Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for lz4 compressed rosbags #656

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions modules/ros/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"@xviz/builder": "1.0.8",
"@xviz/io": "1.0.8",
"lodash": "^4.17.11",
"lz4js": "^0.2.0",
"rosbag": "^2.0.0",
"sharp": "^0.23.0",
"yargs": "^13.2.2"
Expand Down
14 changes: 12 additions & 2 deletions modules/ros/src/core/ros-bag.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
// limitations under the License.
/* global Buffer */
/* eslint-disable camelcase */
import lz4 from "lz4js";

import {open, TimeUtil} from 'rosbag';
import {quaternionToEuler} from '../common/quaternion';

Expand Down Expand Up @@ -66,7 +68,12 @@ export class ROSBag {
this.bagContext.end_time = TimeUtil.toDate(bag.endTime).getTime() / 1e3;

const frameIdToPoseMap = {};
await bag.readMessages({topics: [TF, TF_STATIC]}, ({topic, message}) => {
await bag.readMessages({
topics: [TF, TF_STATIC],
decompress: {
lz4: (buffer) => new Buffer(lz4.decompress(buffer)),
}
}, ({topic, message}) => {
message.transforms.forEach(t => {
frameIdToPoseMap[t.child_frame_id] = {
...t.transform.translation,
Expand Down Expand Up @@ -122,7 +129,10 @@ export class ROSBag {
const frame = {};

const options = {
topics: this.rosConfig.topics
topics: this.rosConfig.topics,
decompress: {
lz4: (buffer) => new Buffer(lz4.decompress(buffer)),
},
};

if (start) {
Expand Down