Assign C++ Array to ROS Msg Array
How do I assign a C++ array to a ROS message array? In particular, how do I do this for a float64[9] array?
ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
How do I assign a C++ array to a ROS message array? In particular, how do I do this for a float64[9] array?
The std_msgs/Float64MultiArray message should do what you want:
http://docs.ros.org/api/std_msgs/html...
The message structure has a single field called data
which can be treated as a std::vector<double>
type in your C++ node. If you know it will be a fixed array of 9 values, just allocate 9 elements in the vector after declaring the message variable:
std_msgs::Float64MultiArray array_msg;
array_msg.data.resize(9);
You can then publish and subscribe to a topic to transmit array messages between your nodes.
I hope this helps!
float64[9] is defined as of type boost::array<double,ul9>
, so try following declaration:
boost::array<double, ul9> array_msg
Asked: 2016-04-22 16:01:53 -0500
Seen: 10,379 times
Last updated: Apr 23 '16
ROS2 equivalents to ROS1 roscd, rosmsg rossrv...
"rosmsg package <packagename>" does not show action messages from the package
Unable to load msg [sensor_msgs/]
how does one index array in rospy?
Python cannot import geometrical Point array
how to print name of elements of ros message
Is the "byte" type in messages signed or unsigned?
rosmsg md5 Cannot locate message
Control 8x8 grid of RGB LEDs like Raspberry Pi Sense Hat or Unicorn Hat?