Ask Your Question

Revision history [back]

It looks like jsonpickle will do the job:

sudo apt-get install python-jsonpickle

import json-pickle
from std_msgs.msg import Header
h = Header()
h.frame_id = "map"
a = jsonpickle.encode(h)

And the the following could be easily written to disk, or sent directly to a web server:

>>>> a
'{"py/object": "std_msgs.msg._Header.Header", "stamp": {"py/object": "genpy.rostime.Time", "secs": 0, "nsecs": 0}, "seq": 0, "frame_id": "map"}'

A python script could convert bags to json pickle format as a ros node or offline, and if conversion back for reading in C++ is necessary a python intermediary could read the json and write out a bag (I assume even if there is a generic C++ json pickle reader it would create strange python objects and not C++ ros messages, and additional custom conversion machinery would be required to close the loop, could be worth trying).

It looks like jsonpickle will do the job:

sudo apt-get install python-jsonpickle

import json-pickle
from std_msgs.msg import Header
h = Header()
h.frame_id = "map"
a = jsonpickle.encode(h)

And the the following could be easily written to disk, or sent directly to a web server:

>>>> a
'{"py/object": "std_msgs.msg._Header.Header", "stamp": {"py/object": "genpy.rostime.Time", "secs": 0, "nsecs": 0}, "seq": 0, "frame_id": "map"}'

A python script could convert bags to json pickle format as a ros node or offline, and if conversion back for reading in C++ is necessary a python intermediary could read the json and write out a bag (I assume even if there is a generic C++ json pickle reader it would create strange python objects and not C++ ros messages, and additional custom conversion machinery would be required to close the loop, could be worth trying).

It looks like http://answers.ros.org/question/44224/i-am-unable-to-serialize-and-deserialize-ros-msgs-please-help/ came to a similar conclusion.

It looks like jsonpickle will do the job:

 sudo apt-get install python-jsonpickle

import json-pickle
from std_msgs.msg import Header
h = Header()
h.frame_id = "map"
a = jsonpickle.encode(h)

And the the following could be easily written to disk, or sent directly to a web server:

>>>> a
'{"py/object": "std_msgs.msg._Header.Header", "stamp": {"py/object": "genpy.rostime.Time", "secs": 0, "nsecs": 0}, "seq": 0, "frame_id": "map"}'

A python script could convert bags to json pickle format as a ros node or offline, and if conversion back for reading in C++ is necessary a python intermediary could read the json and write out a bag (I assume even if there is a generic C++ json pickle reader it would create strange python objects and not C++ ros messages, and additional custom conversion machinery would be required to close the loop, could be worth trying).

It looks like http://answers.ros.org/question/44224/i-am-unable-to-serialize-and-deserialize-ros-msgs-please-help/ came to a similar conclusion.

It looks like jsonpickle will do the job:

sudo apt-get install python-jsonpickle

Then in python:

import json-pickle
from std_msgs.msg import Header
h = Header()
h.frame_id = "map"
a = jsonpickle.encode(h)

And the the following could be easily written to disk, or sent directly to a web server:

>>>> a
'{"py/object": "std_msgs.msg._Header.Header", "stamp": {"py/object": "genpy.rostime.Time", "secs": 0, "nsecs": 0}, "seq": 0, "frame_id": "map"}'

A python script could convert bags to json pickle format as a ros node or offline, and if conversion back for reading in C++ is necessary a python intermediary could read the json and write out a bag (I assume even if there is a generic C++ json pickle reader it would create strange python objects and not C++ ros messages, and additional custom conversion machinery would be required to close the loop, could be worth trying).

It looks like http://answers.ros.org/question/44224/i-am-unable-to-serialize-and-deserialize-ros-msgs-please-help/ came to a similar conclusion.