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

Unable to serialize Python list in message

asked 2016-10-17 08:56:55 -0500

Cerin gravatar image

How do you store a list of uints in a ROS message? I have a message like:

string frame
string type
uint8 quality
uint8[] a
uint8[] b
uint8[] c
uint8[] d
uint8   width
uint8   height
string data

but when I try to store:

mymsg.a = [1, 2]
mypub.publish(mymsg)

I get the error:

ROSSerializationException: field a[] exceeds specified width [uint8]

Why is this?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2018-12-02 09:35:04 -0500

ray30031 gravatar image

came across similar problem.

I think it is because python int is 64bit and you are putting it in a array of uint8.

try np.array([1,2]).astype(np.uint8)

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2016-10-17 08:56:55 -0500

Seen: 545 times

Last updated: Dec 02 '18