[Rviz, gmapping] my robot randomly jumps in rviz

asked 2020-01-16 05:45:50 -0600

Marcus Barnet gravatar image

updated 2022-03-20 10:06:45 -0600

lucasw gravatar image

I created my own robot with mecanum wheels and I'm able to correctly move it under Gazebo. The problem is that when I try to use gmapping to simulate the robot in RVIZ, it starts jumping around the map as soon as I try to move it in Gazebo. I guess the problem is with the laser since I get this error when I run gmapping:

Scan Matching Failed, using odometry

This is my world in Gazebo: image description

and this is the result in RVIZ: image description

and this is a short video that shows what happens in RVIZ while the robot moves in Gazebo.

This is my code:


  <arg name="paused" default="false"/>
  <arg name="use_sim_time" default="true"/>
  <arg name="extra_gazebo_args" default=""/>
  <arg name="gui" default="true"/>
  <arg name="recording" default="false"/>
  <!-- Note that 'headless' is currently non-functional.  See gazebo_ros_pkgs issue #491 (-r arg does not disable
       rendering, but instead enables recording). The arg definition has been left here to prevent breaking downstream
       launch files, but it does nothing. -->
  <arg name="headless" default="false"/>
  <arg name="debug" default="false"/>
  <arg name="physics" default="ode"/>
  <arg name="verbose" default="false"/>

   <include file="$(find gazebo_ros)/launch/empty_world.launch">
   <arg name="world_name" value="$(find pavioliner_gazebo)/worlds/pavilion.world"/>

  <arg name="respawn_gazebo" default="false"/>
  <arg name="use_clock_frequency" default="false"/>
  <arg name="pub_clock_frequency" default="100"/>
  <arg name="enable_ros_network" default="true" />

  <!-- set use_sim_time flag -->
  <param name="/use_sim_time" value="$(arg use_sim_time)"/>

  <!-- start gazebo server-->
  <group if="$(arg use_clock_frequency)">
    <param name="gazebo/pub_clock_frequency" value="$(arg pub_clock_frequency)" />
    <param name="gazebo/enable_ros_network" value="$(arg enable_ros_network)" />
  <node name="gazebo" pkg="gazebo_ros" type="$(arg script_type)" respawn="$(arg respawn_gazebo)" output="screen"
    args="$(arg command_arg1) $(arg command_arg2) $(arg command_arg3) -e $(arg physics) $(arg extra_gazebo_args) $(arg world_name)" />

  <!-- start gazebo client -->
  <group if="$(arg gui)">
    <node name="gazebo_gui" pkg="gazebo_ros" type="gzclient" respawn="false" output="screen" args="$(arg command_arg3)"/>


<!-- Load the URDF into ROS parameter server -->
  <param name="robot_description" command="$(find xacro)/xacro '$(find pavioliner_description)/robot/pavioliner.urdf.xacro' --inorder" />

  <!-- Publish joint values -->
  <node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher" />

  <!-- convert joint states to TF transforms for rviz, etc  -->
  <node name="robot_state_publisher" pkg="robot_state_publisher" type="state_publisher"/>

  <!-- Spawn model -->
  <node name="urdf_spawner" pkg="gazebo_ros" type="spawn_model" respawn="false" output="screen"
    args="-urdf -x 0 -y 0 -z 0  -model pavioliner -param robot_description"/>


this is my pavioliner.urdf.xacro

<?xml version="1.0"?>

<robot name="pavioliner_xl" xmlns:xacro="http://www.ros.org/wiki/xacro">

    <!-- Import pavioliner XL wheels -->
    <xacro:include filename="$(find pavioliner_description)/urdf/wheels/omni_wheel.urdf.xacro" />
    <xacro:include filename="$(find pavioliner_description)/urdf/base/pavioliner_base.urdf.xacro" />

     <!-- Laser  -->
         <xacro:include filename="$(find pavioliner_description)/plugins/laser/hokuyo.xacro"/>
         <xacro:laser name="pavioliner/laser" parent ...
edit retag flag offensive close merge delete


I'm not a navigation or mapping expert at all, but your Gazebo world is very empty, with only a few objects in it. Most mapping (and localisation) approaches need features to match (ie: objects they can 'recognise').

I'd try adding some more features (or increasing the scan range of the laser, as that may allow it to 'see' sufficient features).

gvdhoorn gravatar image gvdhoorn  ( 2020-01-16 05:50:24 -0600 )edit

I tried to increase the number of objects inside the World and i also increased the laser range to 80 meters, but nothing changed, I still got the same message error Scan Matching Failed, using odometry. Likelihood=0 and the robot randomly and quickly jumps on the map under RVIZ without any logic reason.

Marcus Barnet gravatar image Marcus Barnet  ( 2020-01-16 06:22:02 -0600 )edit

I think your error is pretty clear: scan matching failed, not enough features. Its not just the range, its the stuff you have and since its a simulation those walls are perfectly flat so you're not getting ambient features from cracks and misplacments.

stevemacenski gravatar image stevemacenski  ( 2020-01-16 12:57:58 -0600 )edit

Can't it be a problem related to the laser? I can't see the laser points in rviz when I set fixed frame to laser frame and this sounds strange to me. I added the hokuyo.acro that I've found online, may be I have a problem with it. What do you think?

Marcus Barnet gravatar image Marcus Barnet  ( 2020-01-16 15:21:10 -0600 )edit

I guess my/the assumption was that you've got the laserscanner working properly.

If you're not sure about that, I would certainly recommend to diagnose that first.

gvdhoorn gravatar image gvdhoorn  ( 2020-01-16 15:36:07 -0600 )edit

Unfortunately I do not know how to diagnose it correctly. I can read successfully from the laser topic, the laser tf is OK as you can see from the tf tree. The only problem is that I don't know if the hokuyo.xacro file is correctly configured. I added the code of it in my first post. I'm almost sure that the problem is in the laser file but I don't know how to find it

Marcus Barnet gravatar image Marcus Barnet  ( 2020-01-16 16:06:20 -0600 )edit