ROS Resources: Documentation | Support | Discussion Forum | Service Status | Q&A answers.ros.org

New PCA9685 driver for ROS

I wrote a driver for the PCA9685 I2C PWM driver chip. This chip is intended to be used with LED applications but is also used in a number of servo and motor controller boards, including a few Adafruit and Waveshare boards among others.

A couple of notable features I added that I haven’t seen done in other similar packages:

  • The ability to update only certain channels in a ROS command, and not update all of them. This allows multiple ROS nodes to publish to the same command topic but take charge of different subsets of the 16 channels.
  • A timeout. If a channel isn’t updated within that time, it gets set to 0. This is useful to avoid servos burning out if your control logic crashes, and also as a heartbeat timeout in the case of motor controllers.
2 Likes

Hi dheera,
Thanks for sharing your package. I am new to ROS so I’m still confusing after reading your readme file. You’re using Int32MultiArray as the message type, but in your description, the subscriber take 16 values for each channel. How are those two related. If I want to write send command to this node, how do I define the values of label, size, stride, data_offset, and data respectively to specify the channel?
Thanks much,
Zhouqiao

Hi Zhouqiao,
The code currently only reads the data field and expects 16 values. It doesn’t actually read label/stride/data_offset, so it’ll work without setting those, but it’s probably most “correct” to just define it as a one-dimensional array of 16 values. i.e.

dim[0].label = “command”
dim[0].size = 16
dim[0].stride = 16

Thanks, works perfect.

Hi Dheera,
I have not been able to get this to work.
I have the Adafruit servo board working outside of ROS but I need to make it work within ROS as this project does.
I am fairly new to ROS but I do have several nodes working.
I work in python.
Is there something particular to get a cpp script working?

The approach I took was to download your project in a catkin workplace and compile.

If you could guide me on how to install your files in an existing project, that would be awsome.
Thanks.

  • Did you get a compile or run error, and what is the error?
  • What hardware do you have the servo board connected to?
  • Are you able to see the servo board using i2cdetect?

Marc Boudreau via ROS ros@discoursemail.com 於 2019年12月19日 週四 上午8:42寫道:

Hi,

Thanks for replying, I appreciate it

Like I said, I am new to cpp nodes. I did not realize that you do not place the file extension “.cpp” as you need to place the “.py” when using python.

I now have the node running!

However, I have yet to figure out the publish nomenclature.

I have tried variations of:

rostopic pub Int32MultiArray/command {data:[32767,32767,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1]}

but always get errors:

Usage: rostopic pub /topic type [args…]

rostopic: error: no such option: -]

Le jeu. 19 déc. 2019 à 17:08, Dheera Venkatraman via ROS ros@discoursemail.com a écrit :

it works!
This makes me happy!

Thanks for sharing your work!

Le jeu. 19 déc. 2019 à 17:08, Dheera Venkatraman via ROS ros@discoursemail.com a écrit :