Coder Social home page Coder Social logo

go-robot-fll / python-for-spike-prime Goto Github PK

View Code? Open in Web Editor NEW
48.0 1.0 12.0 95 KB

These are the programs we use every day as a team for programming the LEGO SPIKE PRIME for competitions such as the First Lego League. Feel free to use this code and tag us on social media if you do so

License: Apache License 2.0

Python 100.00%
spike prime fll wro gorobot python lego mindstorms robot firstlegoleague

python-for-spike-prime's Introduction

Python-for-Spike-Prime

These are some basic programs that are useful if you are building and programming the LEGO SPIKE PRIME. We use this code for competing in the FLL ourselves and have received multiple awards for our robot design. We strongly recommend that you use VS Code for your programming, the instructions for doing so are below. You can however also paste this into the SPIKE or MINDSTORMS software.

Programs and Features included

Linefollower

  • follows line until specified color/distance is reached
  • acceleration/braking
  • dynamic PID control for smooth driving

Gyrorotation

  • turns until specified color/angle is reached
  • acceleration/braking
  • different turning styles (on the spot/curve)

Gyrostraightdrive

  • drives in a straight line until specified distance/color is reached
  • accelerating/braking
  • dynamic PID control for smooth driving
  • alignment with lines
  • parallel code execution for turning motors while driving

Arc Rotation

  • turns in a large arc, to be able to turn around objects until ending condition is reached
  • accelerating breaking
  • various ending conditions

Break Function

  • allows you to break out of currently running function back into main
  • press right button to activat
  • save significant amounts of time and is less prone to crashing the hub than middle button

Necessary extensions/Programs for use in VS Code:

Visual Studio Code Python Lego Spike Prime/Mindstorms Robot Inventor Extension by Peter Staev

Fully charged battery voltage

When the battery is fully charged the voltage is roughly 8300. This will vary based on how the wear and tear of your battery. We recommend charging the robot when the battery voltage drops below 8000 mV, as there is a reduction in torque.

How to connect:

Click the button LEGO Hub: Disconnected on the left hand side of the blue bottom bar. A dropdown menu will open at the top of the screen, try out all the COM options it gives you until you are connected. Note: You have to have previously connected to the hub in the Spike or Mindstorms software first.

How to upload a program to the hub:

Press CTRL SHIFT P and select LEGO Hub: upload program from the dropdown menu. Choose Python: regular. Choose the slot you want the program to be saved in on the hub.

How to start a program:

Press CTRL + SHIFT + P and select LEGO Hub: start program from the dropdown menu. Select the slot of the program you want to start on the hub. Note: This step can be skipped if you have autostart activated.

How to enable precompiling:

To precompile the main.py on the PC/laptop, go to the extension page and select the extension. Then click on the settings symbol and activate Lego Spike Prime Mindstorms: Compile Before Upload. This will allow the program to start faster.

Reporting Bugs:

If you find a bug, kindly report it to [email protected] We will try to fix it as soon as possible. If you have any questions regarding the code, please reach out to us using the same Email adress.

For further info on working with Spike Prime in VS Code see:

https://github.com/PeterStaev/lego-spikeprime-mindstorms-vscode

Credits:

Thanks to Peter Staev for making it possible for us to use access in depth features of Spike Prime and for enabling us to use VS Code to program.

Disclaimer:

This program uses features of extensions that use unofficial and undocumented APIs. They can change without notice. Functions tested on Windows 10/11 connecting to a LEGO MINDSTORMS Spike Prime Hub.

LEGO and MINDSTORMS are registered trademarks of the LEGO Group. SPIKE is a trademark of LEGO Group.

python-for-spike-prime's People

Contributors

juoper avatar marcus-howell avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.