1 of 11

Gyro Drive on Spike Prime�using Python

Installation and�Robot Setup

2 of 11

Pre-Install Requirements

  • This presentation assumes you are familiar with this code.
  • Before setting up your robot, you should read through all the 2025 Gyro Drive presentations so you are familiar with the terms and code layout.

3 of 11

Is Python activated?

  • If you know Python is activated on your Spike system, skip these steps. �
  • Open Spike
  • The Spike Prime IDE (Interactive Development Environment) allows you to key in the Python commands�just like any text-based programming�language. You may need to enable it…
    • Help, Settings, General, Enable Python
  • Click New Project but done’t hit CREATE!
    • You should be able to arrow to Python. �It should not be grayed out.

4 of 11

Installation

  • The code is released on the MAR-FLL-Director Github account 2025-GyroDrive-Spike-Python
  • Once on the page, at the top, you will see a list of items available.
    • Click on the file name with the most recent date.
    • This stands for Spike Prime Python and the upload date.
    • On the right side, look for the Download button
    • Click it and download to your Download, or Share folder
      • I am only familiar with Windows. If you have Apple, or Chromebook please try it out and let me know what the process is.
  • The GitHub window is no longer needed; however, there are links to various presentations.
    • These presentation are also available on the FMA FLL website under �FLL Challenge Team Info 2025 MAR FLL Challenge Tools - Gyro Drive Spike Python

5 of 11

Open Program

  • Start up the Spike application
  • Windows:
  • Upper left corner click File, Open.
  • Navigate to where you saved the spp yy-mm-dd.llsp3 file.
  • Click it and the file will open. It will also be copied to your Documents/LEGO Education Spike folder.
  • Apple
  • I was told this is similar to how Windows works.
  • Chromebook
  • Need Instructions (please email answer to flarkin@midatlanticrobotics.org)

6 of 11

Initial Setup

Now that you are in the code, you need to initiate the gyro_drive_settings class with parameters to fit your robot.

  • Wheel Diameter
  • The actual wheel diameter is just a starting point. We will adjust this to get the robot to work accurately.
    • The large wheels are 8.80 cm. The medium are 5.60 cm. We needed to adjust these values to get the best accuracy.
    • We landed on 8.85 cm and 5.56 cm. The code is not perfect, but once dialed in, it is very reproducible.

7 of 11

Initial Setup

You need the additional settings after the wheel diameter.

  • Left motor port (port.A to port.F)
  • Right motor port
  • Measure motor port
  • Max velocity on the motors (use enum)
    • These values are discussed in the Spike Hub Knowledge Base motor section.
  • We also have 2 defaulted values
  • left_motor_direction = -1
  • right_motor_direction = 1
    • This is used to flip one motor’s direction so they both go in the same directions when called on. Normally the right is fine but left needs to be flipped.

8 of 11

Testing Driving Accuracy

  • Setup your code like we are to the right.
  • Use your wheel diameter, ports, and max motor velocity.
  • As you add attachments you may need to change your settings for “base case”
  • Even if the settings are not perfect the will be reproducible.
  • Try not to change the settings once you have a few missions ready. Otherwise you will have to retest.
  • You can use the tests.drive_accuracy_test() to test you settings.
  • If your code does not have this, type it in. Type tests. and all the methods will show up.
  • This will allow you to dial in the distance accuracy.
  • Carefully, line up the robot correctly each time.
  • Set it up for several (2 or 3) loops so you can be sure you are accurate.
  • Make slight changes to the wheels diameter to dial it in.
  • Use a low speed like 40% or 50%.
  • Once you dial it in try using speeds of 70% and 80%. It should work as acceleration will ramp speed up and slow down.

9 of 11

Testing Driving And Spin Accuracy

  • We do support acceleration when driving.
  • This will put the robot speed through 3 states, ramp up, steady state, and ramp down.
  • There are two settings. You can put them in and then adjust as you go. Look at the settings code for what they do.
  • Play with different settings see how they affect the acceleration.�
  • You can use tests.spin_to_angle_test() to get you close to the any angles you will want.
  • This test will call gyro_spin_to_angle(). It is called to turn your robot to a specific angle. It is also called by gyro_drive to turn to the angle before you move forward or reverse.
  • As you test, adjust your spin settings to get it within +/- 1 degree.
  • Make sure your heaviest attachments are on the robot for testing.
  • Even if the settings are not perfect they will be reproducible.
  • Remember when used with the gyro_drive, once the angle is turned, you will drive on that same angle for the length given.

10 of 11

gyro_drive test plot

Here is a plot of a test drive.

  • It shows speed in acceleration, steady state, and deceleration.
  • It shows angle correction as it is driving.
  • Question: Did it accurately hit the target distance at the end?

The circles are plots over time of the readings. In 1.55 sec., there were only 9 plots. We want many more passes for accuracy. This slows it down but useful to see it.

11 of 11

Gyro Drive on Spike Prime�using Python

Good Luck!!!