-
Notifications
You must be signed in to change notification settings - Fork 78
Add RMW serialize and deserialize functions #1173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this 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 exportsserializeMessage
/deserializeMessage
inindex.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(); |
Copilot
AI
Jun 19, 2025
There was a problem hiding this comment.
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.
.ThrowAsJavaScriptException(); | |
.Value(); // Log the error without throwing an exception. |
Copilot uses AI. Check for mistakes.
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
This PR introduces native and JavaScript-level serialization and deserialization for ROS 2 messages using RMW, complete with tests and helper functions.
serialize
/deserialize
) and registers them in the Node addonSerialization
JS class and exportsserializeMessage
/deserializeMessage
inindex.js
destroyRawROS
)Fix: #1172