ros-industrial / ros2_canopen

CANopen driver framework for ROS2
https://ros-industrial.github.io/ros2_canopen/manual/rolling/
125 stars 52 forks source link

Feature/multiple sdo write types #264

Closed kurtist123 closed 2 months ago

kurtist123 commented 3 months ago

The ros2_canopen::BasicSlave only supported SDO writes to UNSIGNED32 type data objects. A data length exception was thrown when trying to write to other data types.

The exception was coming from the line: https://github.com/rosindustrial/ros2_canopen/blob/master/canopen_fake_slaves/include/canopen_fake_slaves/basic_slave.hpp#L49

It was calling Get(), regardless of the data type of the object. This was resulting in a data length mismatch for data types other than UNSIGNED32.

I implemented a GetValue method to explicitly call Get<>() using the data object type. One thing to note is that the GetValue method only supports getting types that can fit inside a 32-bit container. Trying to SDO write larger values will result in the same data length exception as before. I also added more SDO write tests to exercise getting multiple data types.

This PR is related to the issue: https://github.com/ros-industrial/ros2_canopen/issues/263