RobotWebTools / rclnodejs

Node.js version of ROS 2.0 client
https://docs.ros.org/en/humble/Concepts/Basic/About-Client-Libraries.html?highlight=rclnodejs#community-maintained
Apache License 2.0
311 stars 70 forks source link

Add willCheckConsistency option to enable/disable message consistency checking #947

Closed minggangw closed 4 months ago

minggangw commented 6 months ago

Currently, when a publisher/client sends a topic/request, it will check the consistency of the message to be sent. For example, the following code will lead to an exception:

  const pub_ = this.node.createPublisher('sensor_msgs/msg/JointState', 'topic_js');
  const stringMsgObject = rclnodejs.createMessageObject('sensor_msgs/msg/JointState');
  stringMsgObject.header.frame_id = '0';

Because the stamp in header is not initialized.

This patch adds an additional option for node when initializing, which is willCheckConsistency (default is false), so the code above can run as expected with the stamp initialized with default value. Meanwhile, user can set it to true to check the consistency intentionally.

To achieve, this patch implements:

  1. Add willCheckConsistency to the node option.
  2. Update message.dot accordingly to check the consistency based on the node option above.
  3. Update the unit tests:
    • test/test-security-related.js

Fix: #937