the state of the robot is not synchronized in gazebo and rviz

asked 2018-10-07 08:55:03 -0600

this post is marked as community wiki

This post is a wiki. Anyone with karma >75 is welcome to improve it.


  <arg name="paused" default="false"/>  
  <arg name="use_sim_time" default="true"/>  
  <arg name="gui" default="true"/>  
  <arg name="headless" default="false"/>  
  <arg name="debug" default="false"/>

  <include file="$(find gazebo_ros)/launch/empty_world.launch"> 
    <arg name="debug" value="$(arg debug)"/>  
    <arg name="gui" value="$(arg gui)"/>  
    <arg name="paused" value="$(arg paused)"/>  
    <arg name="use_sim_time" value="$(arg use_sim_time)"/>  
    <arg name="headless" value="$(arg headless)"/> 
  <param name="robot_description" command="$(find xacro)/xacro --inorder '$(find vehicle_mover)/urdf/vehicle_mover.urdf.xacro'" />
  <node name="urdf_spawner" pkg="gazebo_ros" type="spawn_model" respawn="false" output="screen" args="-urdf -model vehicle_mover -param robot_description"></node>


  <arg name="model" default="$(find vehicle_mover)/urdf/vehicle_mover.urdf.xacro"/>
  <arg name="gui" default="true" />
  <arg name="rvizconfig" default="$(find vehicle_mover)/rviz/urdf.rviz" />

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

  <node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher" />
  <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" />    

These are the nodes and topics that are generated after the above files are launched: image description

The current situation is that if I control the robot to move in gazebo, the robot observed in rviz is still in place. Obviously this is because /gazebo node is not publishing messages to the /robot_state_publisher node. So how to let gazebo publish messages?

edit retag flag offensive close merge delete