How to sent a uint32 array message?

800 views
Skip to first unread message

Aptschihu Buktu

unread,
Sep 6, 2016, 5:41:12 PM9/6/16
to ROS SIG NG ROS
Hello,

I try to create a message with an uint32 array, that fits to std_msgs::UInt32MultiArray in ROS. But it seems that this type does not exit any more. I found u_int32__struct.hpp and maybe it is the definition I'm looking for. But I'm to silly to handle that (Because I'm a ASM/C guy).

Please give me some suggestion how to solve this.

Many thanks in advance,
Alex

Dirk Thomas

unread,
Sep 6, 2016, 5:45:32 PM9/6/16
to ROS SIG NG ROS
Hi Alex,

In general it is not recommended to use messages from `std_msgs` directly since they have no semantic (except for debugging or prototyping where they can be handy). Therefore we haven't included all message from `std_msgs` in ROS 1.

You can simply create a .msg file for your needs which will also give the data structure a specific semantic.

Cheers,
- Dirk



--
You received this message because you are subscribed to the Google Groups "ROS SIG NG ROS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ros-sig-ng-ros+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Aptschihu Buktu

unread,
Sep 6, 2016, 5:49:54 PM9/6/16
to ROS SIG NG ROS
Hi again,

is it a acceptable way to go with strings? Because strings working well an both sides...

regards,
Alex

Dirk Thomas

unread,
Sep 6, 2016, 5:53:24 PM9/6/16
to ROS SIG NG ROS
Hi Alex,

I am not sure what you mean with "go with string". Do you actually want to transfer textual data or use a string container to transfer binary data? If it is the later I can only highly suggest to not do that. At some point we will address the question of string encoding and then you can not expect binary data to be transferred transparently.

Cheers,
- Dirk


Alex

Aptschihu Buktu

unread,
Sep 6, 2016, 6:14:52 PM9/6/16
to ROS SIG NG ROS
Hi Dirk,

at the an, I will transport three uint32 (an array would be the best case) from ROS2 over a ROS-Bridge to ROS - the easiest way for the moment. In one month I have enough time for going the hard way and maybe to contribute ROS2.

I found, that the most examples based on transporting strings. So... why not memcpy data into a C-string, publish it and de-pack it again with memcpy?

Regards,
Alex

Dirk Thomas

unread,
Sep 6, 2016, 6:19:15 PM9/6/16
to ROS SIG NG ROS
Hi Alex,

because you data is *not* a string - the data is three uint32 values. Therefore you should use a field of type `uint32[3]`.

The reason why many examples use a string is because "Hello world" is a string. The example also include cases of numbers, e.g. the add_two_ints service. So using the appropriate type for your case shouldn't be a a matter of what some examples do.

Cheers,
- Dirk

--

William Woodall

unread,
Sep 6, 2016, 6:23:52 PM9/6/16
to ROS SIG NG ROS
Also, depending on what your data is, it might make sense to unpack the semantic meaning of the data into your message definition. For example, if it is always three uint32 values, then maybe it could be represented as "x", "y", "z" or "roll", "pitch", "yaw" (or whatever the three ints represent) rather than a fixed sized array.
--
William Woodall
ROS Development Team

Aptschihu Buktu

unread,
Sep 7, 2016, 3:05:41 PM9/7/16
to ROS SIG NG ROS
For my current example it is truly a better style to give every value an own name. But it's a bit unhandy, because I have to copy values, which comes with an array, value by value in a "beautiful" message and I have to copy them back later to do calculations with them. Matrix and vector algebra is more handy....

William Woodall

unread,
Sep 7, 2016, 3:17:52 PM9/7/16
to ROS SIG NG ROS
Then you should use a custom type and serialize-deserialize to and from that type, as we do with OpenCV image types and PCL point cloud types. The purpose of the message as an interface is to be semantically meaningful and intuitive, not necessarily to be to be the most convenient storage layout on which to do calculations. When you can accomplish both in a message description that's fine, but when you can't I think custom serializers are the way to go.

That being said, if you're the only one using your message, then you can do whatever you like.

On Wed, Sep 7, 2016 at 12:05 PM, Aptschihu Buktu <aptschi...@gmail.com> wrote:
For my current example it is truly a better style to give every value an own name. But it's a bit unhandy, because I have to copy values, which comes with an array, value by value in a "beautiful" message and I have to copy them back later to do calculations with them. Matrix and vector algebra is more handy....

--
You received this message because you are subscribed to the Google Groups "ROS SIG NG ROS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ros-sig-ng-ros+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Aptschihu Buktu

unread,
Sep 7, 2016, 4:00:38 PM9/7/16
to ROS SIG NG ROS
Dear William and Dirk,

thanks for these lot information. I think, I found more than only one solution and I'm happy with it.

Cheers,
Alex

Reply all
Reply to author
Forward
0 new messages