Skip to content

Commit

Permalink
drive now
Browse files Browse the repository at this point in the history
Signed-off-by: JoshuaGabriel <[email protected]>
  • Loading branch information
JoshuaGabriel committed Aug 10, 2024
1 parent fae5cce commit 82ed943
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/phidget_drivetrain/front_left_right_nopid.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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()
Expand Down

0 comments on commit 82ed943

Please sign in to comment.