Skip to content

Commit 2fdf624

Browse files
committed
Fix speed control so 0 turns it off; retune turn secondary values for turn
1 parent d354ca3 commit 2fdf624

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

XRPLib/differential_drive.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ def turn(self, turn_degrees: float, max_effort: float = 0.5, timeout: float = No
246246
# Secondary controller to keep encoder values in sync
247247
if secondary_controller is None:
248248
secondary_controller = PID(
249-
kp = 0.002,
249+
kp = 0.0175,
250250
)
251251

252252
if use_imu and (self.imu is not None):

XRPLib/encoded_motor.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,15 +115,16 @@ def get_speed(self) -> float:
115115
def set_speed(self, speed_rpm: float = None):
116116
"""
117117
Sets target speed (in rpm) to be maintained passively
118-
Call with no parameters to turn off speed control
118+
Call with no parameters or 0 to turn off speed control
119119
120120
:param target_speed_rpm: The target speed for the motor in rpm, or None
121121
:type target_speed_rpm: float, or None
122122
"""
123-
if speed_rpm is None:
123+
if speed_rpm is None or speed_rpm == 0:
124124
self.target_speed = None
125125
self.set_effort(0)
126126
self.speed = 0
127+
self.updateTimer.deinit()
127128
return
128129
# If the update timer is not running, start it at 50 Hz (20ms updates)
129130
self.updateTimer.init(period=20, callback=lambda t:self._update())

XRPLib/resetbot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# using the EncodedMotor since the default drivetrain uses the IMU and takes 3 seconds to init
1212
for i in range(4):
1313
motor = EncodedMotor.get_default_encoded_motor(i+1)
14-
motor.set_effort(0)
14+
motor.set_speed(0)
1515
motor.reset_encoder_position()
1616

1717
# Turn off the on-board LED

0 commit comments

Comments
 (0)