Skip to content
/ ulog Public

PX4 ULog file reader

Notifications You must be signed in to change notification settings

foxglove/ulog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

0a7d568 · Nov 19, 2024

History

42 Commits
Nov 19, 2024
Oct 23, 2021
Jan 18, 2022
Nov 19, 2024
Jan 18, 2022
Oct 27, 2021
Oct 23, 2021
Nov 19, 2024
Oct 23, 2021
Nov 19, 2024
Oct 23, 2021
Oct 31, 2024
Oct 23, 2021
Oct 27, 2021
Oct 27, 2021
Nov 19, 2024
Oct 27, 2021
Oct 27, 2021
Oct 27, 2021
Nov 19, 2024

Repository files navigation

@foxglove/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 "@foxglove/ulog";
import { FileReader } from "@foxglove/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

@foxglove/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

Stay in touch

Join our Discord to ask questions, share feedback, and stay up to date on what our team is working on.

About

PX4 ULog file reader

Resources

Stars

Watchers

Forks