https://github.com/asadm/rosbags

Minimal ROS1 bag writer for Node & the browser

https://github.com/asadm/rosbags

Science Score: 26.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (10.6%) to scientific vocabulary
Last synced: 10 months ago · JSON representation

Repository

Minimal ROS1 bag writer for Node & the browser

Basic Info
  • Host: GitHub
  • Owner: asadm
  • License: mit
  • Language: JavaScript
  • Default Branch: main
  • Homepage:
  • Size: 23.4 KB
Statistics
  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • Open Issues: 0
  • Releases: 0
Created about 1 year ago · Last pushed about 1 year ago
Metadata Files
Readme License

README.md

rosbags – zero-dependency ROS1 bag writer for Node & the browser

This directory contains a minimal implementation of a ROS1 (format v2.0) bag writer in pure JavaScript with zero runtime dependencies – not even buffer (we prebundle a polyfill for browser), ieee754 or friends. The only modules it relies on are provided by Node.js itself (fs, path, …), which means it also works unchanged in the browser after bundling.

The code is a direct, line-for-line port of the rosbags reference implementation written in Python. All record layouts, headers and constants are identical, so a bag produced here can be opened with any existing ROS tooling.


Quick start

```bash

Run the small unit-test suite (writes & reads a few bags)

node js/tests/run.mjs ```

Install via npm

bash npm install rosbags

Usage in Node (ESM)

```js import { Writer } from 'rosbags';

const bag = new Writer('example.bag'); bag.open(); const conn = bag.addConnection('/foo', 'std_msgs/msg/Int8'); bag.write(conn, 1, Buffer.from([0x01])); bag.close(); ```

Usage in Node (CommonJS)

js const { Writer } = require('rosbags'); // ...identical to above

Usage in the Browser via CDN

Add a single script tag that exposes rosbagsWriter globally:

html <script src="https://unpkg.com/rosbags/dist/rosbags.browser.js"></script> <script> // The bundle already contains a Buffer poly-fill, no extra scripts needed. const { Writer } = rosbagsWriter; const w = new Writer(); w.open(); const c = w.addConnection('/foo', 'std_msgs/msg/Int8'); w.write(c, 123n, new Uint8Array([0x42])); w.close(); const blob = new Blob([w.getUint8Array()], { type: 'application/octet-stream' }); // download or upload blob here </script>


Write a bag on disk (from source checkout)

```js // After installing from npm: import { Writer } from 'rosbags'; // Node ESM variant

const bag = new Writer('example.bag'); // pass a path ⇒ write to disk bag.open();

// Register a topic/connection first const conn = bag.addConnection('/foo', 'std_msgs/msg/Int8');

// Then stream messages (timestamp in nanoseconds) bag.write(conn, 1, Buffer.from([0x01])); bag.write(conn, 2, Buffer.from([0x02]));

bag.close(); ```

Create a bag entirely in memory (browser-friendly)

```js import { Writer } from 'rosbags';

const writer = new Writer(); // no path ⇒ keep data in memory writer.open(); const conn = writer.addConnection('/bar', 'std_msgs/msg/Int8'); writer.write(conn, 42, new Uint8Array([0xff])); writer.close();

const raw = writer.getUint8Array(); // Uint8Array containing the .bag file // …upload, download or feed into a WebWorker here… ```

Read the resulting bag with the official npm package

```js const rosbag = require('rosbag');

(async () => { const bag = await rosbag.open('example.bag'); await bag.readMessages({ noParse: true }, (msg) => { console.log(msg.topic, msg.data); }); })(); ```


Testing

Two kinds of tests live in js/tests/:

  • test_writer1.js – verifies the writer against a set of hand-rolled assertions (header sizes, chunk flags, …).
  • test_writer_rosbag_read.js – round-trip check that writes with this writer and reads back using the upstream rosbag npm dependency.

The tests load dist/rosbags.js (CommonJS stub) so they exercise the same API surface without requiring a build step. When you run npm run build, the real bundles dist/rosbags.node.mjs (ESM) and dist/rosbags.browser.js overwrite / complement the stub.

Run the suite via:

```bash node js/tests/run.mjs


Publishing to npm

The package.json includes convenience scripts:

  • npm run build – Generates two self-contained bundles using esbuild:
    • dist/rosbags.node.mjs (ESM for Node)
    • dist/rosbags.browser.js (IIFE for browsers)
  • npm publish – Publish the package. A prepublishOnly hook ensures the bundle is rebuilt and the tests are green before the actual upload.

Everything required at runtime is embedded in the generated bundle, so the published module stays dependency-free. ```


License

This JavaScript port is released under the MIT license (see LICENSE).

Owner

  • Name: Asad Memon
  • Login: asadm
  • Kind: user
  • Location: San Francisco Bay Area

GitHub Events

Total
  • Push event: 1
  • Create event: 1
Last Year
  • Push event: 1
  • Create event: 1

Committers

Last synced: 12 months ago

All Time
  • Total Commits: 6
  • Total Committers: 1
  • Avg Commits per committer: 6.0
  • Development Distribution Score (DDS): 0.0
Past Year
  • Commits: 6
  • Committers: 1
  • Avg Commits per committer: 6.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Asad Memon a****k@g****m 6

Issues and Pull Requests

Last synced: 12 months ago

All Time
  • Total issues: 0
  • Total pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Total issue authors: 0
  • Total pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels

Dependencies

package-lock.json npm
  • @esbuild/aix-ppc64 0.19.12 development
  • @esbuild/android-arm 0.19.12 development
  • @esbuild/android-arm64 0.19.12 development
  • @esbuild/android-x64 0.19.12 development
  • @esbuild/darwin-arm64 0.19.12 development
  • @esbuild/darwin-x64 0.19.12 development
  • @esbuild/freebsd-arm64 0.19.12 development
  • @esbuild/freebsd-x64 0.19.12 development
  • @esbuild/linux-arm 0.19.12 development
  • @esbuild/linux-arm64 0.19.12 development
  • @esbuild/linux-ia32 0.19.12 development
  • @esbuild/linux-loong64 0.19.12 development
  • @esbuild/linux-mips64el 0.19.12 development
  • @esbuild/linux-ppc64 0.19.12 development
  • @esbuild/linux-riscv64 0.19.12 development
  • @esbuild/linux-s390x 0.19.12 development
  • @esbuild/linux-x64 0.19.12 development
  • @esbuild/netbsd-x64 0.19.12 development
  • @esbuild/openbsd-x64 0.19.12 development
  • @esbuild/sunos-x64 0.19.12 development
  • @esbuild/win32-arm64 0.19.12 development
  • @esbuild/win32-ia32 0.19.12 development
  • @esbuild/win32-x64 0.19.12 development
  • base64-js 1.5.1 development
  • buffer 6.0.3 development
  • esbuild 0.19.12 development
  • heap 0.2.7 development
  • ieee754 1.2.1 development
  • int53 1.0.0 development
  • rosbag 4.0.1 development
package.json npm
  • buffer ^6.0.3 development
  • esbuild ^0.19.12 development
  • rosbag ^4.0.1 development