I am unable to serialize and deserialize ros msgs.. Please Help
Hello Community, I am using the ros::serialization library to serialize a ros msg type into a buffer. However when I pass the same buffer to a deserialize function it gives me the following error.
terminate called after throwing an instance of 'ros::serialization::StreamOverrunException' what(): Buffer Overrun
Could someone please help me in figuring this out? I literally copied both ros::serialization and ros::deserialization from the ROS wiki under roscpp. Any help is appreciated. Thanks Ammar
EDIT: Here is the code -
void Trader::serialize_task(const multiagent_coordination_msgs::TaskToken& my_task){
namespace ser = ros::serialization;
multiagent_coordination_msgs::Agent my_agent;
uint32_t serial_size = ros::serialization::serializationLength(my_task);
boost::shared_array<uint8_t> buffer(new uint8_t[serial_size]);
ser::OStream stream(buffer.get(), serial_size);
ser::serialize(stream, my_task);
deserialize_task(buffer);
}
void Trader::deserialize_task(const boost::shared_array<uint8_t>& my_buffer){
namespace ser = ros::serialization;
multiagent_coordination_msgs::TaskToken my_task;
uint32_t serial_size = ros::serialization::serializationLength(my_task);
boost::shared_array<uint8_t> buffer(new uint8_t[serial_size]);
ser::IStream stream(buffer.get(), serial_size);
ser::deserialize(stream, my_task);
}
It would help to see your code.