Hi all,
I have finally cleaned up my PWM driver that uses the SysFS interface to drive RC motor controllers and servos.
Features
- Supports setting PWM duty or PPM compliant duty cycles.
- Set PWM devices using a normalised float value (0 to 1).
- PPM zero-points can be set to support reverse on RC motor controllers, allowing the duty to be set with a normalised float from -1.0 to 1.0.
Why
When researching how I was going to interface with a PCA9685
board for a DIY RoboCar project, I found that a driver for that hardware exists in the Linux kernel.
This meant I was able to simply use the SysFS interface to configure that particular board, and any other PWM devices that kernel driver
support exists for (of which there is a a lot). This also includes Single Board Computers such as Raspberry Pi and Rock Pi, where
you can use the PWM port on the GPIO header.
A survey of the available ROS packages didn’t show many ROS 2 PWM packages, and none of those used the SysFS interface. So here is my package to solve this.
Usage
- Enable the kernel driver for the PWM hardware by configuring the Device Tree.
- Set up the
udev
rule so the PWM device’s SysFS interface can be written to from non-root users. - Install/compile this package into your ROS2 install or workspace.
- Add the
pwmdriver
node to your launch scripts, or run thepwmdriver
node, making sure to specify your configuration file. - Publish the normalised float to the
/pwm/<output name>
topic, setting the duty cycle. - Zoom around!