1 of 22

Gyro Drive on Spike Prime�using Python

Getting Ready and Testing

2 of 22

Welcome!!! Let’s get ready!!!

  • This presentation is designed as a teaser to show the 2025 Gyro Drive in action.
  • To be clear, you are not expected to know Python at this point!
  • We will…
    • Demonstrate the capabilities of running under the Spike Python environment.
    • Discuss what each test will do, how to set it up, and what the results should look like.
    • Show you some code and an associated video of the robot using it.
    • We hope you will at least have fun and maybe say, “That’s cool!”
  • Just by looking at what the robot does, we believe you can begin to understand some of the code that runs it. You may surprise yourself. That’s where you start. There is no magic here.
  • We do have some homework for you to get started.
  • There will be several other presentations and videos on various topics.
  • We expect to release the 2025 Gyro Drive Spike Python code this summer.
  • For more information, visit our website at midatlanticrobotics.com/fll

3 of 22

2025 Python Gyro Drive�Starting Homework

4 of 22

Create a Test Track

  • Use the back of an old FLL Field
  • On it, draw a 50 cm square as accurately as possible.
    • True Value Hardware has inexpensive wooden meter sticks. My grandson, however, says they are not good swords. 
  • Draw a line, as shown, north to south 25cm from the West line.
  • Leave room on the outside
  • We will think of this as a map. North is up, South is down, East is right, West is left. 
  • The Start is on the southwest corner as shown. 

5 of 22

Test Setup

Test Setup:

  • Robot is fully charged
  • The robot is placed pointing East, centered across the South horizontal line. 
  • The drive wheels are on the West vertical line. This is important as this is where the robot spins.
  • Center the robot carefully on the horizontal line and drive the wheels carefully on the vertical line. 
  • If the robot settings are correct, it can drive all over this field and return to its start. 
  • Remember, this is a toy, but we can make it dance.
  • All actions are very repeatable

6 of 22

gyro_drive_tests()

tests.spin_to_angle_test

7 of 22

tests.spin_to_angle_test

  • Designed to take an angle list and have the robot turn to these in succession. It will use the spin variables in the gyro_drive_settings class.
    • speed: 20% fast, 5% slow, angle: variable�
  • Setup:
    • Position the robot on the mat pointing to the north along the centerline with wheels centered on the south line. �
  • What we expect:
    • The robot will spin to each angle and display the yaw it reads at the end. We have a slight delay so the robot can settle.
    • We expect the final angle to be within 1 degree of the desired angle. �
  • Adjust settings until it is accurate.
    • These are the spin variables in the settings class.

8 of 22

tests.spin_to_angle_test

  • When complete the At angle (requested angle) and final actual yaw will show on the console. All +/- 1o

At angle: 270 | Yaw: 270 (-90)

At angle: -270 | Yaw: -269 (91)

At angle: 360 | Yaw: 361 (1)

At angle: -360 | Yaw: -359 (1)

At angle: 390 | Yaw: 390 (30)

At angle: -390 | Yaw: -389 (-29)

At angle: 450 | Yaw: 449 (89)

At angle: -450 | Yaw: -450 (-90)

At angle: 0 | Yaw: -1 (-1)

360+ compass

At angle: 45 | Yaw: 45 (45)

At angle: -45 | Yaw: -44 (-44)

At angle: 90 | Yaw: 89 (89)

At angle: -90 | Yaw: -90 (-90)

At angle: 135 | Yaw: 135 (135)

At angle: -135 | Yaw: -135 (-135)

At angle: 180 | Yaw: 181 (-179)

At angle: -180 | Yaw: -179 (-179)

9 of 22

gyro_drive_tests()

tests.drive_accuracy_test

10 of 22

tests.drive_accuracy_test

  • Designed to have the robot drive a measured distance and back again.
    • length: 50 cm, speed: 50%, angle: 0
    • loops: 2�
  • Setup:
    • This is run on the test mat starting at the south-west corner. �
  • What we expect:
    • We want the robot to follow the south center line. We want the wheels to stop on the east line while it still straddles the south line.
    • It will then back up, using slower reverse speed, following the south line, to the west line exactly where it started.
  • Adjust settings until it is accurate.

11 of 22

