dennn66 / ros_pca9685

7 stars 6 forks source link

PCA9685 ROS package

ros_pca9685 is a package for talking to the PCA9685 I2C PWM driver by NXP

PCA9685 Highlights from datasheet

Usage on Raspberry PI

Package tested with [Adafruit 16-Channel 12-bit PWM/Servo Driver] (http://adafruit.com/products/815)

How to configure Raspberry PI described [here] (https://learn.adafruit.com/adafruit-16-channel-servo-driver-with-raspberry-pi/overview)

Circuit

Install

    mkdir -p ~/pca_ws/src
    cd  ~/pca_ws
    catkin_init_workspace
    cd ~/pca_ws/src
    git clone https://github.com/dennn66/ros_pca9685
    cd ~/pca_ws/src/ros_pca9685/ros_pca9685/src/lib/
    git clone https://github.com/TeraHz/I2C
    git clone https://github.com/TeraHz/PCA9685
    cd ~/pca_ws
    catkin_make_isolated

Run

    rosrun ros_pca9685 controller_sub

Pub/Sub

Publish

Subscribe

Test

   rostopic pub  /pca9685/servostate_to_controller pca9685_msgs/ServoState '{port_num: 1, servo_rot: 0.5, servo_type: 2}' --once
   rostopic pub  /pca9685/pwmstate_to_controller pca9685_msgs/PwmState '{port_num: 1, on_value: 0, off_value: 400}' --once

Turn off servos

Stop all servos:

rostopic pub /pca9685/servostate_to_controller pca9685_msgs/ServoState '{port_num: 0, servo_rot: 0.0, servo_type: 0}' --once

Stop servo:

rostopic pub /pca9685/servostate_to_controller pca9685_msgs/ServoState '{port_num: 1, servo_rot: 0.0, servo_type: 0}' --once

or

  rostopic pub  /pca9685/pwmstate_to_controller pca9685_msgs/PwmState '{port_num: 1, on_value: 0, off_value: 0}' --once