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

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'

Thanks.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
5

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

Question Tools

1 follower

Stats

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

Seen: 1,644 times

Last updated: Nov 13 '17