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

JointState message(s) with heterogeneous position and velocity sensors

asked 2016-09-30 04:59:27 -0600

barthelemy gravatar image


I'd like to produce JointState messages for a robot (Pepper). The messages are typically stored in a rosbag for debugging using plots and rviz.

The robot has several joints, some of them having position sensors, others having only velocity sensors (wheels).

I'm wondering about the proper way to fit this data in one or several JointState messages.

I tried using NaN for missing data as in:

name = ["HeadYaw", "WheelB"]
position = [0.1111, nan]
velocity = [nan, 0.0022]
effort = []

But rviz (or tf?) noisily complains about it. It prints this log for each message:

[ERROR] [1475223793.988530679, 1179.142482190]: Ignoring transform for child_frame_id "WheelB_link" from authority "unknown_publisher" because of a nan value in the transform (nan nan nan) (nan nan nan nan)

I can imagine workarounds:

  • use zeros instead of NaN,
  • integrate the velocity to compute a position of NaN,

but I fear to lure users into believing we have position sensors.

Another solution would be to write two JointState messages in the same topic. One for joints with position sensors, another one for joints with velocity sensors, like this:

name = ["HeadYaw"]
position = [0.1111]
velocity = []
effort = []

name = ["WheelB"]
position = []
velocity = [0.0022]
effort = []

This solution seems clean and a bit more efficient. Is it supported?

When trying it I get spammed by this log

[ERROR] [1475228046.318736664, 1475228032.225733209]: Robot state publisher received an invalid joint state vector

Apparently coming from this check:

if (state->name.size() != state->position.size()){
  ROS_ERROR("Robot state publisher received an invalid joint state vector");

in joint_state_listener.cpp.

I suspect the check is wrong, given the JointState message definition:

All arrays in this message should have the same size, or be empty. This is the only way to uniquely associate the joint name with the correct states.

So to summarize, my questions are:

  • what is the proper way to fit my data into JointState message(s)?
  • Am I right thinking the joint_state_listener log is a bug?

Thank you!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2016-10-17 17:01:52 -0600

tfoote gravatar image
edit flag offensive delete link more

Question Tools



Asked: 2016-09-30 04:59:27 -0600

Seen: 1,211 times

Last updated: Oct 17 '16