Home Setup RobotPy: A Step-by-Step Guide
Post
Cancel

Setup RobotPy: A Step-by-Step Guide

1. Install Python

  • For Windows install from either the Microsoft Store or from Python Site directly
  • MacOS should already have Python installed
  • For Linux, you can install using your package manager
    • ie Ubuntu run

      1
      
      sudo apt install python3 python3-pip
      

2. Create a project folder and setup Python venv(virtual environment)

  • For Linux or Mac

    1
    2
    3
    4
    5
    
      mkdir robotpy
      cd robotpy
      python3 -m venv robotpy
      source robotpy/bin/activate
      pip install --upgrade robotpy[all]
    
  • For Windows

      cd Documents
      mkdir robotpy
      python3 -m venv robotpy
      .\robotpy\Scripts\Activate.bat
      pip install --upgrade robotpy[all]
    

3. Create basic robot.py and test

  • Download and install Visual Studio Code for your platform
  • Open the folder we created previously
  • Create a new file called robot.py
  • Paste in code from one of these examples

4. (Optional) Roborio Installer

  • You can find documentation here, this is the TLDR version, be sure you are connected to a powered-on Roborio via a USB cable

    1
    2
    3
    4
    5
    
      pip install robotpy-installer
      python -m robotpy_installer download-python
      python -m robotpy_installer install-python
      python -m robotpy_installer download robotpy[commands2]
      python -m robotpy_installer install robotpy[commands2]
    

5. Test your code

  • Before deploying your code to the Roborio it is always best to test using the command below

    1
    
      python robot.py test
    
    • Now that you’ve proved out sytax errors it’s time to simulate and see if it’s doing what you want with the following command
    1
    
      python robot.py sim
    

Closing

This should help you get started with a Python virtual environment for robotpy, there is tons more documentation here to dive into, if you’re looking for directions on how to update your RobotPy environment check out my post on updating robotpy. If this post was helpful please consider supporting this blog by click the “Buy me a coffee” button below. Good luck and have fun coding!

This post is licensed under CC BY 4.0 by the author.