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

Use BigInt for Int64 and UInt64 #836

Open csmith-rtr opened 2 years ago

csmith-rtr commented 2 years ago

rclnodejs currently seems to detect if a 64bit integer is greater than Number.MAX_SAFE_INTEGER and returns either a number or a string depending on if it is or not. This was originally tracked by #103 which was before bigint was introduced. It would be nice to use the new native type rather than changing the type that can be returned.

See below. Ran ros2 topic pub with std_msgs/Int64 data type and printed out the message and the type of the data field. Changed the published value between Number.MAX_SAFE_INTEGER and one slightly larger.

Got Message: {"data":"9007199254740993"}
Type: string
Got Message: {"data":9007199254740991}
Type: number

The typescript message definitions also do not indicate that the data field can be a string. image