3.0.2 • Published 10 months ago

@foxglove/rosmsg2-serialization v3.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

@foxglove/rosmsg2-serialization

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

npm version

MessageReader

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

import { MessageReader } from "@foxglove/rosmsg2-serialization";

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

// specify a different `timeType` for time objects compatible with ROS 1 and @foxglove/rostime
const reader = new MessageReader(messageDefinition, { timeType: "sec,nsec" });

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

// access message fields
message.header.stamp;

MessageWriter

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

import { MessageWriter } from "@foxglove/rosmsg2-serialization";

// message definition comes from `parse()` in @foxglove/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: {
    stamp: { sec: 0, nanosec: 0 },
    frame_id: ""
  },
  x: 1,
  y: 0,
  z: 0
});

Test

yarn test

License

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

Stay in touch

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

3.0.2

10 months ago

3.0.1

11 months ago

3.0.0

11 months ago

2.0.4

1 year ago

2.0.3

2 years ago

2.0.2

2 years ago

2.0.1

2 years ago

2.0.0

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

0.2.0

4 years ago

0.1.0

4 years ago