Skip to content

Commit 7fcc979

Browse files
authored
Merge pull request #43 from Open-STEM/ArcadeDrive
Arcade Drive method in DifferentialDrive
2 parents 593f75c + ea77e12 commit 7fcc979

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

XRPLib/differential_drive.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,20 @@ def stop(self) -> None:
8484
self.right_motor.set_speed()
8585
self.set_effort(0,0)
8686

87+
def arcade(self, straight:float, turn:float):
88+
"""
89+
Sets the raw effort of both motors based on the arcade drive scheme
90+
91+
:param straight: The base effort (Bounded from -1 to 1) used to drive forwards or backwards.
92+
:type straight: float
93+
:param turn: The modifier effort (Bounded from -1 to 1) used to skew robot left (positive) or right (negative).
94+
:type turn: float
95+
"""
96+
scale = max(abs(straight), abs(turn))/(abs(straight) + abs(turn))
97+
left_speed = (straight - turn)*scale
98+
right_speed = (straight + turn)*scale
99+
self.set_speed(left_speed, right_speed)
100+
87101
def reset_encoder_position(self) -> None:
88102
"""
89103
Resets the position of both motors' encoders to 0

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
["XRPLib/resetbot.py", "github:Open-STEM/XRP_Micropython/XRPLib/resetbot.py"],
1818
["XRPLib/servo.py", "github:Open-STEM/XRP_Micropython/XRPLib/servo.py"],
1919
["XRPLib/timeout.py", "github:Open-STEM/XRP_Micropython/XRPLib/timeout.py"],
20-
["XRPLib/version.py", "github:Open-STEM/XRP_Micropython/XRPLib/version.py"],
2120
["XRPLib/webserver.py", "github:Open-STEM/XRP_Micropython/XRPLib/webserver.py"],
2221
["XRPExamples/__init__.py", "github:Open-STEM/XRP_Micropython/Examples/__init__.py"],
2322
["XRPExamples/drive_examples.py", "github:Open-STEM/XRP_Micropython/Examples/drive_examples.py"],

0 commit comments

Comments
 (0)