Skip to content

Conversation

minggangw
Copy link
Member

@minggangw minggangw commented Jun 19, 2025

This PR introduces native and JavaScript-level serialization and deserialization for ROS 2 messages using RMW, complete with tests and helper functions.

  • Adds C++ RMW bindings (serialize/deserialize) and registers them in the Node addon
  • Implements Serialization JS class and exports serializeMessage/deserializeMessage in index.js
  • Provides basic unit tests and fixes a naming typo (destroyRawROS)

Fix: #1172

@minggangw minggangw requested a review from Copilot June 19, 2025 07:38
Copilot

This comment was marked as outdated.

@coveralls
Copy link

coveralls commented Jun 19, 2025

Coverage Status

coverage: 84.672% (-0.06%) from 84.731%
when pulling 7346d36 on minggangw:fix-1172
into 688791e on RobotWebTools:develop.

@minggangw minggangw requested a review from Copilot June 19, 2025 10:23
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces native and JavaScript-level serialization and deserialization for ROS 2 messages using RMW, complete with tests and helper functions.

  • Adds C++ RMW bindings (serialize/deserialize) and registers them in the Node addon
  • Implements Serialization JS class and exports serializeMessage/deserializeMessage in index.js
  • Provides basic unit tests and fixes a naming typo (destroyRawROS)

Reviewed Changes

Copilot reviewed 9 out of 10 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
test/test-serialization.js New tests for serialization/deserialization
src/rcl_serialization_bindings.h/.cpp Native RMW serialization/deserialization bindings
src/addon.cpp Module initialization now includes serialization
rosidl_gen/templates/message.dot Corrected typo from destoryRawROS to destroyRawROS
lib/serialization.js JS helper Serialization class
lib/node.js Updated call to destroyRawROS
index.js Exported serializeMessage and deserializeMessage
binding.gyp Added serialization binding source file
Comments suppressed due to low confidence (2)

test/test-serialization.js:19

  • [nitpick] The test suite description refers to publishing rather than serialization. Rename it to something like 'rclnodejs serialization test suite' for clarity.
describe('rclnodejs publisher test suite', function () {

lib/serialization.js:27

  • There are no tests covering these error paths. Consider adding unit tests for invalid inputs (wrong message type or non-Buffer) to ensure errors are thrown as expected.
    if (!(message instanceof typeClass)) {

if (RCUTILS_RET_OK != ret) {
Napi::Error::New(env,
"failed to fini rcl_serialized_msg_t in destructor.")
.ThrowAsJavaScriptException();
Copy link

Copilot AI Jun 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Throwing a JavaScript exception from a C++ destructor can lead to std::terminate. It's safer to log the error or handle cleanup without throwing in the destructor.

Suggested change
.ThrowAsJavaScriptException();
.Value(); // Log the error without throwing an exception.

Copilot uses AI. Check for mistakes.

@minggangw minggangw merged commit af12346 into RobotWebTools:develop Jun 20, 2025
19 checks passed
minggangw added a commit that referenced this pull request Jun 20, 2025
This PR introduces native and JavaScript-level serialization and deserialization for ROS 2 messages using RMW, complete with tests and helper functions.

- Adds C++ RMW bindings (`serialize`/`deserialize`) and registers them in the Node addon  
- Implements `Serialization` JS class and exports `serializeMessage`/`deserializeMessage` in `index.js`  
- Provides basic unit tests and fixes a naming typo (`destroyRawROS`)

Fix: #1172
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add RMW serialize and deserialize functions

2 participants