problem about indexToCells function of costmap2d

23 views
Skip to first unread message

youha...@gmail.com

unread,
Aug 4, 2017, 1:20:49 AM8/4/17
to ros-sig-navigation
when I saw the costmap_2d.h, I got the definition of indexToCells is as follows:
inline void indexToCells(unsigned int index,unsigned int& mx,unsigned int& my) const
{
my=index/size_x_;
mx=index-(my*size_x_);
}
if my=index/size_x_,so mx=index-(my*size_x_)=index-(index/size_x_*size_x_)=index-index=0.In conlusion,mx=0.
I can´t understand why mx is zero?And if mx is zero,why can we set it to zero directly?


David Lu!!

unread,
Aug 8, 2017, 3:32:32 PM8/8/17
to ros-sig-n...@googlegroups.com
The values are stored in row-major order, where rows equate to y
values. https://en.wikipedia.org/wiki/Row-_and_column-major_order

In your math, you're not taking the integer arithmetic into
consideration. There's an implicit casting happening such that my is
really int(index/size_x_)
> --
> You received this message because you are subscribed to the Google Groups
> "ros-sig-navigation" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ros-sig-navigat...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages