Joint State Publisher produces empty messages
Hello,
This questions can be split into two:
The first one. I am currently using in my URDF in Gazebo a ROS_control controller to control the platform wheels (velocity and position interface) and I am wondering if there is a way to plot the PID values in order to see the performance. Since I do not have any /command/data and /state/process_value topics I cannot plot the behavior of the PIDs.
The second one is related to the first question. Since I do not have those topics I want now to plot the changes on the jointStates. Robot_state_publisher and joint_state_publisher are launched properly but when you read the joint state topic there are certain messages which appear to be empty, this follows a pattern because this empty message happens every 4 messages, the 5th one is the empty one:
header:
seq: 74
stamp:
secs: 7
nsecs: 400000000
frame_id: ''
name: [front_right_wheel_steer_joint, front_right_wheel_joint, front_right_shock,
front_left_wheel_steer_joint, front_left_wheel_joint, front_left_shock,
back_right_wheel_steer_joint, back_right_wheel_joint, back_right_shock,
back_left_wheel_steer_joint, back_left_wheel_joint, back_left_shock]
position: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
velocity: []
effort: []
Joint state publisher node is publishing at a rate of 50 and I thought that was the problem, but changes on that value will output the same behavior.
If someone can help me with this I will appreciate.
Thanks in advance.
Update:
Here is the launch file:
<?xml version="1.0"?>
<launch>
<!-- these are the arguments you can pass this launch file, for example paused:=true -->
<arg name="gui" default="true"/>
<arg name="use_joint_state_publisher" default="false"/>
<arg name="setup" default="setup_4"/> <!-- Different setups for the sensors -->
<arg name="ultrasonic_on" default="1"/> <!-- Different setups for the sensors -->
<arg name="zed_on" default="1"/> <!-- Different setups for the sensors -->
<group ns="ares">
<!-- Load the URDF into the ROS Parameter Server -->
<param name="robot_description"
command="$(find xacro)/xacro --inorder '$(find ares_description)/urdf/bus/ares.xacro' setup:=$(arg setup)
ultrasonic_on:=$(arg ultrasonic_on) zed_on:=$(arg zed_on)" />
<!-- send fake joint values -->
<node if="$(arg use_joint_state_publisher)" name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher" output="screen"/>
<!-- Combine joint values -->
<node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher" output="screen"/>
<!-- Display with rviz -->
<node name="rviz" pkg="rviz" type="rviz" respawn="false" output="screen"/>
</group>
</launch>
If you change the parameter use_joint_state_publisher
to true the model is well defined in tf and visualize in rviz.
Are you quite sure only a single node is publishing the joint states topic? Typically when I get occasional messages with completely different values it's because there are two nodes publishing on the same topic.
Hello @jdlangs
In fact there are two Publishers: Gazebo and Joint_state_publisher, but I think that is the correct behavior.
I think what @jdlangs pointed out is most likely the problem. Usually, you would have either gazebo or the joint state publisher sending messages, but not both. The typical use case is: you build your URDF and use the joint state publisher to debug it. Then, as soon as your gazebo simulation is ready, gazebo publishes the actual message and you do not need the other anymore. There are cases in which you might still want the joint state publisher to run, but not in general. The reason is that the joint state publisher generally has an "internal fake state" that is updated via the gui, and thus it would differ from the actual state provided by a simulator. Also, it generally does not include velocity/effort info, making me think this is the problem. Are both gazebo and the joint state publisher sending messages on
/joint_states
? If so, give ...(more)As @ffusco said I removed from my launch file the launch of the joint_state_publisher and now all the messages in the
/joint_states
topic are properly filled. However, now I have the problem of a broken tf tree because I am not able to see the model in rviz.Is the robot state publisher printing and message on the console? (make sure to add the attribute
output=screen
in the launch file) In addition, is the RViz robot model display reporting any issue?The robot_state_publisher has the attribute
output=screen
and does not produce any warnings or errors. In Rviz the problem resides in the tf tree, since there are no transforms between the vehicle base and the wheels. Thus, Rviz shows the vehicle chassis but not the wheels.There is a good chance the node responsible for publishing
JointState
s is not publishing them for alljoint
s defined in your urdf.That would cause the RSP to not do FK, leading to missing transforms, causing the error you get in RViz.
As far as I understood
joint_state_publisher
node is needed byrobot_state_publisher
to build the tf tree. The problem rises when Gazebo ANDjoint_state_publisher
node publish on the same topic/joint_states
with different messages. I have 12 joints for the wheels: 4 linear movement, 4 steering and 4 shock absorbers. To my knowledge, Gazebo is publishing on/joint_states
empty messages with all 12 joints names, whilejoint_state_publisher
node is publishing filled messages with only 8 joints, without the shock ones.In truth I only want this data to debug what is happening in the wheels... I decided to record a rosbag and filter the empty messages. But I do not really able to understand and find why this empty messages are produced.
I am going to update the question with my launch file.