liamondrop / ros-pca9685-board

ROS Node to control servos on a PCA9685 board
MIT License
25 stars 9 forks source link

ROS PCA9685 Board

A ROS node to control servos on a PCA9685 board

The primary purpose of this project is to develop a ROS node capable of controlling servos for steering and throttle, such as would be used by a Donkey Car, using the standard Adafruit PCA9685 board, controlled over the I2C bus from a Raspberry Pi.

Table of Contents

Dependencies

ROS, obviously. If you don't want to suffer the pain of trying to build ROS on the standard RPi Linux distros, you might look into this tasty image, with ROS pre-installed, from Ubiquity Robotics.

This project also depends on the wiringPi library for I2C communication. It may already be present on your Pi. You can learn more about it here.

Install

On your Pi, once you've verified wiringPi has been installed, create a Catkin workspace directory and clone this repository into src.

mkdir -p ~/catkin_ws/src
cd src
git clone git@github.com:liamondrop/ros-pca9685-board.git

You should now be able to build with Catkin.

cd ~/catkin_ws
catkin_make
source devel/setup.bash

Usage

In the launch file, there is an example servo configuration. This will set the parameters for the steering and throttle servos, as well as the pwm frequency. You may need to change these for your particular setup.

One note on throttle servos for RC cars: when switching from forward to reverse, it is actually necessary to send a reverse pulse twice before the servo will respond.

You may also set the PWM Frequency in the configuration. It defaults to 50hz in this project, which is the standard recommended frequency for servos. If you change this value, you will likely need to update your servo configurations as well.

Once you haveLaunch the pca9685_board node.

roslaunch pca9685_board pca9685.launch

The pca9685_board node listens to two topics:

If you have completed the TeleopTurtle Joystick tutorial, you could control the servos with a joystick by simply relaying the /turtle1/cmd_vel topic to the /servos_drive topic.

rosrun topic_tools relay /turtle1/cmd_vel /servos_drive

Note that the angular and linear scales in that project are set to 2, and you will probably want to change them to 1 so the joystick output only ranges from -1.0 to 1.0, as required by this module.

Maintainers

@liamondrop

Contributing

PRs accepted.

Small note: If editing the README, please conform to the standard-readme specification.

License

MIT © 2018 Liam Bowers