JSPM

@lichtblick/ulog

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 335
  • Score
    100M100P100Q96372F
  • License MIT

PX4 ULog file reader

Package Exports

  • @lichtblick/ulog
  • @lichtblick/ulog/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@lichtblick/ulog) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@lichtblick/ulog

PX4 ULog file reader

A web and node.js TypeScript library for reading PX4 ULog files, from the PX4 Autopilot system for drones and other autonomous vehicles.

Usage

import { MessageType, ULog } from "@lichtblick/ulog";
import { FileReader } from "@lichtblick/ulog/node";

async function main() {
  const ulog = new ULog(new FileReader("../path/to/file.ulg"));
  await ulog.open(); // required before any other operations
  console.log(ulog.messageCount()); // ex: 64599
  console.log(ulog.timeRange()); // ex: [ 0n, 181493506n ]

  // build a map of subscription ids to message counts
  // NOTE: readMessages() iterates over DATA section messages in timestamp order
  const msgIdCounts = new Map<number, number>();
  for await (const msg of ulog.readMessages()) {
    if (msg.type === MessageType.Data) {
      // NOTE: `msg.value` holds the deserialized message
      msgIdCounts.set(msg.msgId, (msgIdCounts.get(msg.msgId) ?? 0) + 1);
    }
  }

  // convert the subscription ids to message names
  const msgCounts = Array.from(msgIdCounts.entries()).map(([id, count]) => [
    ulog.subscriptions.get(id)?.name ?? `unknown msg_id ${id}`,
    count,
  ]);
  console.log(msgCounts);
  // ex: [ [ 'vehicle_attitude', 6461 ], [ 'actuator_outputs', 1311 ], ... ]
}

void main();

License

@lichtblick/ulog is licensed under the MIT License.

Releasing

  1. Run yarn version --[major|minor|patch] to bump version
  2. Run git push && git push --tags to push new tag
  3. GitHub Actions will take care of the rest