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

How to serialize C++ objects containing ROS messages

asked 2014-06-18 19:44:54 -0600

sned gravatar image

Hello I have the following class I'd like to serialize:

class Foo
{  int x;
   std::vector<double> bars;
   moveit_msgs::RobotState _startState;
}

in the absence of any ROS/MoveIt components, I am able to serialize out/in using the Boost serialization library. I resume that if all I had was the moveit message type then I could use the move_it serialization described on MessagesSerializationAndAdaptingTypes (assuming moveit_msgs are serializable by ROS?). But when I have a class containing both then I am not sure what to do. How do I go about serializing it now? I am using ROS Groovy

thanks

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2014-10-01 21:30:15 -0600

tfoote gravatar image

In ROS you cannot serialize and send arbitrary datatypes, you need to use ROS message datatypes. Some libraries provide custom mappings from native datatypes to ROS message-serialized formats. But you need a target ROS message format.

More on messages here: http://wiki.ros.org/Messages

edit flag offensive delete link more
1

answered 2014-10-02 01:23:32 -0600

ahendrix gravatar image

I assume you're using boost::serialization

ROS message don't implement boost::serialization::Serializable, so you'll need to implement a serialize() function as described here: http://www.boost.org/doc/libs/1_56_0/...

ROS already has serializers for messages, so you may be able to use those to implement the boost serialization. I'm not aware of much documentation about how to call the ROS serializers in C++. the best place to start is probably the source: https://github.com/ros/roscpp_core/bl...

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2014-06-18 19:44:54 -0600

Seen: 2,577 times

Last updated: Oct 02 '14