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

Revision history [back]

click to hide/show revision 1
initial version

I'm not sure I have completely understand your issue but here some insights : try not to represent the environment and the neighbors with up, left, right and down but instead use the axis of the frame of reference because it can also depends of the convention you use. For example, for a map in ROS if you check the REP-103 moving forward is increasing data along x-axis and going left is increasing data along the y-axis, depending of the convention you use it can be differents north/east/west/south but in the end the data is correctly increased/decreased on the propper axis. In utils.cpp l77 you have : Node up(0,-1,1,0,0,0);, meaning that up is decreasing data along the y-axis, if you check the three other declarations you can find that what you call the pink part actually represents how your path planning algorithms represent up, down, left and right. The yellow part is actually how maps are represented in ROS.

With that in mind :

If I take the c++ code and apply it in ROS

There shouldn't be some issues, even though the spatial representations are not the same in the end it just calculates a path based on the input you give. If the up isn't the same as you think but the algorithm calculates that the robot should go up, the coordinate that the algorithm considers to be up would match your map.

About the origin, it can be anything you want, the origin defined in ROS is just corresponding to the first cell of the map data array. In ROS the occupancy grid is a 2D-array and you can find the link between a coordinate and index with those formulas :

index = floor((x - x_origin)/resolution) + floor((y - y_origin)/resolution)*map_width
x = (index % width) * resolution + x_origin
y = ((index - (index % width)) / resolution) + y_origin