ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A answers.ros.org
Ask Your Question

Revision history [back]

You try to assign a list of lists to my_msg.data. my_msg.data is, however, a list of floats only. How you order the single values needs to be specified in the MultiArrayLayout part my_msg.layout.

You try to assign a list of lists to my_msg.data. my_msg.data is, however, a list of floats only. How you order the single values needs to be specified in the MultiArrayLayout part my_msg.layout.


EDIT

Not quire sure what the ros_tcp_endpoint expects and if it can handle arbitrary msgs.

If it can handle arbitrary messages, I'd go for something more descriptive for a waypoint, then a FloatMultiArray. You could use e.g. a nav_msgs/Path or a geometry_msgs/PoseArray. Or even create your own Waypoint message, e.g. as a list of geometry_msgs/Point.

If, for some reason, you are limited to use a FloatMultiArray, I'd do something along the lines of (rough sketch, so no guarantee that it works, but you should get the idea)

p1 = [x,y,z] # create all the points until pn
my_msgs.data = [*p1, ..., *pn]
my_msgs.layout.data_offset =  0 # no padding
dim = []
dim.append(MultiArrayDimension("points", n, 3*n))
dim.append(MultiArrayDimenstion("coords", 3, 1))
my_msgs.layout.dim = dim