How to use the @xviz/io.XVIZData 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 / test / modules / io / writers / xviz-format-writer.spec.js View on Github external
tape('XVIZFormatWriter#full matrix', t => {
  const dataSources = [
    TestXVIZSnapshot,
    TestXVIZSnapshotString,
    TestXVIZSnapshotBuffer,
    TestXVIZSnapshotGLB
  ];
  for (const source of dataSources) {
    const xvizObj = new XVIZData(source);

    for (const format of [
      XVIZ_FORMAT.BINARY_GLB,
      XVIZ_FORMAT.JSON_BUFFER,
      XVIZ_FORMAT.JSON_STRING
    ]) {
      const sink = new MemorySourceSink();

      t.comment(`-- TestCase ${xvizObj.format} to ${format}`);

      // Convert the data to the requested format
      // data is state_update and this will default to a message sequence of 0
      const formatWriter = new XVIZFormatWriter(sink, {format});
      formatWriter.writeMessage(0, xvizObj);

      // We don't really care about the key as each writer will have
github uber / xviz / modules / server / src / sources / rosbag-data-source.js View on Github external
async xvizFrame(iterator) {
    const {
      valid,
      data: {start, end}
    } = iterator.next();
    if (!valid) {
      return null;
    }

    // Read Frame by keyTopic/stream
    const frame = await this.bag.readFrameByTime(start, end);
    return new XVIZData(frame);
  }
}
github uber / xviz / modules / server / src / middlewares / xviz-server-middleware-stack.js View on Github external
middlewareDispatch(name, msg) {
    const arrayLength = this.middlewares.length;
    for (let i = 0; i < arrayLength; i++) {
      const middleware = this.middlewares[i];

      const handler = middleware[name];

      if (handler) {
        let args = [];

        // Support JS objects
        if (msg && !(msg instanceof XVIZData)) {
          msg = new XVIZData(msg);
        }
        args = [msg];

        const nextMiddleware = handler.apply(middleware, args);
        if (nextMiddleware === false) {
          break;
        }
      }
    }
  }
}
github uber / xviz / test / modules / io / common / xviz-data.spec.js View on Github external
{
      description: 'Binary Metadata',
      data: MinimalBinaryMetadata,
      format: XVIZ_FORMAT.BINARY_GLB,
      type: 'metadata'
    },
    {
      description: 'Binary StateUpdate',
      data: MinimalBinaryStateUpdate,
      format: XVIZ_FORMAT.BINARY_GLB,
      type: 'state_update'
    }
  ];

  for (const test of testCases) {
    const xvizObj = new XVIZData(test.data);
    t.equal(
      xvizObj.format,
      test.format,
      `${test.description} matches expected format ${test.format}`
    );

    t.equal(xvizObj.type, test.type, `${test.description} matches expected type ${test.type}`);

    const msg = xvizObj.message();
    t.equal(msg.type, test.type, `${test.description} matches expected message type ${test.type}`);
  }

  t.end();
});
github uber / xviz / modules / server / src / scenarios / scenario-provider.js View on Github external
_readMessage(message) {
    const data = this.reader.readMessage(message);
    if (data) {
      return new XVIZData(data);
    }

    return undefined;
  }
github uber / xviz / modules / server / src / scenarios / scenario-provider.js View on Github external
_readMetadata() {
    const data = this.reader.readMetadata();
    if (data) {
      return new XVIZData(data);
    }

    return undefined;
  }
}
github uber / xviz / modules / ros / src / providers / rosbag-provider.js View on Github external
xvizMetadata() {
    if (!this.metadata) {
      this._getMetadata();
    }

    if (this.metadata) {
      return new XVIZData(this.metadata);
    }

    return null;
  }