How to use the rosbag.TimeUtil.fromDate 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 / xviz / modules / ros / src / bag / bag.js View on Github external
async readFrameByTime(start, end) {
    const bag = await open(this.bagPath);
    const frame = {};

    const options = {};

    if (start) {
      options.startTime = TimeUtil.fromDate(new Date(start * 1e3));
    }

    if (end) {
      options.endTime = TimeUtil.fromDate(new Date(end * 1e3));
    }

    if (this.topics) {
      options.topics = this.topics;
    }

    await bag.readMessages(options, async 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) {
        frame.keyTopic = result;
      }
github uber / xviz / modules / ros / src / bag / bag.js View on Github external
async readFrameByTime(start, end) {
    const bag = await open(this.bagPath);
    const frame = {};

    const options = {};

    if (start) {
      options.startTime = TimeUtil.fromDate(new Date(start * 1e3));
    }

    if (end) {
      options.endTime = TimeUtil.fromDate(new Date(end * 1e3));
    }

    if (this.topics) {
      options.topics = this.topics;
    }

    await bag.readMessages(options, async 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);
      }
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) {
      options.topics = this.topics;
    }

    await bag.readMessages(options, async 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) {
        await flushFrame();
        frame.keyTopic = result;
      }
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) {
      options.topics = this.topics;
    }

    await bag.readMessages(options, async 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) {
        await flushFrame();
        frame.keyTopic = result;
      }
      frame[result.topic] = frame[result.topic] || [];
github uber / xviz / modules / ros / src / core / ros-bag.js View on Github external
async readMessages(start, end) {
    const bag = await this._openBag();
    const frame = {};

    const options = {
      topics: this.rosConfig.topics
    };

    if (start) {
      options.startTime = TimeUtil.fromDate(new Date(start * 1e3));
    }

    if (end) {
      options.endTime = TimeUtil.fromDate(new Date(end * 1e3));
    }

    await bag.readMessages(options, async result => {
      // rosbag.js reuses the data buffer for subsequent messages, so we need to make a copy
      if (result.message.data) {
        // Used for binary data in images, point clouds, etc
        // TODO(this needs to work in the browser)
        result.message.data = Buffer.from(result.message.data);
      }

      frame[result.topic] = frame[result.topic] || [];
      frame[result.topic].push(result);
github uber / xviz / modules / ros / src / core / ros-bag.js View on Github external
async readMessages(start, end) {
    const bag = await this._openBag();
    const frame = {};

    const options = {
      topics: this.rosConfig.topics
    };

    if (start) {
      options.startTime = TimeUtil.fromDate(new Date(start * 1e3));
    }

    if (end) {
      options.endTime = TimeUtil.fromDate(new Date(end * 1e3));
    }

    await bag.readMessages(options, async result => {
      // rosbag.js reuses the data buffer for subsequent messages, so we need to make a copy
      if (result.message.data) {
        // Used for binary data in images, point clouds, etc
        // TODO(this needs to work in the browser)
        result.message.data = Buffer.from(result.message.data);
      }

      frame[result.topic] = frame[result.topic] || [];
      frame[result.topic].push(result);
    });

    return frame;
  }

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 11 months ago

Package Health Score

70 / 100
Full package analysis

Similar packages