Skip to content

Operation-P-E-A-C-C-E-Robotics/base-swerve

Repository files navigation

ROBOT PROGRAMMING 101

By Sean Benham

Here is as good a comprehensive guide to programming a robot as I am able to form with my 8 years of FRC knowledge. This is intended to take you from the very basics all the way to a highly competitive robot.

In many places, I will refer to outside sources. This way, I'm not re-inventing the wheel, and all the necessary information is compiled in one place. You won't miss anything for lack of searching. I'll also include the most important tips and tricks that are often missed in conjuction with what's available in whatever artice.

Let's start with that now

Links to key documentation:

  1. WPILib Docs: Great documentation for all things robot code
  2. Phoenix Docs: Writing software for CTRE products (Motors, Pigeon IMU, CANCoders, etc.)
  3. REV Robotics Docs: Writing software for REV Products (PDH/PCM, Motors, Etc.)
  4. Limelight Docs: Using the Limelight camera
  5. Photonvision Docs: Using photonvision cameras
  6. PathPlanner Docs: Path planning for autos with PathPlanner
  7. Choreo Docs: A more optimized but harder-to-use alternative to PathPlanner
  8. EVERYTHING I'VE LEARNED ABOUT FRC (mostly)

Good Reference Projects:

  1. Our 2023 Software Demonstrates state space motion control with advanced kinematics and automation. Uses limelight apriltags for localizing. Tank drive. Overcomplicated and failed miserably, but structurally sound and worth looking at.
  2. Our 2024 Software Uses MotionMagicExpo for motion profiling, state space for the flywheels. Swerve drivetrain based on this project. Auto aiming with shoot-on-the-move calculations. Worked extremely well (considering it was written by one guy) but uses an unconventional State Machine architecture. This will make it confusing if you don't have a good understanding of programming in general.
  3. CTRE example projects Projects from CTRE that demonstrate how to use their stuff. Most of them are not command-based - keep in mind that they aren't examples of how to structure your code.
  4. FRC 254 2018 Very complicated, unconventional, ahead of it's time, and very confusingly structured. This project inspired me so I'm including it, but DON'T try and copy it.
  5. Our 2017 Code From a time before I did software; much, much simpler than any of the garbage I've done. Don't do a separate subsystem for the left and right half of a tank drive though, that's silly.
  6. Our 2022 Code The first robot I programmed that actually competed (ahem, COVID). Garbage code, I didn't know what I was doing. Worked good.

Before we get started, look through this google slide

It should give the requisite knowledge of robot hardware to get started. I'm sorry about how terrible it is, that's cause I made it.

WITHOUT FURTHER ADO

Here is the guide index:

  1. Setting up your driver station
  2. Setting up your robot project
  3. Basic programming skills & The Command Based Structure
  4. Using GIT & GitHub
  5. Getting a swerve running (using this project)
  6. End Effectors, Intakes, and Pneumatics
  7. Motion control 101
  8. How to program an elevator
  9. How to program an arm
  10. How to program a shooter
  11. Kinematics 101
  12. Creating good OIs & automation
  13. Creating an autonomous
  14. Telemetry & Useful Data Sources
  15. Programming Using State Machines
  16. Available debugging resources.
  17. Competitions and Sanity