How to use the rosbag.open function in rosbag

To help you get started, we’ve selected a few rosbag examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github uber / streetscape.gl / examples / converters / voyage / src / lib / bag.js View on Github external
async readFrames(onFrame) {
    const bag = await open(this.bagPath);

    let frame = {};
    function flushFrame() {
      if (frame.keyTopic) {
        onFrame(frame);
        frame = {};
      }
    }

    await bag.readMessages({topics: this.topics}, result => {
      // rosbag.js reuses the data buffer for subsequent messages, so we need to make a copy
      if (result.message.data) {
        result.message.data = Buffer.from(result.message.data);
      }
      if (result.topic === this.keyTopic) {
        flushFrame();
github uber / xviz / modules / ros / src / bag / bag.js View on Github external
async readFrameByKeyTopic(start, end) {
    const bag = await open(this.bagPath);
    let frame = {};

    async function flushFrame() {
      if (frame.keyTopic) {
        // This needs to be address, was used to flush on keyTopic message to sync
        // await onFrame(frame);
        frame = {};
      }
    }

    const options = {
      startTime: TimeUtil.fromDate(new Date(start * 1e3)),
      endTime: TimeUtil.fromDate(new Date(end * 1e3))
    };

    if (this.topics) {
github cruise-automation / webviz / packages / webviz-core / src / dataProviders / BagDataProvider.js View on Github external
extensionPoint.progressCallback({
              fullyLoadedFractionRanges: ranges.map(({ start, end }) => ({
                start: Math.max(0, start / approximateSize),
                end: Math.min(1, end / approximateSize),
              })),
            });
          }
        },
      });
      await remoteReader.open(); // Important that we call this first, because it might throw an error if the file can't be read.
      approximateSize = remoteReader.size() * 0.99; // Chop off the last percentage or so for the indexes.

      this._bag = new Bag(new BagReader(remoteReader));
      await this._bag.open();
    } else {
      this._bag = await open(bagPath.file);
      extensionPoint.progressCallback({ fullyLoadedFractionRanges: [{ start: 0, end: 1 }] });
    }

    const { startTime, endTime } = this._bag;
    const connections = ((Object.values(this._bag.connections): any): Connection[]);
    if (!startTime || !endTime || !connections.length) {
      // This will abort video generation:
      reportError("Invalid bag", "Bag is empty or corrupt.", "user");
      return new Promise(() => {}); // Just never finish initializing.
    }

    this._connectionsByTopic = keyBy(connections, "topic");
    return {
      start: startTime,
      end: endTime,
      topics: bagConnectionsToTopics(connections),
github cruise-automation / webviz / packages / webviz-core / src / players / bag / BagDataProvider.worker.js View on Github external
initialize = async (initialize: InitializeMessage): Promise => {
    await decompress.isLoaded;
    this._bag = await open(initialize.bagPath);
  };
github uber / streetscape.gl / examples / converters / voyage / src / lib / bag.js View on Github external
async calculateOrigin() {
    const bag = await open(this.bagPath);
    let origin = {latitude: 0, longitude: 0, altitude: 0};
    await bag.readMessages({topics: ['/gps/fix']}, ({message}) => {
      origin = _.minBy(ORIGINS, ({longitude, latitude}) => {
        return turf.distance(
          turf.point([longitude, latitude]),
          turf.point([message.longitude, message.latitude])
        )
      });
    });

    return origin;
  }
github uber / xviz / modules / ros / src / core / ros-bag.js View on Github external
async _openBag() {
    return await open(this.bagPath);
  }

rosbag

`rosbag` is a node.js & browser compatible module for reading [rosbag](http://wiki.ros.org/rosbag) binary data files.

Apache-2.0
Latest version published 1 year ago

Package Health Score

63 / 100
Full package analysis

Similar packages