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

Advanced Swerve Code for FRC
Other
1 stars 2 forks source link
frc frc-java frc-swerve swerve-drive

ROBOT PROGRAMMING 101

By Sean Benham

Here is as good a comprehensive guide to programming a robot as I am able to create. 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. I'll also try to include tips and tricks that aren't taught in other places.

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 has a very confusing structure for a beginner. 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.
  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.
  7. Mechanical Advantage 2024 The best team for software in New England. HOWEVER they use their own logging tool called AdvantageKit. It's super cool, but not for beginners, and this project has another atypical structure. Also, AdvantageKit is sadly not compatible with this project, because the CTRE swerve libraries we use have multithreading for odometry.

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