-
-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests/motors/drivebase: Add s-curve test.
Drive straight, curve right, curve left, and straight again, all without stopping.
- Loading branch information
1 parent
d595002
commit bd15513
Showing
2 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from pybricks.pupdevices import Motor | ||
from pybricks.tools import wait | ||
from pybricks.parameters import Port, Direction, Stop | ||
from pybricks.robotics import DriveBase | ||
from pybricks import version | ||
|
||
print(version) | ||
|
||
# Initialize default "Driving Base" with medium motors and wheels. | ||
left_motor = Motor(Port.C, Direction.COUNTERCLOCKWISE) | ||
right_motor = Motor(Port.D) | ||
drive_base = DriveBase(left_motor, right_motor, wheel_diameter=56, axle_track=112) | ||
|
||
# Allocate logs for motors and controller signals. | ||
DURATION = 20000 | ||
DIV = 4 | ||
left_motor.log.start(DURATION, DIV) | ||
right_motor.log.start(DURATION, DIV) | ||
drive_base.distance_control.log.start(DURATION, DIV) | ||
drive_base.heading_control.log.start(DURATION, DIV) | ||
|
||
# Drive straight, curve right, curve left, then straight, without stopping. | ||
drive_base.straight(500, Stop.NONE) | ||
drive_base.curve(200, 90, Stop.NONE) | ||
drive_base.curve(200, -90, Stop.NONE) | ||
drive_base.straight(500) | ||
|
||
# Wait so we can also log hold capability, then turn off the motor completely. | ||
wait(100) | ||
drive_base.stop() | ||
|
||
# Transfer data logs. | ||
print("Transferring data...") | ||
left_motor.log.save("servo_left.txt") | ||
right_motor.log.save("servo_right.txt") | ||
drive_base.distance_control.log.save("control_distance.txt") | ||
drive_base.heading_control.log.save("control_heading.txt") | ||
print("Done") |
File renamed without changes.