ROS Melodic, Ubuntu18, Gazebo9
Issue: Not able to visualize laser scan data in rviz
Error: No tf data. Actual error: Fixed Frame [map] does not exist
Steps to recreate:
- Launch gazebo with ros
roslaunch gazebo_ros empty_world.launch
- Insert Hokuyo laser sensor. Go to the insert tab in gazebo and add the hokuyo model to the world. Also add a few blocks near the sensor (for visualization).
- Open rviz
rviz
Rviz gives the error as mentioned above. I have done rostopic list and saw that there was /laser/scan topic, but there was no /tf topic. I added the LaserScan visualisation to rviz.
I did rostopic echo on /laser/scan and the data was actually being published properly. I am not doing slam or anything, I just want to visualize the scan data in rviz.
Who publishes this map frame? Should I be publishing this? If so, how should I?
Originally posted by pravardhan on ROS Answers with karma: 38 on 2020-05-18
Post score: 2
Original comments
Comment by Roberto Z. on 2020-05-18:
Rviz is a ROS tool and Gazebo does not require ROS to run and does not natively publish ros topics and ros TF's. So you need an interface for using ROS with Gazebo. Following just the steps mentioned above does not provide a rostopic. Running roscore and then rviz just provides these ros topics:
/clicked_point
/initialpose
/move_base_simple/goal
/rosout
/rosout_agg
/tf
/tf_static
But if you do have a rostopic showing up a laser msg, as you mention, you should also have an URDF model with a plugin definition on it? Could you confirm?
Comment by pravardhan on 2020-05-18:
The included hokuyo model does use a laser plugin.
<plugin name="laser" filename="libRayPlugin.so" />
<plugin name="gazebo_ros_head_rplidar_controller" filename="libgazebo_ros_laser.so">
<topicName>laser/scan</topicName>
<frameName>map</frameName>
</plugin>
This is in the sdf of the hokuyo laser. As u can see the frameName is set to map but there is no tf topic being published. You are right that gazebo doesn't require ros to run, but see that I am not opening gazebo from my app drawer, I am opening it with the launch file which will bind gazebo to ros.