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

How do I use tuple datatype in my custom message?

asked 2018-01-09 05:31:52 -0600

SS2.0 gravatar image

The data I want to publish is in a tuple. Initially i tried using int64 [] field type in my custom message, but that did not work, which makes sense. How do I use tuple field type?

edit retag flag offensive close merge delete

Comments

Welcome! Can you please show us what you've tried by updating your question with your code and the data that you're trying to publish? Also, what does

did not work

mean? Did you get an error?

jayess gravatar image jayess  ( 2018-01-09 08:12:46 -0600 )edit

I do not have access to the code immediately. The data I am trying to publish is a tuple containing 3 ints and a bytearray. The data is bulk data so it is 256 tuples that I am trying to publish at once. When I used int64 [], it gave a serialization error.

SS2.0 gravatar image SS2.0  ( 2018-01-09 08:31:40 -0600 )edit

Ok, when you do get access to it please update your question with it along with a copy and paste of the error.

jayess gravatar image jayess  ( 2018-01-09 08:32:59 -0600 )edit

I am not able to copy paste the code here due to the character limit

SS2.0 gravatar image SS2.0  ( 2018-01-09 19:29:39 -0600 )edit

You can edit your question to do that. Comments are good for providing updates to questions for this reason.

jayess gravatar image jayess  ( 2018-01-09 22:50:31 -0600 )edit

Thanks for the advice. I have done that.

SS2.0 gravatar image SS2.0  ( 2018-01-09 23:34:26 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2018-01-09 13:44:27 -0600

From your comment above you'll need to make two messages to do this. The first message will be your tuple containing the three ints and the byte array. Then you'll need to make another message which is an array of the first message type.

By nesting custom messages like this complex data structures can be created. Let us know how you get on with this.

edit flag offensive delete link more

Comments

Is there a tuple datatype in rospy?

SS2.0 gravatar image SS2.0  ( 2018-01-09 19:17:58 -0600 )edit

(0 0x1a4 0x0000100000000035 8)

This is an example of what I want to publish. There are 256 of these tuples that I want to publish in one go. What fieldtype do I define in my ROS custom message?

SS2.0 gravatar image SS2.0  ( 2018-01-09 19:25:52 -0600 )edit

Got it working now. Thanks for the advice.

SS2.0 gravatar image SS2.0  ( 2018-01-11 21:56:35 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2018-01-09 05:31:52 -0600

Seen: 2,649 times

Last updated: Jan 09 '18