diff --git a/modules/ros/package.json b/modules/ros/package.json index 749d5172b..a9cb60c6a 100644 --- a/modules/ros/package.json +++ b/modules/ros/package.json @@ -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" diff --git a/modules/ros/src/core/ros-bag.js b/modules/ros/src/core/ros-bag.js index 44e81eac4..0b1a8af4b 100644 --- a/modules/ros/src/core/ros-bag.js +++ b/modules/ros/src/core/ros-bag.js @@ -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'; @@ -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, @@ -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) {