Ask Your Question

Publish nan to a jointState topic

asked 2017-11-12 16:04:51 -0500

Tanvir gravatar image

updated 2017-11-13 02:29:51 -0500

gvdhoorn gravatar image

Hi, I want to publish a jointState message from terminal with NaNs as the values inside some of its fields. Is there a way I can do that.

If I do

rostopic pub -r 2 /test sensor_msgs/JointState "header:
  seq: 0
  stamp: {secs: 0, nsecs: 0}
  frame_id: '/test'
name: ['l', 'r']
position: [0.0, 0.0]
velocity: [0.0, 0.0]
effort: [nan, nan]"

I get the following error

Unable to publish message. One of the fields has an incorrect type:
  <class 'struct.error'>: 'required argument is not a float' when writing '/test'


edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2017-11-13 02:26:43 -0500

gvdhoorn gravatar image

updated 2017-11-13 02:29:18 -0500

ROS uses YAML for this, and according to the YAML 1.1 Reference card the value should be .NAN (all caps, with the dot):

Language Independent Scalar types:
  [ .inf, -.Inf, .NAN ]    : [ Infinity (float), Negative, Not a number ]

The following seems to work for me:

rostopic pub -r 1 /some_topic std_msgs/Float64 '.NAN'
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2017-11-12 16:04:51 -0500

Seen: 1,104 times

Last updated: Nov 13 '17