How to publish Int16MultiArray from command line?
I have a C++ subscriber that listens for a message composed of a two integers, which I've implemented with a std_msgs::Int16MultiArray
message type like:
void on_motor_speed(const std_msgs::Int16MultiArray& msg){
///do stuff
}
ros::Subscriber<std_msgs::Int16MultiArray> motor_speed_sub("motor/speed", &on_motor_speed);
Is there an easier way to do this?
How do I test this from the command line using rostopic pub
? Based on this question, I think is should be something like:
rostopic pub motor/speed std_msgs/Int16MultiArray "{layout:{dim:[{label:'', size:0, stride:0}], data_offset:0}, data:[64, 64]}"
but I get the YAML parsing error:
Usage: rostopic pub /topic type [args...]
rostopic: error: Argument error: while scanning a plain scalar
in "<string>", line 1, column 16:
{layout:{dim:[{label:'', size:0, stride:0}], da ...
^
found unexpected ':'
in "<string>", line 1, column 21:
{layout:{dim:[{label:'', size:0, stride:0}], data_of ...
^
Please check http://pyyaml.org/wiki/YAMLColonInFlowContext for details.
As far as I know, YAML does support the inline syntax, and doesn't need to be multi-line. What am I doing wrong?