From 82ed94312f2cc601dfb1b9c49e1dc0ada38798a2 Mon Sep 17 00:00:00 2001 From: JoshuaGabriel Date: Sat, 10 Aug 2024 00:37:38 -0700 Subject: [PATCH] drive now Signed-off-by: JoshuaGabriel --- src/phidget_drivetrain/front_left_right_nopid.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) mode change 100644 => 100755 src/phidget_drivetrain/front_left_right_nopid.py diff --git a/src/phidget_drivetrain/front_left_right_nopid.py b/src/phidget_drivetrain/front_left_right_nopid.py old mode 100644 new mode 100755 index fcb5013..fb5c489 --- a/src/phidget_drivetrain/front_left_right_nopid.py +++ b/src/phidget_drivetrain/front_left_right_nopid.py @@ -17,6 +17,9 @@ def __init__(self): self.pub_right_pwm = rospy.Publisher('worm_gear_front_right_pwm', Int16, queue_size=10) self.pub_right_dir = rospy.Publisher('worm_gear_front_right_dir', Bool, queue_size=10) + self.pub_back_pwm = rospy.Publisher('worm_gear_back_right_pwm', Int16, queue_size=10) + self.pub_back_dir = rospy.Publisher('worm_gear_back_right_dir', Bool, queue_size=10) + # Assume left stick Y-axis is at index 1, adjust if needed self.axis_left_y = 0 @@ -27,9 +30,10 @@ def joy_callback(self, data): joy_value = data.axes[self.axis_left_y] # Convert joystick value to PWM (0 to 255) - pwm_value = int(abs(joy_value) * 255) + pwm_value = int(abs(joy_value) * 100) # Determine direction + direction = False direction = joy_value >= 0 # Publish PWM and direction for both motors @@ -38,6 +42,9 @@ def joy_callback(self, data): self.pub_right_pwm.publish(pwm_value) self.pub_right_dir.publish(direction) + self.pub_back_pwm.publish(pwm_value) + self.pub_back_dir.publish(direction) + if __name__ == '__main__': try: JoystickMotorControl()