Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@lichtblick/rosmsg-serialization

Package Overview
Dependencies
Maintainers
0
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lichtblick/rosmsg-serialization

ROS1 (Robot Operating System) message serialization, for reading and writing bags and network messages

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

@lichtblick/rosmsg-serialization

ROS1 (Robot Operating System) message serialization, for reading and writing bags and network messages

npm version

MessageReader

Message reader deserializes ROS messages into plain objects. The messages are fully deserialized.

import { MessageReader } from "@lichtblick/rosmsg-serialization";

// message definition comes from `parse()` in @lichtblick/rosmsg
const reader = new MessageReader(messageDefinition);

// deserialize a buffer into an object
const message = reader.readMessage([0x00, 0x00, ...]);

// access message fields
message.header.stamp;

LazyMessage

Lazy messages provide on-demand access and deserialization to fields of a serialized ROS message. Creating a lazy message from a buffer performs no de-serialization during creation. Only accessed fields are deserialized; the deserialization occurs at access time.

import { LazyMessageReader } from "@lichtblick/rosmsg-serialization";

// message definition comes from `parse()` in @lichtblick/rosmsg
const reader = new LazyMessageReader(messageDefinition);

// build a new lazy message instance for our serialized message from the Uint8Array
// Note: since deserialization is lazy - avoid-reusing the array you provide for other messages
const message = reader.readMessage([0x00, 0x00, ...]);

// access message fields
message.header.stamp;

MessageWriter

Convert an object, array, or primitive value into binary data using ROS message serialization.

import { MessageWriter } from "@lichtblick/rosmsg-serialization";

// message definition comes from `parse()` in @lichtblick/rosmsg
const writer = new MessageWriter(pointStampedMessageDefinition);

// serialize the passed in object to a Uint8Array as a geometry_msgs/PointStamped message
const uint8Array = writer.writeMessage({
  header: {
    seq: 0,
    stamp: { sec: 0, nsec: 0 },
    frame_id: ""
  },
  x: 1,
  y: 0,
  z: 0
});

Test

yarn test

License

@lichtblick/rosmsg-serialization 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

Benchmarks

The bench folder contains benchmarks. Run with:

yarn bench
yarn bench:benny

To run benchmarks in web:

yarn bench:web

Keywords

FAQs

Package last updated on 20 Sep 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc