ros-industrial / ros2_canopen

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

SDO Writes to Any Data Type #263

Closed kurtist123 closed 5 months ago

kurtist123 commented 6 months ago

I am trying to use the sdo_write service to update objects in my object dictionary. Writing to UNSIGNED32 objects works from both the master and proxy node services. Writing to an object of any other data type fails with the error:

basic_slave_node-1] terminate called after throwing an instance of 'lely::canopen::SdoError' [basic_slave_node-1] what(): Get:06:2101:01: Data type does not match, length of service parameter does not match (06070010): Data type does not match, length of service parameter does not match

Using both the master service (type: COWriteID) and proxy service (type: COWrite) fails when trying to write any data type other than UNSIGNED32. Is it possible to write other data types?

All of the SDO write tests in canopen_tests write to an UNSIGNED32 type object.

The logic also appears to require specific objects at ID 0x4000 and 0x4001 that are both UNSIGNED32. Are these the cause of not being able to write other data types?

Object definition in object dictionary:

[2101sub1] ParameterName=Token ObjectType=0x7 ;StorageLocation=RAM DataType=0x0005 AccessType=rwr DefaultValue=69 PDOMapping=1

Bus config:

options: dcf_path: "@BUS_CONFIG_PATH@"

master: node_id: 5 driver: "ros2_canopen::MasterDriver" package: "canopen_master_driver" baud_rate: 250 heartbeat_consumer: false heartbeat_producer: 2000 start_nodes: true sync_period: 5000000

defaults: dcf: "acu_can0.eds" driver: "ros2_canopen::ProxyDriver" package: "canopen_proxy_driver" polling: false heartbeat_consumer: false heartbeat_producer: 2000 boot: true period: 10 diagnostics: enable: false

nodes: can0_comm: node_id: 6

Service calls producing errors: ros2 service call /master/sdo_write canopen_interfaces/srv/COWriteID '{nodeid: 6, index: 8449, subindex: 1, data: 44, canopen_datatype: 5}'

and

ros2 service call /can0_comm/sdo_write canopen_interfaces/srv/COWrite '{index: 8449, subindex: 1, data: 44}'

Setup:

Additional context I'm using the basic slave launch file (ros2_canopen/canopen_fake_slave/lauch/basic_slave.launch.py) to launch the slave/proxy node

kurtist123 commented 6 months ago

PR to correct this issue: https://github.com/ros-industrial/ros2_canopen/pull/264

hellantos commented 5 months ago

Thanks for fixing this!