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

custom field type for ROS msg

asked 2018-07-25 11:42:30 -0500

mohthepro gravatar image

updated 2018-07-27 13:11:20 -0500

We're trying to read a radar udp packet and one of the data types is of a RadarDetection[] type which is not supported by ROS (because its a custom type) the size of each index is 224 bits, one solution Im thinking of is :

-creating a message that contains int64[4] RadarDetection_custom and then use that message as a field type to represent the RadarDetection type but with 256 bits instead 224

I am not confident that this solution will work and I was wondering if there is a better solution than this

edit retag flag offensive close merge delete


Could you reformat your question with more punctuation and more information about the data you want to send? You should also check your numbers. int64[3] would only hold 192 bits, not 256, and where did "215" come from?

Geoff gravatar image Geoff  ( 2018-07-25 18:39:21 -0500 )edit

Sorry I meant int64[4], and I reformatted the question to make it easier to read, the 215 bits is just the size of the field type that I am receiving from the radar's UDP packets, I dont know why the radar manufacturers made it like so

mohthepro gravatar image mohthepro  ( 2018-07-26 09:35:55 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2018-07-25 18:58:13 -0500

Geoff gravatar image

updated 2018-07-25 19:00:24 -0500

An array of int8 28 values long will give you 224 bits. This is the usual approach to storing a binary blob such as your RadarDetection type. It will be presented as a boost::array of int8_t, which you can get the raw pointer to and read into your data type. See the msg data types page for more information.

edit flag offensive delete link more


is there any difference between int8[28] and what I suggested with int64[4] other than less wasted space?

mohthepro gravatar image mohthepro  ( 2018-07-26 10:05:29 -0500 )edit

In some ways no. In fact they will probably take exactly the same space in memory due to the way compilers work. However semantically int64 implies a particular encoding that the data probably doesn't have whereas an array of bytes is the standard encoding of raw binary data.

PeteBlackerThe3rd gravatar image PeteBlackerThe3rd  ( 2018-07-26 17:18:23 -0500 )edit

So it's a convention really but your code will be more meaningful to other developers of you use a buffer of bytes.

PeteBlackerThe3rd gravatar image PeteBlackerThe3rd  ( 2018-07-26 17:20:23 -0500 )edit

Question Tools



Asked: 2018-07-25 11:42:30 -0500

Seen: 317 times

Last updated: Jul 27 '18