Rviz map position issue

asked 2021-02-04 05:25:05 -0500

sisko gravatar image

updated 2022-03-25 17:34:53 -0500

lucasw gravatar image

I mapped the willow garage office using Gmapping and saved the map using the map_server node. My launch file has the following fragment to load the saved map:

<!-- Map Server -->
    <arg name='map' value='$(find my_bot)/maps/willow_garage_map.yaml'/>
    <node name="map_server" pkg="map_server" type="map_server" output="screen" args='$(arg map)'/>

But I get the strangest results in rviz. The map and the robot are located quite a distance away from each other.

image description

My robot with lidar detecting "invisible walls"

image description

My robot and map seem to want a divorce

I would appreciate some help to understand what I've done wrong and how I can unite robot and map so I can carry out some path planning and navigation.

UPDATE #1 :

Contents of willow_garage_map.yml :

image: willow_garage_map.pgm
resolution: 0.050000
origin: [-100.000000, -100.000000, 0.000000]
negate: 0
occupied_thresh: 0.65
free_thresh: 0.196

I also discovered the Map display of Rviz has an configured with the /map topic geneates an error. I confirmed the map topic exists and also has data published into it.

image description

UPDATE #2 :

image description

rosrun tf tf_echo map odom

Failure at 157.725000000
Exception thrown:"map" passed to lookupTransform argument target_frame does not exist. 
The current list of frames is:
Frame hokuyo_link exists with parent chasis.
Frame chasis exists with parent odom.
Frame left_camera exists with parent chasis.
Frame overwatch_camara exists with parent chasis.
Frame right_camera exists with parent chasis.

Failure at 157.725000000
Exception thrown:"map" passed to lookupTransform argument target_frame does not exist. 
The current list of frames is:
Frame hokuyo_link exists with parent chasis.
Frame chasis exists with parent odom.
Frame left_camera exists with parent chasis.
Frame overwatch_camara exists with parent chasis.
Frame right_camera exists with parent chasis.

Failure at 158.725000000
Exception thrown:"map" passed to lookupTransform argument target_frame does not exist. 
The current list of frames is:
Frame hokuyo_link exists with parent chasis.
Frame chasis exists with parent odom.
Frame left_camera exists with parent chasis.
Frame overwatch_camara exists with parent chasis.
Frame right_camera exists with parent chasis.
Frame wheel_left_aft exists with parent chasis.
Frame wheel_left_fore exists with parent chasis.
Frame wheel_right_aft exists with parent chasis.
Frame wheel_right_fore exists with parent chasis.

And . . . (my base_link is called chasis)

rosrun tf tf_echo odom chasis

At time 298.426
- Translation: [0.001, -0.019, 0.350]
- Rotation: in Quaternion [0.000, 0.000, -0.033, 0.999]
            in RPY (radian) [0.000, 0.000, -0.066]
            in RPY (degree) [0.000, 0.000, -3.776]
At time 298.426
- Translation: [0.001, -0.019, 0.350]
- Rotation: in Quaternion [0.000, 0.000, -0.033, 0.999]
            in RPY (radian) [0.000, 0.000, -0.066]
            in RPY (degree) [0.000, 0.000, -3.776]
At time 299.426
- Translation: [0.001, -0.019, 0.350]
- Rotation: in Quaternion [0.000, -0.000, -0.033, 0.999]
            in RPY (radian) [0.000, -0.000, -0.066]
            in RPY (degree) [0.000, -0.000, -3.789]
At time 300.426 ...
(more)
edit retag flag offensive close merge delete

Comments

2

what is the content of willow_garage_map.yaml ?
Specifically, what is the value for the field origin in that file?
Also, could your run rostopic echo /map_metadata and post the output?
And what is the initial pose of your robot in gazebo? Is it at x=0, y=0 or somewhere else?

Roberto Z. gravatar image Roberto Z.  ( 2021-02-04 08:07:22 -0500 )edit
1

Try using the set_pose button at the top of the RVIZ GUI to give your robot an initial location. You have to realize that your robot doesn't magically know things about its position in the world, you must be very deliberate to tell it those things

JackB gravatar image JackB  ( 2021-02-04 17:04:54 -0500 )edit

@roberto: Thanks for your input. I updated my question with more data including the contents of willow_garage_map.yaml. I confirmed /map and /map_metadata have content. map_metadata below:

rostopic echo /map_metadata 
map_load_time: 
  secs: 0
  nsecs:   6000000
resolution: 0.0500000007451
width: 4000
height: 4000
origin: 
  position: 
    x: -100.0
    y: -100.0
    z: 0.0
  orientation: 
    x: 0.0
    y: 0.0
    z: 0.0
    w: 1.0

I did alter the position values of x & y to zero but when I launched rviz my model still was not in the map.

sisko gravatar image sisko  ( 2021-02-04 18:55:43 -0500 )edit

@JackB: Thanks for your input. Are you refering to the 2D pose estimate button? I tried that but I got no particle filters. That might be a different issue to tacle.

sisko gravatar image sisko  ( 2021-02-04 18:58:09 -0500 )edit

From the data I can see that your map origin appears to be ok! [-100,-100,0]
Maybe it is an offset caused by your TF's, how does your TF tree structure looks like?
What are the numerical values of the transformation from map to odom, and from odom to base_link?
rosrun tf tf_echo map odom
rosrun tf tf_echo odom base_link

Roberto Z. gravatar image Roberto Z.  ( 2021-02-05 02:47:05 -0500 )edit

@roberto: I aded the TF tree and the other requested data to the update#2 section of my question

sisko gravatar image sisko  ( 2021-02-05 06:17:46 -0500 )edit
2

You don't have the tf between map and odom, what are you using for the localization of the robot ? The node map_server doesn't localize the robot in the map, you need AMCL for example.

Delb gravatar image Delb  ( 2021-02-05 06:40:05 -0500 )edit
2

Yes agree,I think Rviz is missing the transform between map and odom. You need to broadcast a transform between map and odom.

As a quick fix try this:
rosrun tf static_transform_publisher 0 0 0 0 0 0 map odom 100

or add a static transform to your launch file:
<node pkg="tf2_ros" type="static_transform_publisher" name="odom_wrt_map_tf" args="0 0 0 0 0 0 map odom" />

Also it is necessary to correctly configure Rviz's Global Options. What is value for the field Fixed Frame under “Global Options."?

It should be set to map

Roberto Z. gravatar image Roberto Z.  ( 2021-02-05 07:36:09 -0500 )edit