python example of a motor hardware interface
Hi all,
I have a 4WD robot that uses PWM motor controls. I am looking for a good ROS2 python example to convert Twist signal in PWM.
Thanks
ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
Hi all,
I have a 4WD robot that uses PWM motor controls. I am looking for a good ROS2 python example to convert Twist signal in PWM.
Thanks
To convert Twist message to PWM that's what I've done
Example
def calc_vel(self, x, z): # x and z are coming from Twist
t = self.track #distance between wheels
r_vel = x + ((z * t) /2)
l_vel = x - ((z * t) /2)
dc_r = calc_duty_cycle(r_vel)
dc_l = calc_duty_cycle(dc_l)
return dc_r, dc_l
def calc_duty_cycle(self, vel):
# linear equation variables defined by experimentation
M_SLOPE = 50
Y_INTERCEPT = 2
return M_SLOPE * vel + Y_INTERCEPT
Asked: 2022-05-30 15:51:25 -0600
Seen: 669 times
Last updated: Jun 06 '22
Do I need to know any specific computer language or framework to use ROS?
Is anybody in ROS community using PySide?
Any good examples of using dynamic_reconfigure for a python node?
where do I get a gazebo diff drive plugin?
is there a python equivalent of fromROSMsg/toROSMsg (pcl stack)
How to contributing python versions of tutorials? e.g. Tutorials for arm_navigation
How to recieve an array over Publisher and Subscriber? (Python)
Error assigning a python quaternion
Using python for automatically writing data in bag to csv file
What model of controllers do you have for these PWM motors? This package
simple_drive
and this AutomaticAddison blog post describe similar things you can try to achieve herethanks, I've written very similar code. I was looking for something which included odom for a bot without encoders.
How would it work exactly?