Search code examples
rosgazebo-simu

How to set robot position [amcl_pose (x,y)] in rviz to (0.0000,0.00000) on top left corner


I have created a small map in the gazebo, after launching the gazebo, RVIZ, and map server the robot is loading in the middle of the map, and (x,y) position is (0.00000,0.00000) as shown in the image.

enter image description here

I want to load the robot at the top-left corner of the map the position of that coordinate should be (0.00000,0.00000). How can I achieve this?


Solution

  • When publishing the map on the map server you can specify the map.yaml with desired settings.

    image: testmap.png
    resolution: 0.1
    origin: [0.0, 0.0, 0.0]
    occupied_thresh: 0.65
    free_thresh: 0.196
    negate: 0
    

    To achieve what you desire you need to change X and Y coordinated of the origin. You can read the desired values from RViz with pointing the mouse the desired position and then writing those values in the map.yaml.

    In the case when spawning the robot on the border of the map be careful since it can happen that the robot will not be able to find a valid path (since it is outside of known area).

    Check official documentation for more information on how to use the map.yaml and what options are there.