Rosanswers logo

Hi everyone,

I am trying to see my robot in gazebo and rviz, but I am not able to send the joint states to robot_state_publisher directly from gazebo to generate the tf tree. For this reason, the robot does not appear correctly in rviz. When I use the joint_state_publisher, the robot is correctly shown in rviz but it not move like in gazebo.

This is the graph: https://drive.google.com/file/d/1JWmTUJFmxBdJfqylPs48tfCttL0wLLjw/view?usp=sharing

If I remove the joint_state_publisher, rviz loose the transformation between movable joints.

What am I doing wrong?

EDIT: Here follows the launch file:

<?xml version="1.0"?>
  <arg name="paused" default="false"/>
  <arg name="use_sim_time" default="true"/>
  <arg name="gui" default="true"/>
  <arg name="debug" default="false"/>

<include file="$(find gazebo_ros)/launch/empty_world.launch">
    <arg name="world_name" value="$(find mm_description)/worlds/mm.world"/>
    <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)"/>

<!-- Robot model -->
<param name="robot_description" command="$(find xacro)/xacro '$(find mm_description)/urdf/mm.xacro'" />

<arg name="x" default="0"/>
<arg name="y" default="0"/>
<arg name="z" default="0.5"/>

<!-- Spawn the robot model -->
<node name="mybot_spawn" pkg="gazebo_ros" type="spawn_model" output="screen" args="-urdf -param robot_description -model mm -x $(arg x) -y $(arg y) -z $(arg z)" /> 

<!-- send joint values -->
<node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher">
    <remap from="/joint_states" to="/mm/joint_states" />
    <param name="use_gui" value="True"/>    

<node name="joint_state_spawner" pkg="controller_manager" type="spawner"
         respawn="false" output="screen" ns="/mm"

<node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher" respawn="false" output="screen">
    <remap from="/joint_states" to="/mm/joint_states" />

<!-- Load joint controller configurations from YAML file to parameter server -->
<rosparam file="$(find mm_control)/config/mm_state_controller.yaml" command="load"/>
<rosparam file="$(find mm_control)/config/mm_controllers.yaml" command="load"/>
<rosparam file="$(find mm_control)/config/mm_actuators.yaml" command="load"/>

<!-- load the controllers -->
<node name="controller_spawner" pkg="controller_manager" type="spawner" respawn="false"
    output="screen" ns="/mm" args="position_controller">    

<!-- Show in Rviz  -->
<node name="rviz" pkg="rviz" type="rviz" args="-d $(find mm_description)/launch/config.rviz"/>

The command rostopic echo returns:


seq: 48780


secs: 53

nsecs: 311000000  

frame_id: '' 

name: [frame__crank]

position: [-0.1847331807173509]

velocity: [-0.027513476836548797]

effort: [14.126169875336736]

--- header:

seq: 48781

secs: 53

nsecs: 312000000  

frame_id: ''

name: [frame__crank]

position: [-0.18476008023893709]

velocity: [-0.027133224871914673]

effort: [14.117217536586715]

Originally posted by Hugo on ROS Answers with karma: 41 on 2020-06-19

Post score: 0

Original comments

Comment by Teo Cardoso on 2020-06-19:
Could you post your launch files? Maybe this makes it easy to answer your question correctly.

Comment by Hugo on 2020-06-19:
Hi Teo, thank you for helping. I have edited the question and put the launch file.

Comment by Teo Cardoso on 2020-06-19:
Weird, this looks right to me. Deactivate the joint_state GUI and if is possible, post the result of

rostopic echo /mm/joint_states -n2

Comment by Teo Cardoso on 2020-06-19:
Did you using joint_state_publisher only with

<param name="use_gui" value="True"/>   

or did you try with this parameter set False ?

Comment by Hugo on 2020-06-19:
I have edited and put the rostopic echo response.

Comment by Hugo on 2020-06-19:
I am using just joint_state_publisher. I delete the line param name="use_gui" value="True"

Comment by Teo Cardoso on 2020-06-20:
I tried to check the main reason for failure, however, I couldn' t find. If there is any public github repository with the project I would like to know. Otherwise, really sorry, but I don't know how I can help you.

Comment by Hugo on 2020-06-23:
Thank you for your help Teo. I think that I have found a solution (maybe not the best one, but it works... hehe).

Comment by Teo Cardoso on 2020-06-23:
I'm glad to hear this ^^


1 Answer 1


Rosanswers logo

The way that I have found to solve this issue is remove the joint_state_publisher from launch file and put it in the xacro file like this:

    <plugin name="joint_state_publisher" filename="libgazebo_ros_joint_state_publisher.so">

Now the robot's movements in Rviz are the same as in Gazebo and the TF tree is made correctly.

Originally posted by Hugo with karma: 41 on 2020-06-23

This answer was ACCEPTED on the original site

Post score: 0


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.