Ros2_control hardware_interface for Adafruit 16-Channel PWM / Servo Bonnet for Raspberry Pi (PCA9685)

I have created a hardware_interface which interfaces with the PCA9685, a 16-channel PWM driver, which communicates via I2C. It is used in these Adafruit products:

With this driver you can connect your shield/hats/bonnets to the i2c port of your Raspberry Pi (or similar single board computer) and use them in conjunction with ros2_control framework.

This repo is using a modified version of this library, GitHub - barulicm/PiPCA9685: C++ and Python Library for PCA9685 chips and the Raspberry Pi, to communicate via I2C with a PCA9685. Thank you, barulicm (Matthew Barulic) · GitHub.

Here is the link to our repository which contains the hardware_interface as one package and an example how to use joint_group_velocity_controller to send commands to it in another package: GitHub - rosblox/pca9685_ros2_control

And here is a link to a repo which packages the above repo in a Docker image: GitHub - rosblox/ros-pca9685-ros2-control. Clone the repo, execute ./build.sh to build the image, execute ./run.sh to start a container from the image, type run (an alias) to start the launch file with from the example controller.

Please note, that this is in a proof-of-concept state. I plan to potentially use this shield to teleoperate a skid-steered rover which is implemented with a pca9685.

Thank you for your inspirational videos, ArticulatedRobotics, https://articulatedrobotics.xyz/.

8 Likes

I was reading your post thinking “ooh nice, I’ve been meaning to try connecting ROS to a PCA9685” (I was originally going to have servo control of the camera on my mobile robot) and was pleasantly surprised once I got to the last line!

It’s such a warm fuzzy feeling not just when people are inspired to go and make something, but especially when they contribute back to the community, so thanks! :smiley:

2 Likes

This is awesome!
I updated Dheera’s ROS1 PCA9685 node to ROS2 over here, but I never got my head around the controllers interface. If I ever get back to maintaining mine, I’ll probably turn it into convenience wrappers for yours

I typically use the PCA9685 for servo control or hobby ESCs (skid steer), and I found that having a channel mixer was extremely useful for just hacking around, I imagine that mixer can be turned into an actual controller layer now

Thanks for the package!

1 Like

Awesome project!

Are your drivers already featured here?
Why not? :wink:

In the top-right you can find an “edit on github” button.

1 Like

@maxpol - This is such a huge help! I have watched pretty much every video from @joshnewans (Thanks Josh - amazing stuff!), but my bot uses a PCA9685 expansion board, and was desperately stuck on the hardware interface for ROS2. Looking forward to digging into this and hopefully getting my bot to actually move!

Eric

2 Likes

Thanks for your kind words @joshnewans, @BrettRD and @ecastelli.

@bmagyar I have created a PR to add it to the ros2_control documentation. It’d be great if this would be used by more people and we could gradually expand the hardware_interface’s features for the PCA9685. Thanks for the suggestion.

I have got everything built and launching the service works fine but running the service call always result in “the passed service type is invalid”. I have checked the service list and “/pca9685/set_pwn” is there. Any hints? I would love to just get a servo to move.

Ahh forgot to source the setup.bash, rookie mistake…

1 Like