Ask Your Question

Ekaradon's profile - activity

2020-11-24 00:44:28 -0600 received badge  Famous Question (source)
2020-11-11 21:30:17 -0600 received badge  Popular Question (source)
2020-06-27 17:10:12 -0600 received badge  Notable Question (source)
2020-06-20 11:25:08 -0600 edited question What's the best practice to pre-process parameter file

What's the best practice to pre-process parameter file I have a parameter yaml file, some of these parameters are easy t

2020-06-20 11:24:10 -0600 asked a question What's the best practice to pre-process parameter file

What's the best practice to pre-process parameter file I have a parameter yaml file, some of these parameters are easy t

2020-06-15 03:25:51 -0600 commented answer How to correctly deserialize a message with variable length array?

The correct byte sequence for 2 would be 0x02 0x00 0x00 0x00 at the first 4 bytes of buffer, and uint8 array_size should

2020-06-15 03:25:04 -0600 marked best answer How to correctly deserialize a message with variable length array?

I'm receiving some data from serial port and want to deserialize the byte stream I received to a ROS message.

The serial port data contains variable number of elements (elements with same type). So I use variable length array in my ROS message.

For example I have received these bytes in memory:

uint8_t buffer[] = { 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x03, 0x03, 0x11, 0x11, 0x11, 0x11, 0x12, 0x12, 0x12, 0x12, 0x13, 0x13, 0x13, 0x13 };

Here,

  • 0x02 means 2 elements in the variable length array,
  • (0x01010101, 0x02020202, 0x03030303) is the first element, this is actually a 3-dimensional point with float type,
  • (0x11111111, 0x12121212, 0x13131313) is the second element.

And I'm going to use this message:

uint8 array_size    # will be 0x02
geometry_msgs/Point32[] points    # will be a array with length 2, the first Point32 is (0x01010101, 0x02020202, 0x03030303), and the second one is (0x11111111, 0x12121212, 0x13131313)

It seems the tutorial does not work with variable length array. I checked the code, and there is a serializer for std::vector.

But the deserialization process goes wrong in this function:

// (line 348 of serialization.h)
template<typename Stream>
inline static void read(Stream& stream, VecType& v)
{
    uint32_t len;
    stream.next(len);
    v.resize(len);    // <----
    IteratorType it = v.begin();
    IteratorType end = v.end();
    for (; it != end; ++it)
    {
        stream.next(*it);
    }   
}

It seems the deserializer will change the length of the vector first. But the value of variable len gets very huge and v.resize(len) fails.

2020-06-15 03:25:04 -0600 received badge  Scholar (source)
2020-06-15 03:22:28 -0600 edited answer How to correctly deserialize a message with variable length array?

As gvdhoorn says, this will most likely lead stream.next(len) to read 4 bytes from buffer and consider them all part

2020-06-15 03:19:02 -0600 edited answer How to correctly deserialize a message with variable length array?

As gvdhoorn says, this will most likely lead stream.next(len) to read 4 bytes from buffer and consider them all part

2020-06-15 03:18:07 -0600 received badge  Supporter (source)
2020-06-15 03:18:06 -0600 edited answer How to correctly deserialize a message with variable length array?

As gvdhoorn says, this will most likely lead stream.next(len) to read 4 bytes from buffer and consider them all part

2020-06-15 03:14:37 -0600 answered a question How to correctly deserialize a message with variable length array?

As gvdhoorn says, this will most likely lead stream.next(len) to read 4 bytes from buffer and consider them all part

2020-06-15 03:14:37 -0600 received badge  Rapid Responder (source)
2020-06-15 03:03:03 -0600 edited question How to correctly deserialize a message with variable length array?

How to correctly deserialize a message with variable length array? I'm receiving some data from serial port and want to

2020-06-15 03:03:02 -0600 received badge  Popular Question (source)
2020-06-15 02:53:34 -0600 edited question How to correctly deserialize a message with variable length array?

How to correctly deserialize a message with variable length array? For example I have a message: uint8 array_size geome

2020-06-15 02:51:33 -0600 received badge  Enthusiast
2020-06-14 02:31:41 -0600 edited question How to correctly deserialize a message with variable length array?

How to correctly deserialize a message with variable length array? For example I have a message: uint8 array_size geome

2020-06-14 02:18:37 -0600 edited question How to correctly deserialize a message with variable length array?

How to correctly deserialize a message with variable length array? For example I have a message: uint8 array_size geome

2020-06-13 10:56:30 -0600 edited question How to correctly deserialize a message with variable length array?

How to correctly deserialize a message with variable length array? For example I have a message: uint8 array_size geome

2020-06-13 10:55:09 -0600 edited question How to correctly deserialize a message with variable length array?

How to correctly deserialize a message with variable length array? For example I have a message: uint8 array_size geome

2020-06-13 10:55:09 -0600 received badge  Editor (source)
2020-06-13 10:53:16 -0600 asked a question How to correctly deserialize a message with variable length array?

How to correctly deserialize a message with variable length array? For example I have a message: uint8 array_size geome

2020-06-11 02:27:18 -0600 edited question Logging before a fatal exit

Logging before a fatal exit For example I want to have a ROS node which opens serial port and reads some data. Here's th

2020-06-10 08:10:41 -0600 asked a question Logging before a fatal exit

Logging before a fatal exit For example I want to have a ROS node which opens serial port and reads some data. Here's th

2020-06-10 08:08:29 -0600 asked a question Logging when have fatal error

Logging when have fatal error For example I want to have a ROS node which opens serial port and reads some data. Here's

2020-06-10 08:08:29 -0600 asked a question Logging when have fatal error

Logging when have fatal error For example I want to have a ROS node which opens serial port and reads some data. Here's

2015-04-23 05:13:39 -0600 commented answer Which IDE(s) do ROS developers use?

I have some problem configuring the CLion IDE. It reports "catkin was neither found in workspace nor in the CMAKE_PREFIX_PATH" when building. I chaged the value of CMAKE_PREFIX_PATH in the cache, and that makes CLion working. However, afterwards, command "catkin_make" in console doesn't work.