0
$\begingroup$

Rosanswers logo

I'd like to use bag files as a generic output data format, but I'd also like to display text and numbers out of the bags in a javascript browser environment. It isn't necessary to handle arrays of binary data.

Is it possible to read a bag directly from javascript (using a library)?

Or what would be a good way to save data into a bag (which is easy with the rosbag api), then programmatically convert the bag to json, yaml, or less desirably a csv? It looks like from http://answers.ros.org/question/55037/is-there-a-way-to-save-all-rosbag-data-into-a-csv-or-text-file/ there are command lines to convert to csv, is there an api call to do the same thing?


Originally posted by lucasw on ROS Answers with karma: 8729 on 2016-02-08

Post score: 1

$\endgroup$

2 Answers 2

0
$\begingroup$

Rosanswers logo

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.


Originally posted by lucasw with karma: 8729 on 2016-02-09

This answer was ACCEPTED on the original site

Post score: 2

$\endgroup$
0
$\begingroup$

Rosanswers logo

Cruise Automation recently open sourced a Javascript library for parsing rosbag files. This should allow you to more easily get the information you're looking for directly into the browser:

https://github.com/cruise-automation/rosbag.js


Originally posted by samjabrahams with karma: 11 on 2018-04-06

This answer was NOT ACCEPTED on the original site

Post score: 1

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.