ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

How can I find the index of the cell from map coordinates ?

asked 2018-03-11 11:01:40 -0500

Developer gravatar image

Hi

I have the (x,y,z) position of the map. From that information, how can I find the cell index and also costmap value(free, obstacle ...) related to this coordinates ?

thanks

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
1

answered 2018-03-12 12:18:55 -0500

David Lu gravatar image
edit flag offensive delete link more

Comments

Hi David, I could not understand your solution proposal. Let me explain the case better. I have a position(x,y,z) of a map on Rviz. And from that position information, I want to first find related cell index(I m no sure, if gridcell or costmap).Than I want to change this cost value manually.

Developer gravatar image Developer  ( 2018-03-12 14:11:12 -0500 )edit

Do you have a Costmap2dROS object that you are manipulating in code?

David Lu gravatar image David Lu  ( 2018-03-13 16:38:37 -0500 )edit

No I don t have. I try to get the position of the related grid from the position of the interactive marker that I put on the Rviz (map). And change the value of this grid.

Developer gravatar image Developer  ( 2018-03-14 18:29:19 -0500 )edit
1

answered 2018-03-14 01:24:11 -0500

David is right , in detail , you can see the code in worldToMap below:

  /**
   * @brief  Given two map coordinates... compute the associated index
   * @param mx The x coordinate
   * @param my The y coordinate
   * @return The associated index
   */
  inline unsigned int getIndex(unsigned int mx, unsigned int my) const
  {
    return my * size_x_ + mx;
  }
edit flag offensive delete link more

Comments

thanks man !

Developer gravatar image Developer  ( 2018-03-14 18:27:58 -0500 )edit
1

This only works if the unsigned ints are already in map coordinates. You first have to run worldToMap or the equivalent math operations

David Lu gravatar image David Lu  ( 2018-03-14 20:43:48 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2018-03-11 11:01:40 -0500

Seen: 1,187 times

Last updated: Mar 14 '18