UNPKG

@foxglove/rosbag2

Version:

ROS 2 (Robot Operating System) bag reader and writer abstract implementation

32 lines 1.14 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.RawMessageIterator = void 0; const rostime_1 = require("@foxglove/rostime"); class RawMessageIterator { constructor(dbIterator, topicsMap) { this.dbIterator = dbIterator; this.topicsMap = topicsMap; } [Symbol.asyncIterator]() { return this; } async next() { const res = this.dbIterator.next(); if (res.done === true) { return { value: undefined, done: true }; } else { const row = res.value; // Resolve topicId to a parsed topic row const topic = this.topicsMap.get(row.topic_id); if (topic == undefined) { throw new Error(`Cannot find topic_id ${row.topic_id} in ${this.topicsMap.size} topics`); } const timestamp = (0, rostime_1.fromNanoSec)(row.timestamp); const value = { topic, timestamp, data: row.data }; return { value, done: false }; } } } exports.RawMessageIterator = RawMessageIterator; //# sourceMappingURL=RawMessageIterator.js.map