dheera / ros-pwm-pca9685 Goto Github PK
View Code? Open in Web Editor NEWROS package for PCA9685 16-channel PWM driver, used in motor and LED applications
ROS package for PCA9685 16-channel PWM driver, used in motor and LED applications
Hi, I am very new to ROS, but I was able to compile the code and publish to my robot. I am just trying to simply move my motor, but it seems like I don't know how to control how long the motor runs for? I first want 2 motors to run, then the first only then the second only. I believe I also need to tell the motor to stop in between
Here is my code
#!/usr/bin/python3
import rospy, time
from std_msgs.msg import Int32MultiArray
class motor():
def __init__(self):
rospy.loginfo("Setting Up the Node...")
self.pub = rospy.Publisher("command", Int32MultiArray, queue_size=10)
rospy.init_node('motor_test')
self.r = rospy.Rate(10)# 10hz
def send_motor_msg(self):
self.pub.publish(Int32MultiArray(data=[0, 0, 0, 0,0,0,0,0,0,0,0,0,0,0,0,0]))
self.pub.publish(Int32MultiArray(data=[32717, 0, 32717, -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1]))
self.pub.publish(Int32MultiArray(data=[0, 0, 0, 0,0,0,0,0,0,0,0,0,0,0,0,0]))
self.pub.publish(Int32MultiArray(data=[32717, 0, 0, -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1]))
self.pub.publish(Int32MultiArray(data=[0, 0, 0, 0,0,0,0,0,0,0,0,0,0,0,0,0]))
self.pub.publish(Int32MultiArray(data=[0, 0, 32717, -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1]))
if __name__=="__main__":
m = motor()
while not rospy.is_shutdown():
m.send_motor_msg()
m.r.sleep()
How can I control it such that I can tell the robot how long to run a motor?
Hi everybody,
I try to launch the node with the command :
rosrun pwm_pca9685 pca9685_node
But I keep have the same error : i2c device open failed
My I2C port works correctly, the command sudo i2cdetect -y 1
sees the board
Do you have any idea of the source of the problem ?
Hi @dheera
I am pretty new to ROS and trying to build a RPi-Robot to learn it.
I have this PCA9685 based PWM board and I run ROS Melodic on Debian Buster and everything works fine (including a camera). The board has address 0x40 so the default parameters are probably correct.
libi2c-dev
is installed and I try to start your node like this:
rosrun pwm_pca9685 pca9685_node
But it segfaults:
[ INFO] [1585099217.457893949]: initializing
[ INFO] [1585099217.477227357]: starting
Segmentation fault
(gdb) backtrace
#0 0x00016158 in pwm_pca9685::PCA9685Activity::set(unsigned char, unsigned short) ()
#1 0x00016ae0 in pwm_pca9685::PCA9685Activity::spinOnce() ()
#2 0x00015bd4 in main ()
Maybe you know why this happens or you can tell me how to properly debug it.
Showing my colors here, but I'm new to ROS. I have ROS setup and running, receiving inputs from a joy_node I've configured that's taking in inputs from an Xbox One S controller (bluetooth). What I'd like to do is relay those inputs to this PCA9685 node to drive two motors and a steering servo.
I bought a WaveShare JetRacer kit that comes with a "JetCard" distro/jupyter notebook that's kind of watered down and had a lot of functions that weren't working, so I decided to just load JetPack and try some stuff for myself. There's a battery+oled+SCL/SDA "hat" that comes with the JetRacer which has most stuff being driven over i2c. I've been able to drive the motors and steering rack using the servokit and motorkit package from adafruit in a terminal just to test their functionality.
Where I'm running into a snag is trying to pull those "kits" into ROS, which is where I found you! I just need to figure out how to turn this into a node so I can start testing things from ROS.
Hi,
Thanks for the code. I am using a Waveshare jetracer with its schematic in driving motos and servos in this link.
Despite the settings of this hardware, the motors start spining and stop once I run the node directly. I am a bit confused since the default of this node should hold everything to 0%?
I have been trying to pass parameters to the node and cant seem to figure out what is going on. Here is what I tried:
rosrun pwm_pca9685 pca9685_node timeout:=[100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100]
but it still runs for 5 seconds. I have also tried rosrun pwm_pca9685 pca9685_node _timeout:=[100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100]
and the same thing. Any advice?
Hi dheera,
I'm trying to use your driver node on my project with the PCA9685 and a raspberry connected to it by i2c. The i2c works because I used it with the servokit library and works really fine. What is happening is that when your ros is running in the raspberry pi the robot start to make random movements that has not send and without sending any command. I don't know why is this working like that. I don't know if it's something important but I'm working with the roboti arm sainsmart 6dof.
I also tried to publish a command in the /command topic but when I do it it latched, in the /command is received but no motor is working. When I use the rqt_graph I get this image and I don't understand what is doing. Can you give me some feedback ? I send you also the rqt_graph
Will this solution work for ros2 on catkin too? I see colcon dependencies in CMakeLists.txt which I guess points to old ros (version 1).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.