Guidelines to create a ros2control hardware interface that uses CAN to comunicate with an Odrive

Hi everybody, as the title says I want to write a c++ ros2control hardware interface for the Odrive using CAN bus, I want to use Test Driven Development to do this based on the virtual can interface that can be set up in linux. So far I tried to follow this post Writing a Hardware Component in the last part a template script is recommended but advised that it might not work with versions latter Foxy, so I tried it anyway by doing git checkout to the humble branch of the downloaded repo and created a package, I’ve been comparing the output of this script and it seems compatible with the documentation of a new hardware interface. I noticed the script creates a test folder and a test being the same recommended in the first link, I was able to pass the said test by doing:

colcon build --packages-select  odrive_can_hw_interface && colcon test --packages-select  odrive_can_hw_interface --event-handlers=console_direct+

Now I have a basic implementation and a way to run the test! But now i don’t really know how to continue, for instance I noticed that the parameters of the urdf should be passed to the hardware interface as the argument info of the on_init function but i’m not sure how to access them, I don’t know where or what are the joints called and how could I access them in order to ASSERT that the CAN bus configuration parameters are passed, So I’m asking for basic guidance to achieve this, I have worked with ROS but only in python and I know some of C/C++ but only in microcontrollers so I’m at a loss.

My specific questions are:

1.-How can I access from my test the hardware interface objects created and their variables in order to create the test.

2.- Is this approach ok? or should I maybe use common gtest to test a library of the communication protocoL and then use the ros package just as a wrapper for the functions defined in this library?

3.- Can you recommend documentation and examples?

Thanks a lot in advance, I’m really exited to do this project and your expert insights will be very much appreciated.

All the code until now is in this repo

1 Like

Hey there

Are you using the ROS2 CAN package that ODrive developed, then passing that communication information over to your hardware interface?

Are you using an ODrive s1?