Skip to content

Commit

Permalink
Add support for lz4 compressed rosbags
Browse files Browse the repository at this point in the history
  • Loading branch information
kvalev committed Jun 10, 2021
1 parent 7469a4d commit 102c204
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
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

0 comments on commit 102c204

Please sign in to comment.