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

Rviz doesn't link laser scanner with robot model

asked 2019-08-25 14:00:28 -0500

FabioZ96 gravatar image

updated 2019-08-25 14:03:52 -0500

Hi, I'm using ROS melodic on Ubuntu 18 and I want to perform SLAM using rviz.

I have got a dual drive robot controlled by Arduino via Serial. I have a node that reads/writes data from serial and publish/subscribe them as topic.

This is the topic list:


This is my file .urdf

<robot name="robot">

  <link name="odom">

  <joint name="base_to_odom" type="fixed">
    <parent link="odom"/>
    <child link="base_footprint"/>
    <origin xyz="0 0 0" rpy="0 0 0"/>

  <link name="base_footprint">
        <box size="0.23 0.12 0.01"/>
      <origin rpy="0 0 0" xyz="0 0 0.055"/>
      <material name="black">
        <color rgba="0 0 0 1"/>

This is my launch file for navigation:


  <arg name="model" default="$(find robot)/urdf/robot_z.urdf"/>
  <arg name="gui" default="true" />
  <arg name="rvizconfig" default="$(find robot)/rviz/config_z.rviz" />

  <param name="robot_description" command="$(find xacro)/xacro --inorder $(arg model)" />
  <param name="use_gui" value="$(arg gui)"/>

  <node name="robot_state_publisher" pkg="robot_state_publisher" type="state_publisher" />
  <node name="rviz" pkg="rviz" type="rviz" args="-d $(arg rvizconfig)" required="true" />

  <include file="$(find robot)/launch/includes/gmapping.launch.xml"/>
  <include file="$(find robot)/launch/includes/move_base.launch.xml"/>


I can use a Joystick to move around the robot.

This is my rviz screenshot: Rviz with fixed frame = map

I can move the robot (rappresented by "little car" ) in this world but the laser scanner refers to /odom in the center of world. I tried to change "Fixed frame" from map to "base_footprint" and the robot figure holds in the map while the other axes move around the world with laser scanner points as shown in figure: Rviz with fixed frame = base_footprint

How can I link the robot with laser scanner and odometry?

However I get this warning:

[ WARN] [1566756673.514885761]: Timed out waiting for transform from \base_footprint to \map to become available before running costmap, tf error: canTransform: target_frame \map does not exist. canTransform: source_frame \base_footprint does not exist.. canTransform returned after 0.100995 timeout was 0.1.

I also like to use 2DNavGoal function to comand the robot from rviz but when i use it, nothing in appening.

Thanks a lot. If you need other info I will update the post.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2019-09-05 07:21:02 -0500

FabioZ96 gravatar image

I solved it.

The problem was that the publisher of laser scan, set the frame id to "odom" and not to "scan".

I solved tring this:

scan = LaserScan()
**scan.header.frame_id = "base_scan" #fake_laser_frame"**
...#code to set object's param
scan.ranges = ranges
edit flag offensive delete link more

answered 2019-08-25 18:07:15 -0500

Geoff gravatar image

You are missing important transforms. Without them, your data is not properly tied together. See REP 105 for the coordinate transforms you need to provide.

For the laser scan, you need to tell TF where your laser scanner is in relation to your robot. Add a link to your URDF to represent the laser and then add a joint from the base_footprint to it. Something like this should work, although it won't have a visualisation of the sensor itself and you will need to fix the actual location of the sensor on the robot:

<joint name="base_to_laser" type="fixed">
  <parent link="base_footprint"/>
  <child link="laser"/>
  <origin xyz="0 0 0" rpy="0 0 0"/>

<link name="laser"/>
edit flag offensive delete link more


Thanks for your answer. I tried to add this code to my URDF file and I tried to create joints combining map, odom, base_footprint and others according REP 105. It doesn't work anyway. I still get this warning

[ WARN] [1566983313.478918449]: Timed out waiting for transform from \base_footprint to \map to become available before running costmap, tf error: canTransform: target_frame \map does not exist. canTransform: source_frame \base_footprint does not exist.. canTransform returned after 0.100382 timeout was 0.1.

Nothing changes.

FabioZ96 gravatar image FabioZ96  ( 2019-08-28 04:11:18 -0500 )edit

By "It doesn't work anyway" do you mean the laser data still does not move with the robot?

The warning about navigation should be ignored until you've got the laser data fixed on the robot properly. Then you can start dealing with getting navigation working.

Geoff gravatar image Geoff  ( 2019-08-28 18:41:37 -0500 )edit

Exactly...the laser scan data stay in the center while the robot moves around as shown in first figure.

FabioZ96 gravatar image FabioZ96  ( 2019-08-28 18:59:59 -0500 )edit

Please post the result of running rosrun tf view_frames

Geoff gravatar image Geoff  ( 2019-08-29 17:47:33 -0500 )edit
fabio@fabio:~/Scrivania/ProgettoLab/prog/robot_ws$ rosrun tf view_frames
Listening to /tf for 5.0 seconds
Done Listening
dot - graphviz version 2.40.1 (20161225.0304)

Detected dot version 2.40
frames.pdf generated

Here is the file .pdf generated:

FabioZ96 gravatar image FabioZ96  ( 2019-08-30 03:42:55 -0500 )edit

Question Tools



Asked: 2019-08-25 14:00:28 -0500

Seen: 805 times

Last updated: Sep 05 '19