How to use the @xviz/io.XVIZEnvelope.StateUpdate function in @xviz/io

To help you get started, we’ve selected a few @xviz/io 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 / io / src / writers / xviz-json-writer.js View on Github external
writeMessage(messageIndex, xvizMessage) {
    this._checkValid();
    this._saveTimestamp(xvizMessage, messageIndex);

    if (this.options.envelope) {
      xvizMessage = XVIZEnvelope.StateUpdate(xvizMessage);
    }

    // Limit precision to save space
    const numberRounder = (k, value) => {
      if (typeof value === 'number') {
        return Number(value.toFixed(this.options.precision));
      }

      return value;
    };

    const jsonXVIZMessage = xvizConvertJson(xvizMessage);
    const msg = JSON.stringify(jsonXVIZMessage, numberRounder);
    this.writeToSink(`${messageName(messageIndex)}.json`, msg);
  }
github uber / xviz / modules / ros / src / providers / rosbag-provider.js View on Github external
async xvizMessage(iterator) {
    const {
      valid,
      data: {start, end}
    } = iterator.next();

    if (!valid) {
      return null;
    }

    const dataset = await this.bag.readMessages(start, end);
    const msg = await this.ros2xviz.buildMessage(dataset);

    if (msg) {
      return new XVIZData(XVIZEnvelope.StateUpdate(msg));
    }

    return null;
  }
}
github uber / xviz / modules / io / src / writers / xviz-binary-writer.js View on Github external
writeMessage(messageIndex, xvizMessage) {
    this._checkValid();
    this._saveTimestamp(xvizMessage, messageIndex);

    if (this.options.envelope) {
      xvizMessage = XVIZEnvelope.StateUpdate(xvizMessage);
    }

    const glbFileBuffer = encodeBinaryXVIZ(xvizMessage, this.encodingOptions);
    this.sink.writeSync(`${messageName(messageIndex)}.glb`, toBuffer(glbFileBuffer), {flag: 'w'});
  }
github uber / xviz / modules / builder / src / writers / xviz-writer / xviz-writer.js View on Github external
writeFrame(xvizDirectory, frameIndex, xvizFrame) {
    if (this.wroteFrameIndex !== null) {
      throw new Error(
        `writeFrame() was called after writeFrameIndex().  The index was written with last frame of ${frameName(
          this.wroteFrameIndex - 1
        )}`
      );
    }

    this._saveTimestamp(xvizFrame, frameIndex);

    if (this.options.envelope) {
      xvizFrame = XVIZEnvelope.StateUpdate(xvizFrame);
    }

    if (this.options.binary) {
      const options = {
        flattenArrays: true
      };

      if (this.options.DracoWriter) {
        options.DracoWriter = this.options.DracoWriter;
      }
      if (this.options.DracoLoader) {
        options.DracoLoader = this.options.DracoLoader;
      }

      writeBinaryXVIZtoFile(this.sink, xvizDirectory, frameName(frameIndex), xvizFrame, options);
    }