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

rostopic publish constant value

asked 2011-12-01 10:29:14 -0500

Nick gravatar image

ROS messages allow the definition of constants (e.g. for emulating enum types). Is there a way to publish these named values in "rostopic pub"?

For example, I have a defined message type Emotion.msg:

uint32 emotion
float64 intensity
uint32 NEUTRAL=0
uint32 HAPPY=1
uint32 SAD=2

The idea is that the emotion value is set to one of the constants, and I don't really want to remember what the constants are as values.

The following works as expected, but is not ideal:

rostopic pub  --once /set_emotion my_msgs/Emotion  1 0.5

Rather, I want to publish something like

rostopic pub  --once /set_emotion my_msgs/Emotion  HAPPY 0.5

or at least

rostopic pub  --once /set_emotion my_msgs/Emotion my_msgs/Emotion/HAPPY 0.5

Neither of these seem to work, since the constants get interpreted as strings. Is there a way to specify named constants in the rostopic utility? Neither of these seems to work.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2011-12-01 13:49:49 -0500

jbohren gravatar image

Since rostopic pub uses YAML for parsing command line arguments, I'm not sure it supports constants (there's nothing about constants on this page, for example: ROS/YAMLCommandLine). What you could use, however, is rosh, which uses an interactive Python specification. See here: rosh/Overview/Topics#rostopic_pub.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2011-12-01 10:29:14 -0500

Seen: 2,660 times

Last updated: Dec 01 '11