Skip to content

Commit 65f70ae

Browse files
committed
Fixed turn with use_imu false issues
1 parent 9f99ca8 commit 65f70ae

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

XRPLib/differential_drive.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def straight(self, distance: float, max_effort: float = 0.5, timeout: float = No
138138
if main_controller is None:
139139
main_controller = PID(
140140
kp = 0.075,
141-
kd = 0.005
141+
kd = 0.005,
142142
minOutput = 0.25,
143143
maxOutput = max_effort,
144144
tolerance = 0.1,
@@ -176,7 +176,7 @@ def straight(self, distance: float, max_effort: float = 0.5, timeout: float = No
176176
# record current heading to maintain it
177177
current_heading = self.imu.get_yaw()
178178
else:
179-
current_heading = ((leftDelta-rightDelta)/2)*360/(self.track_width*math.pi)
179+
current_heading = ((rightDelta-leftDelta)/2)*360/(self.track_width*math.pi)
180180

181181
headingCorrection = secondary_controller.tick(initial_heading - current_heading)
182182

@@ -250,7 +250,7 @@ def turn(self, turn_degrees: float, max_effort: float = 0.5, timeout: float = No
250250
turnError = turn_degrees - self.imu.get_yaw()
251251
else:
252252
# calculate turn error (in degrees) from the encoder counts
253-
turnError = turn_degrees - ((leftDelta-rightDelta)/2)*360/(self.track_width*math.pi)
253+
turnError = turn_degrees - ((rightDelta-leftDelta)/2)*360/(self.track_width*math.pi)
254254

255255
# Pass the turn error to the main controller to get a turn speed
256256
turnSpeed = main_controller.tick(turnError)

0 commit comments

Comments
 (0)