Robotics StackExchange | Archived questions

deserialize uint8* to ros message to publish

Hi guys,I want to deserilize to ros message ,here is code

code:

```

int main()
{

std_msgs::String msg;

namespace ser = ros::serialization;

uint8_t buffer_ptr[] = "asdf";

ser::IStream stream(buffer_ptr, 4);

ser::deserialize(stream, msg);

return 0;
}

And I got the error : terminate called after throwing an instance of 'ros::serialization::StreamOverrunException' what(): Buffer Overrun ``` so how to deserialize them ? Any suggestion ?thanks ~

Asked by CarryOwen on 2023-02-03 05:58:09 UTC

Comments

In ROS, typical users do not write code at the low level you show. ROS uses a publish/subscribe model, e.g. where you would create a std_msgs::String object, Publish it to a topic, and receive a copy of that msg object in a Subscribe callback. Serialization is automatic and hidden.

Please give us more context about the problem you are trying to solve.

Asked by Mike Scheutzow on 2023-02-11 12:49:03 UTC

Answers