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

Gazebo is not able to send the joint states to generate tf tree.

asked 2020-06-19 07:00:31 -0500

Hugo gravatar image

updated 2022-05-28 17:08:54 -0500

lucasw gravatar image

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/1JWmT...

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"?>
  <launch>  
  <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)"/>
</include>

<!-- 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>

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

<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" />
</node>

<!-- 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">    
</node>

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

The command rostopic echo returns:

header:

seq: 48780

stamp:

secs: 53

nsecs: 311000000  

frame_id: ''

name: [frame__crank]

position: [-0.1847331807173509]

velocity: [-0.027513476836548797]

effort: [14.126169875336736]

--- header:

seq: 48781
stamp:

secs: 53

nsecs: 312000000

frame_id: ''

name: [frame__crank]

position: [-0.18476008023893709]

velocity: [-0.027133224871914673]

effort: [14.117217536586715]


edit retag flag offensive close merge delete

Comments

Could you post your launch files? Maybe this makes it easy to answer your question correctly.

Teo Cardoso gravatar image Teo Cardoso  ( 2020-06-19 14:25:52 -0500 )edit

Hi Teo, thank you for helping. I have edited the question and put the launch file.

Hugo gravatar image Hugo  ( 2020-06-19 14:39:40 -0500 )edit

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
Teo Cardoso gravatar image Teo Cardoso  ( 2020-06-19 14:59:00 -0500 )edit

Did you using joint_state_publisher only with

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

or did you try with this parameter set False ?

Teo Cardoso gravatar image Teo Cardoso  ( 2020-06-19 15:17:36 -0500 )edit

I have edited and put the rostopic echo response.

Hugo gravatar image Hugo  ( 2020-06-19 15:20:49 -0500 )edit

I am using just joint_state_publisher. I delete the line param name="use_gui" value="True"

Hugo gravatar image Hugo  ( 2020-06-19 15:22:21 -0500 )edit

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.

Teo Cardoso gravatar image Teo Cardoso  ( 2020-06-20 03:32:27 -0500 )edit

Thank you for your help Teo. I think that I have found a solution (maybe not the best one, but it works... hehe).

Hugo gravatar image Hugo  ( 2020-06-23 06:10:24 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-06-23 06:21:17 -0500

Hugo gravatar image

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:

<gazebo>
    <plugin name="joint_state_publisher" filename="libgazebo_ros_joint_state_publisher.so">
        <robotNamespace>/mm</robotNamespace>
        <jointName>${base_link}__${frame}, 
                   ${frame}__${crank}, 
                   ${crank}__${coupler}, 
                   ${fork}__${wheel}, 
                   ${frame}__${rocker}
        </jointName>
    </plugin>    
</gazebo>

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

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2020-06-19 07:00:31 -0500

Seen: 1,223 times

Last updated: Jun 23 '20