How to use the rosbag.TimeUtil.toDate 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.

github uber / xviz / modules / ros / src / messages / geometry-posestamped-converter.js View on Github external
}

    const {timestamp, message} = msg[msg.length - 1];

    // Every frame *MUST* have a pose. The pose can be considered
    // the core reference point for other data and usually drives the timing
    // of the system.
    // Position, decimal degrees
    const rotation = quaternionToEuler(message.pose.orientation);
    const {position} = message.pose;
    xvizBuilder
      .pose(this.xvizStream)
      .mapOrigin(this.origin.longitude, this.origin.latitude, this.origin.altitude)
      .position(position.x, position.y, 0)
      .orientation(rotation.roll, rotation.pitch, rotation.yaw)
      .timestamp(TimeUtil.toDate(timestamp).getTime() / 1e3);
  }
github uber / xviz / modules / ros / src / cmds / bagdump.js View on Github external
export async function BagDump(args) {
  const {bag: bagPath, topic: mainTopic} = args;

  const bag = await open(bagPath);

  if (args.dumpTime) {
    console.log(`start_time: ${TimeUtil.toDate(bag.startTime).getTime() / 1e3}`);
    console.log(`end_time: ${TimeUtil.toDate(bag.endTime).getTime() / 1e3}`);
  }

  if (args.dumpAllTopics) {
    for (const conn in bag.connections) {
      const {topic, type} = bag.connections[conn];
      console.log(topic, type);
    }
  }

  if (args.dumpMessages) {
    await bag.readMessages({}, ({topic, message}) => {
      if (!mainTopic || topic === mainTopic) {
        console.log(JSON.stringify(message, null, 2));
      }
    });
github uber / xviz / modules / ros / src / cmds / bagdump.js View on Github external
export async function BagDump(args) {
  const {bag: bagPath, topic: mainTopic} = args;

  const bag = await open(bagPath);

  if (args.dumpTime) {
    console.log(`start_time: ${TimeUtil.toDate(bag.startTime).getTime() / 1e3}`);
    console.log(`end_time: ${TimeUtil.toDate(bag.endTime).getTime() / 1e3}`);
  }

  if (args.dumpAllTopics) {
    for (const conn in bag.connections) {
      const {topic, type} = bag.connections[conn];
      console.log(topic, type);
    }
  }

  if (args.dumpMessages) {
    await bag.readMessages({}, ({topic, message}) => {
      if (!mainTopic || topic === mainTopic) {
        console.log(JSON.stringify(message, null, 2));
      }
    });
  }
github uber / xviz / modules / ros / src / core / ros-bag.js View on Github external
async _initBag(bag) {
    const TF = '/tf';
    const TF_STATIC = '/tf_static';

    this.bagContext.start_time = TimeUtil.toDate(bag.startTime).getTime() / 1e3;
    this.bagContext.end_time = TimeUtil.toDate(bag.endTime).getTime() / 1e3;

    const frameIdToPoseMap = {};
    await bag.readMessages({topics: [TF, TF_STATIC]}, ({topic, message}) => {
      message.transforms.forEach(t => {
        frameIdToPoseMap[t.child_frame_id] = {
          ...t.transform.translation,
          ...quaternionToEuler(t.transform.rotation)
        };
      });
    });

    this.bagContext.frameIdToPoseMap = frameIdToPoseMap;
  }
github uber / xviz / modules / ros / src / core / ros-bag.js View on Github external
async _initBag(bag) {
    const TF = '/tf';
    const TF_STATIC = '/tf_static';

    this.bagContext.start_time = TimeUtil.toDate(bag.startTime).getTime() / 1e3;
    this.bagContext.end_time = TimeUtil.toDate(bag.endTime).getTime() / 1e3;

    const frameIdToPoseMap = {};
    await bag.readMessages({topics: [TF, TF_STATIC]}, ({topic, message}) => {
      message.transforms.forEach(t => {
        frameIdToPoseMap[t.child_frame_id] = {
          ...t.transform.translation,
          ...quaternionToEuler(t.transform.rotation)
        };
      });
    });

    this.bagContext.frameIdToPoseMap = frameIdToPoseMap;
  }
github uber / xviz / modules / ros / src / bag / bag.js View on Github external
async collectMetadata() {
    const TF = '/tf';

    let origin = {latitude: 0, longitude: 0, altitude: 0};
    const frameIdToPoseMap = {};

    await this.open();

    const start_time = TimeUtil.toDate(this.bag.startTime).getTime() / 1e3;
    const end_time = TimeUtil.toDate(this.bag.endTime).getTime() / 1e3;

    await this.bag.readMessages({topics: [CONFIGURATION, TF]}, ({topic, message}) => {
      if (topic === CONFIGURATION) {
        const config = message.keyvalues.reduce((memo, kv) => {
          memo[kv.key] = kv.value;
          return memo;
        }, {});

        if (config.map_lat) {
          origin = {
            latitude: parseFloat(config.map_lat),
            longitude: parseFloat(config.map_lng),
            altitude: parseFloat(config.map_alt)
          };
        }
      } else if (topic === TF) {
github uber / xviz / modules / ros / src / bag / bag.js View on Github external
async collectMetadata() {
    const TF = '/tf';

    let origin = {latitude: 0, longitude: 0, altitude: 0};
    const frameIdToPoseMap = {};

    await this.open();

    const start_time = TimeUtil.toDate(this.bag.startTime).getTime() / 1e3;
    const end_time = TimeUtil.toDate(this.bag.endTime).getTime() / 1e3;

    await this.bag.readMessages({topics: [CONFIGURATION, TF]}, ({topic, message}) => {
      if (topic === CONFIGURATION) {
        const config = message.keyvalues.reduce((memo, kv) => {
          memo[kv.key] = kv.value;
          return memo;
        }, {});

        if (config.map_lat) {
          origin = {
            latitude: parseFloat(config.map_lat),
            longitude: parseFloat(config.map_lng),
            altitude: parseFloat(config.map_alt)
          };
        }

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

Package Health Score

79 / 100
Full package analysis

Similar packages