tests.drive_accuracy_test

  • Designed to have the robot drive a measured distance and back again.
    • length: 50 cm, speed: 50%, angle: 0
    • loops: 2�
  • Setup:
    • This is run on the test mat starting at the south-west corner. �
  • What we expect:
    • We want the robot to follow the south center line. We want the wheels to stop on the east line while it still straddles the south line.
    • It will then back up, using slower reverse speed, following the south line, to the west line exactly where it started.
  • Adjust settings until it is accurate.

12 of 22

gyro_drive_tests()

tests.drive_test_square

13 of 22

tests.drive_test_square

  • Designed for robot to drive a 50 cm square using +/- angles past +/-180o
    • length: 50 cm, speed: 50%, angle: variable
    • loops: 2�
  • Setup:
    • This is run on the test mat starting at the south-west corner. �
  • What we expect:
    • We want the robot to travel 50 cm on each side of the square, following the angles called out in the code. These are all left turns.
    • It will make two loops. When done, the robot will be back in the starting position. �
  • Adjust settings until it is accurate.
    • These are the spin variables in the settings class.

14 of 22

gyro_drive_tests()

tests.drive_torture_test

15 of 22

tests.drive_torture_test

  • Designed for robot to drive 25 and 50 cm squared figure 8, then do a criss-cross, using +/- angles <= 180o
    • length: 50 cm, speed: 25 and 50%, angle: variable
    • loops: 1�
  • Setup:
    • As described in the accuracy test.
    • The diag_distance was calculated as the Hypotenuse of the 50cm triangle. We added about 1 cm. Hey, are not perfect but reproducible! �
  • What we expect:
    • We want the robot to travel the 25 and 50 cm in a squared figure 8 following the length and angles called out in code. Then do a criss-cross.
    • It will make 1 loop. When done the robot will be back in the starting position. �
  • Adjust settings until it is accurate.
    • These are the spin variables in the settings class.

16 of 22

gyro_drive specials

Using Waypoints

17 of 22

Gyro Drive - Waypoints

  • Waypoint is a colored line or area near an important target
    • It can be anything you want. Colored area!
  • Gyro Drive allows you to add an override to stop at those waypoints.
    • You set it to go further, but the override stops when it sees the color.
  • Look at the map from last season.
    • You want to drive up close so you don’t get a false color positive.
    • Then switch to this override when you are close. Approach slowly.
    • If you hit it, the result code will be,�results.WAYPOINT_DETECTED

18 of 22

Gyro Drive - Waypoints

  • (146-148) We drive using several waypoint colors.
    • We do not have GREEN!
  • (150-175) If we hit a waypoint, message to see what color we hit.
  • (159-162) We did not hit a WP color, so we message no hit.
  • (164-166) Write the message on the hub display and print how far we traveled.
  • (167) Return back to start using distance, negative speed%, -90o.
    • Drive.last_distance_cm is how far we actually traveled until we stopped.
  • (168) Turn robot to angle(0) to restart.

19 of 22

gyro_drive specials

Using Sonar

20 of 22

Gyro Drive - Sonar

  • The hub has a distance sensor that can be used to creep up on a target.
    • You can then accurately know where you are to an object.
    • You want to drive up close so you don’t get a false positive.
    • Then switch to sonar when you are close. Approach slowly for accuracy.
    • You may want to add a timeout if you get hung up on something.
      • If you timeout, you decide what to do. �
  • Note that in this case, the sensor is on the back of the robot.
    • Negative speed to back to target

21 of 22

Gyro Drive - Sonar

  • (125) Setting the port for the distance sensor
  • (126) Drive using sonar, at 15 cm, -15 speed (back), angle 90o for fun!
    • Why angle 90o?
    • Force a spin to the right, oops, 90o does the same thing. Have fun, try spin_left!!!
    • 15 cm is the distance to stop from the target.
  • (129) Turn back to angle 0o
    • This makes it easier to see the hub display message.
  • (130-134) Build and display the message of how far we ended up from the target.
    • Usually about .1 cm.
  • (137) Drive back the distance we traveled, at 50% speed, at 90o
  • (138) Spin back to 0o, almost exactly where we started.
  • (140) return ends the main function.

22 of 22

gyro_drive_tests()

Let us know what you think in the comments.�Visit us at midatlanticrobotics.com/fll