+
+This diagram shows many of the electrical components found on a typical FRC robot.
+You don't need to memorize this layout, but its handy to have this as a reference.
+
+### Battery
+
+
+
+All of the power our robot uses comes from a single 12-volt car battery.
+These can be found on our battery cart in the corner of the lab.
+Not all batteries are created equal: Some brands and specific batteries can hold more juice for longer than others.
+One way we can see the performance of a battery is the resting voltage (or voltage when no motors or similarly power hungry devices are running) of the battery after it has charged.
+This can be checked with the battery beak or on the driver station.
+A good battery will have a resting voltage of over 13 volts, and any battery we use will be above 12.
+As the battery is used the voltage will go down.
+We tend to swap our batteries after they get to around 12.5 volts, although if we are testing something sensitive to voltage (like auto) we might swap them sooner.
+After a match a good battery is usually still above 12 volts.
+To track batteries so we know which batteries are "good" and which are "bad" we give them names like "Garbanzo" or "W.I.S. (Women In STEM)".
+
+When the robot is on, the voltage will drop as power is used by processors and lights.
+When the robot is enabled, the voltage will drop further as power is actively used by mechanisms.
+This is called voltage sag.
+This means that we can't pull full power from every motor on the robot at once and have to be careful to design and program around our power budget.
+When the voltage of the robot drops too low we can brownout.
+This is usually first visible when the LEDs on the robot go out.
+When the voltage is low enough, motors will begin to be turned off automatically, which is visible as a stuttering or jerking.
+If the voltage is even lower, the robot can restart.
+Needless to say, we want to avoid any brownout conditions in a match or when testing, but we often end up seeing them when pushing the robot in testing.
+
+$V = IR$ is the equation which governs voltage sag, where $V$ is amount the voltage will sag from resting, $I$ is the current draw of the robot, and $R$ is the internal resistance of the battery.
+
+### Main Breaker
+
+
+
+The main breaker is the power switch of the robot.
+The red button will turn the robot off, and a small black lever on the side of the breaker will turn it on.
+The main breaker is directly connected to the battery and limits the current draw of the robot, or the amount of power it can use at once.
+This limit is theoretically 120a, but in practice we can draw much more than that for small but significant periods of time (several seconds).
+Whenever you need to be hands on with the robot, make sure the breaker is off.
+If you can't connect to the robot, make sure it's on.
+If the breaker is on, make sure to wear safety glasses.
+
+The breaker should be mounted in a visible and accessible location on all robots, although it tends to blend in with its black casing.
+We tend to have a 3d-printed guard over the off switch to prevent accidental presses by other robots mid-match.
+
+### Power Distribution Hub (PDH)
+
+
+
+The PDH takes the power from the battery and distributes it to the motors, sensors, and other components on the robot (Almost like its a hub for distributing power!).
+We don't have to do anything with the PDH in code, but if a motor or sensor does not have power it could have a bad connection with the PDH.
+The PDH will also have a smaller breaker for each motor on it, which limits the power draw from each individual motor to 40 amps.
+In practice, we can draw more for a short period of time.
+If you are interested in more details about how and why that works, look at the electrical coursework for the team.
+
+There is a similar product manufactured by CTRE called the Power Distribution Panel, or PDP.
+This is essentially an older version of the PDH with fewer motor slots, and is largely legacy hardware.
+You might see it in older documentation and robots, however.
+
+The PDH is also often at one end of our CAN network. What's CAN? Glad you asked . . .
+
+### The CAN Network
+
+
+
+CAN is a type of communication along wires that allow our sensors and motors to communicate along our robot.
+In FRC, CAN is transmitted over yellow and green pairs of cables.
+Each device on the CAN network has a unique ID that it uses to talk to other devices on the network.
+All of our motors and many of our sensors will communicate over CAN.
+CAN is also one of the easiest places for electrical problems to become apparent in software because of the thin wires and large reach of the system.
+When you start up the robot you may see red error messages in the drive station console reporting CAN errors.
+If you see that, something might be broken on the CAN network.
+
+We have to set the IDs of the devices on the CAN network to make sure they are all uniquely and correctly identified.
+It would be very awkward to try to drive the robot and accidentally run the elevator instead of the drivetrain!
+To set the IDs of devices on the CAN network we use the [Tuner X](https://pro.docs.ctr-electronics.com/en/stable/docs/tuner/index.html) app built by CTRE or the [Rev Hardware Client](https://docs.revrobotics.com/rev-hardware-client), depending on the motor type being used.
+This app also has features to test and configure devices on the CAN network.
+
+### CANivore
+
+
+
+The CANivore is a device that connects to the [Rio](#roborio-2) (in the next section) over usb.
+It allows us to have a second CAN network with increased bandwidth.
+This is useful because CAN has a limited amount of information that can travel over it each second, and we can easily reach that limit with the number of motors and sensors we have.
+The CANivore gets around some hardware limitations of the Rio to have extra bandwidth on its network compared to the default network.
+This also enables some extra latency compensation features on CTRE devices.
+In 2024 we exclusively used the CANivore network for motors and sensors.
+
+### RoboRIO 2
+
+
+
+The RoboRIO (rio) is the brain of the robot.
+It is built around a computer running Linux with a large number of Input/Output (IO) ports.
+These ports include:
+
+- Digital IO (DIO) can accept inputs and outputs that are either a 1 or 0, on or off.
+ When used as an input the signal can rapidly be turned on and off to send numerical data.
+ This is done using Pulse Width Modulation (PWM), essentially measuring how long a signal is on compared to how long it is off in a given time window to get a numerical value.
+ For more information on PWM optionally read [this article](https://learn.sparkfun.com/tutorials/pulse-width-modulation/all)
+- PWM pins provide additional pins to _output_ PWM signals.
+ Unlike the DIO ports the PWM ports cannot take inputs.
+ Many motor controllers support using a PWM signal for control instead of CAN, although it has significantly limited features.
+- Analog inputs provide adititional sensor ports, although most sensors use DIO or CAN.
+- The large set of pins in the middle of the Rio is the MXP port.
+ MXP (and the SPI port in the top-right corner) is used for communication over serial interfaces such as I²C protocal.
+ Unfortunately, there is an issue with I²C that can cause the code to lock up when it is used, so we avoid using the serial ports.
+ We can get around this issue by using a coprocessor (computer other than the rio, like a raspberry pi) to convert the signal to a different protocol.
+ Generally we avoid using I²C devices.
+- A CAN network originates at the RIO.
+- Several USB ports are available on the Rio.
+ Common uses include external USB sticks to store logs or the [CANivore](#canivore) (see later in this page).
+ The usb ports can also be used to connect the rio to a computer to deploy code and run the robot, although we usually prefer to use ethernet if we need to run tethered.
+- An ethernet port which connects to the radio (in the next section) to communicate to the driver station.
+
+The Rio also has an SD card as its memory.
+When we set up a Rio for the season we need to image it using a tool that comes with the driver station.
+The WPILib docs have [instructions](https://docs.wpilib.org/en/stable/docs/zero-to-robot/step-3/roborio2-imaging.html) on how to image the SD card.
+
+### Note on 2026-7+ Control System
+As per [this](https://community.firstinspires.org/introducing-the-future-mobile-robot-controller) blog post, FRC will use a different robot control system called SystemCore beginning with the 2027 season.
+This moves away from the RoboRIO and NI and instead will use a controller based on the Raspberry Pi CM5.
+More Information to come on Systemcore in 2026.
+
+### Vivid Hosting Radio
+
+
+
+The VH-109 radio is essentially a Wi-Fi router that lives on the robot and connects it to the driver station.
+At tournaments we have to take the radio to get reprogrammed for that competition.
+This makes it able to connect to the access point (another radio on the field) so that our robot gets enabled and disabled at the right times during matches, however it prevents us from connecting to the robot with a laptop wirelessly $`^1`$.
+The radio has four ethernet ports and a pair of terminals for power wires.
+One ethernet port connects to the rio and is labeled RIO.
+One is usually reserved for tethering to a laptop and is labeled DS.
+We can connect certain advanced sensors, like vision systems, to ethernet.
+Sometimes we add a network switch to the ethernet network, which is a device that allows us to have more ethernet ports than the radio provides.
+Network switches and other ethernet devices are plugged into the AUX1 and AUX2 ports on the radio.
+
+After each competition we have to reimage the radio to allow it to connect to a laptop wirelessly again.
+Refer to the [vivid hosting radio documentation](https://frc-radio.vivid-hosting.net/) for more information.
+
+We can also connect to the robot's VH-109 by connecting to a second network (which comes from a second radio that's connected to the robot).
+This radio could be the VH-113 access point, which is a larger radio that is for the field instead of going on a robot, or a VH-109 configured to act like a VH-113.
+This is the setup we'll usually be using at the Loom.
+
+The radio can either be powered using Power-Over-Ethernet (PoE) or the power terminals.
+Be careful with checking for good, consistent radio power if you are having connection issues.
+
+An older radio known as the OM5P was in use until champs 2024, and you may encounter some on old/offseason robots.
+It was much worse to deal with (more fragile and finicky) and we are lucky to be done with it.
+It is pictured below.
+
+
+
+### Motor Controllers
+
+
+
+Motors are the primary form of movement on the robot, but on their own they are just expensive paperweights.
+Motor controllers take signals from our code, often over CAN, and turn them into the voltage sent to the motor.
+These controllers plug into slots on the PDH, the CAN network (or much more rarely PWM ports), and the power lines of the motor.
+
+Many motor controllers have more features than just commanding a voltage to a motor.
+For instance they might be able to run PID loops much faster than our code is able to, which drives a motor to a specific position or velocity.
+Knowing what motor controller you are using and what features it has is very important when writing robot code.
+Pictured above is the Spark Max built by REV Robotics, a common modern motor controller often used with the NEO and NEO 550 motors.
+REV also produces a motor called the NEO Vortex which uses the Spark Flex, pictured below.
+
+
+
+
+### The Talon FX + Kraken X60/44
+
+
+
+**These motors are used by 321 only, but this information is included for reference.**
+
+The Kraken X60 ("Kraken") motor is the primary motor 321 uses on the robot.
+Unlike many other motors, Krakens come with a built in motor controller called the Talon FX.
+The Kraken also has a built in encoder, or sensor that tracks the rotation and speed of the motor.
+This is a relative encoder, so we tend to pair them with CTRE CANcoders (which are absolute).
+More on encoders [below](#encoders).
+Documentation for the software to control Krakens can be found [here](https://pro.docs.ctr-electronics.com/en/stable/).
+There is also the Kraken X44, which is mostly the same as the X60 but a bit smaller and lighter.
+It looks the same in code to us, since it also has a TalonFX controller.
+
+
+
+We also use the Falcon 500 ("Falcon") motor in some places on the robot.
+Slightly less powerful, slightly older, and likely out of stock for the forseeable future, Falcons are slowly being phased out of our motor stock.
+Because Falcons also have an integrated TalonFX, they behave exactly the same in code as Krakens.
+A Falcon is pictured below.
+
+
+
+### Solenoids and Pneumatics
+
+
+
+Pneumatics are useful for simple, linear, and repeatable motions where motors might not be ideal.
+In the past we have used them primarily for extending intakes.
+If pneumatic pistons are like motors, solenoids are like motor controllers.
+A solenoid takes a control signal and uses it to switch incoming air into one of two output tubes to cause it to either extend or retract.
+We usually use double solenoids, which have both powered extension and retraction.
+Single solenoids only supply air for extension, and rely on the piston having a spring or something similar to retract them.
+Our mechanical team has moved somewhat away from pneumatics over weight and complexity concerns, but they may still appear on future robots.
+
+### Servos
+
+
+
+Servos are similar to motors in that they can produce rotational motion, but are designed for very precise rotation.
+Servos are somewhat more common in FTC than FRC, but are good for "single use" mechanisms or something that needs to go to a specific position.
+In 2025, we used 2 servos to open the funnel hatch panel in order to climb.
+
+### Robot Status Light
+
+
+
+The Robot Status Light (RSL) is an orange light we are required to have on our robot by competition rules.
+When the robot is powered on it will glow solid orange.
+When the robot is enabled ie being controlled by joysticks or autonomous code it will flash orange.
+This is handled automatically by WPILib.
+**When the robot is enabled wear safety glasses and do not go near the robot**.
+
+We have additional LEDs on the robot that indicate the state of the robot, but they are not standardized year to year and should not be relied upon for safety information.
+
+## Sensors
+
+### Encoders
+
+
+
+
+Encoders are devices that measure rotation.
+We use them to measure the angles of our swerve modules, the speed of our wheels, the position of our elevator, and much more.
+Relative encoders measure relative change in position (e.g. the shaft has rotated 30 degrees since powering on), while absolute encoders measure the exact position of the shaft (e.g. the shaft is 30 degrees from some absolute zero position).
+Modern motors have relative encoders built in.
+
+Absolute encoders are useful when they're measuring something that cannot rotate more than once, because they only return their position in a 0-360 degree range.
+This is well suited to mechanisms like arms, that usually can't rotate past 360 degrees without causing problems.
+However, motors are almost always geared down such that the motor rotates multiple times per rotation of the mechanism it is attached to, making the absolute data not so absolute.
+While this gearing is required to get enough torque from the motor, this is something to keep in mind when prototyping or looking at designs for mechanisms.
+If a mechanism has an absolute encoder, it should be rotating 1 or less rotations over the mechanism's range.
+If it is infeasible to have an encoder that goes 1 or less rotations for a mechanism, you might want to take a look at the next section, [Limit Switches](#limit-switches)
+
+Some examples of absolute encoders are the CTRE CANcoder (upper picture).
+The CANcoder sends absolute position and velocity data over the CAN network and uses a magnet embedded in the mechanism to keep track of position.
+We use these to track the heading of our swerve modules, as well as mechanisms like arms.
+
+The Rev Through Bore encoder (lower picture) solves the mounting problem by connecting directly to hex shaft (the most common type of shaft in FRC).
+However, the Through Bore does not communicate over CAN and requires wiring to the DIO ports.
+We used one of these on the hood of our 2022 robot.
+
+Some teams have seen success getting around the absolute encoder only having one rotation of usefullness by using [Chinese remainder theorem](https://en.wikipedia.org/wiki/Chinese_remainder_theorem) alongside multiple encoders.
+
+### Limit Switches
+
+
+
+A limit switch is a simple sensor that tells us whether a switch is pressed or not.
+They are one of the electrically simplest sensors we can use, and are quite useful as a way to reset the encoder on a mechanism ("Zero" the mechanism).
+They can also be used to set up safety limits for mechanisms so they don't damage themselves or others.
+They are quite fragile, however, so absolute encoders are better to be used where possible.
+We used a limit switch on our 2023 robot that was pressed when the elevator was fully retracted.
+When it was pressed, we knew that the elevator must be fully retracted so we could reset the encoder to 0 inches of extension.
+
+However, due to the fragility and additional wiring necessary for limit switches we have moved away from them.
+Instead, we use "current zeroing".
+This involves slowly powering a mechanism into a hardstop with a known position (like an elevator being all the way down).
+When the current draw of the motor spikes, we know that the motor is "stalling", or using power but not moving.
+This tells us that we are at the hardstop in the same way that a limit switch would.
+Think of it as walking towards a wall blindfolded with your hands outstretched- when you get to a point where you're not getting anywhere and are exerting a lot of force in front of you , you'll know you're at the wall.
+
+### IMU
+
+
+
+An Inertial Measurement Unit (IMU or sometimes Gyro) is a sensor that measures its acceleration and rotation.
+We primarily use them to measure the rotation of the robot (heading) so that the robot knows which way it is pointing on the field.
+This lets us run field-relative swerve drive.
+Pictured above is the Pigeon 2.0 IMU by CTRE, an IMU that connects over the CAN network.
+
+### Beambreaks/Light Sensors
+
+
+
+A beambreak has two parts: an emitter, which sends out a beam of infrared light, and a receiver, which is directly across from the emitter and receives that light.
+These are useful for when we need to detect if something like a game piece is present or not.
+If we mount the two parts on opposite sides of a mechanism, the game piece will block the light from reaching the other side and thus tell us that it's there.
+
+We might use an IR reflective sensor if we don't want to or can't add the receiver part, but this works in the same way by detecting when something's blocked the beam of light coming from the emitter.
+
+### Cameras and Vision
+
+
+
+Cameras and vision systems are an important part of advanced FRC software.
+Vision in FRC can be used to detect visual markers called AprilTags on the field, game pieces, and even other robots.
+The pictured camera is a Limelight camera, a purchaseable vision solution that connects to the robot over ethernet and we used from 2021-2023.
+
+However, we've moved towards custom hardware, such as [Arducam cameras](https://www.arducam.com/product/arducam-100fps-global-shutter-usb-camera-board-1mp-720p-ov9281-uvc-webcam-module-with-low-distortion-m12-lens-without-microphones-for-computer-laptop-android-device-and-raspberry-pi/) and [Orange Pi processors](http://www.orangepi.org/).
+The cameras plug into the USB ports on the Orange Pi.
+The Orange Pi connects to the radio over Ethernet,
+It's powered off the PDH with a buck/step down converter (which decreases voltage and increases current, since the Orange Pi only takes 5V and not 12).
+If you're having issues, check the PhotonVision docs pages on [networking](https://docs.photonvision.org/en/latest/docs/quick-start/networking.html) and [wiring](https://docs.photonvision.org/en/latest/docs/quick-start/wiring.html).
\ No newline at end of file
diff --git a/docs/basics/wpilib.md b/docs/basics/wpilib.md
index 0baae3f..5cacd9b 100644
--- a/docs/basics/wpilib.md
+++ b/docs/basics/wpilib.md
@@ -10,7 +10,8 @@ Making FRC Programming Easy
- There are classes to handle sensors, motor speed controllers, the driver station, and a number of other utility functions.
- Documentation is available at + * It is advised to statically import this class (or one of its inner classes) + * wherever the constants are needed, to reduce verbosity. + */ +public final class Constants { + // --8<-- [start: constants] + public static final class DriveConstants { + // Motor controller IDs for drivetrain motors + public static final int LEFT_LEADER_ID = 1; + public static final int LEFT_FOLLOWER_ID = 2; + public static final int RIGHT_LEADER_ID = 3; + public static final int RIGHT_FOLLOWER_ID = 4; + + // Current limit for drivetrain motors. 60A is a reasonable maximum to reduce + // likelihood of tripping breakers or damaging CIM motors + public static final int DRIVE_MOTOR_CURRENT_LIMIT = 60; + } + //--8<-- [end: constants] + + public static final class FuelConstants { + // Motor controller IDs for Fuel Mechanism motors + public static final int FEEDER_MOTOR_ID = 6; + public static final int INTAKE_LAUNCHER_MOTOR_ID = 5; + + // Current limit and nominal voltage for fuel mechanism motors. + public static final int FEEDER_MOTOR_CURRENT_LIMIT = 60; + public static final int LAUNCHER_MOTOR_CURRENT_LIMIT = 60; + + // Voltage values for various fuel operations. These values may need to be tuned + // based on exact robot construction. + // See the Software Guide for tuning information + public static final double INTAKING_FEEDER_VOLTAGE = -12; + public static final double INTAKING_INTAKE_VOLTAGE = 10; + public static final double LAUNCHING_FEEDER_VOLTAGE = 9; + public static final double LAUNCHING_LAUNCHER_VOLTAGE = 10.6; + public static final double SPIN_UP_FEEDER_VOLTAGE = -6; + public static final double SPIN_UP_SECONDS = 1; + } + + public static final class OperatorConstants { + // Port constants for driver and operator controllers. These should match the + // values in the Joystick tab of the Driver Station software + public static final int DRIVER_CONTROLLER_PORT = 0; + public static final int OPERATOR_CONTROLLER_PORT = 1; + + // This value is multiplied by the joystick value when driving the robot to + // help avoid driving and turning too fast and being difficult to control + public static final double DRIVE_SCALING = .7; + public static final double ROTATION_SCALING = .8; + } +} diff --git a/docs/code_examples/2026KitBotInline/Main.java b/docs/code_examples/2026KitBotInline/Main.java new file mode 100644 index 0000000..8776e5d --- /dev/null +++ b/docs/code_examples/2026KitBotInline/Main.java @@ -0,0 +1,25 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +package frc.robot; + +import edu.wpi.first.wpilibj.RobotBase; + +/** + * Do NOT add any static variables to this class, or any initialization at all. Unless you know what + * you are doing, do not modify this file except to change the parameter class to the startRobot + * call. + */ +public final class Main { + private Main() {} + + /** + * Main initialization function. Do not perform any initialization here. + * + *
If you change your main robot class, change the parameter type. + */ + public static void main(String... args) { + RobotBase.startRobot(Robot::new); + } +} diff --git a/docs/code_examples/2026KitBotInline/Robot.java b/docs/code_examples/2026KitBotInline/Robot.java new file mode 100644 index 0000000..9fddd29 --- /dev/null +++ b/docs/code_examples/2026KitBotInline/Robot.java @@ -0,0 +1,130 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +package frc.robot; + +import edu.wpi.first.hal.HAL; +import edu.wpi.first.hal.FRCNetComm.tResourceType; +import edu.wpi.first.wpilibj.TimedRobot; +import edu.wpi.first.wpilibj2.command.Command; +import edu.wpi.first.wpilibj2.command.CommandScheduler; +import edu.wpi.first.wpilibj2.command.button.CommandGenericHID; + +/** + * The VM is configured to automatically run this class, and to call the + * functions corresponding to + * each mode, as described in the TimedRobot documentation. If you change the + * name of this class or + * the package after creating this project, you must also update the + * build.gradle file in the + * project. + */ +public class Robot extends TimedRobot { + private Command m_autonomousCommand; + + private RobotContainer m_robotContainer; + + /** + * This function is run when the robot is first started up and should be used + * for any + * initialization code. + */ + @Override + public void robotInit() { + // Instantiate our RobotContainer. This will perform all our button bindings, + // and put our + // autonomous chooser on the dashboard. + m_robotContainer = new RobotContainer(); + + // Used to track usage of Kitbot code, please do not remove. + HAL.report(tResourceType.kResourceType_Framework, 10); + } + + /** + * This function is called every 20 ms, no matter the mode. Use this for items + * like diagnostics + * that you want ran during disabled, autonomous, teleoperated and test. + * + *
+ * This runs after the mode specific periodic functions, but before LiveWindow
+ * and
+ * SmartDashboard integrated updating.
+ */
+ @Override
+ public void robotPeriodic() {
+ // Runs the Scheduler. This is responsible for polling buttons, adding
+ // newly-scheduled
+ // commands, running already-scheduled commands, removing finished or
+ // interrupted commands,
+ // and running subsystem periodic() methods. This must be called from the
+ // robot's periodic
+ // block in order for anything in the Command-based framework to work.
+ CommandScheduler.getInstance().run();
+ }
+
+ /** This function is called once each time the robot enters Disabled mode. */
+ @Override
+ public void disabledInit() {
+ }
+
+ @Override
+ public void disabledPeriodic() {
+ }
+
+ /**
+ * This autonomous runs the autonomous command selected by your
+ * {@link RobotContainer} class.
+ */
+ @Override
+ public void autonomousInit() {
+ m_autonomousCommand = m_robotContainer.getAutonomousCommand();
+
+ // schedule the autonomous command (example)
+ if (m_autonomousCommand != null) {
+ CommandScheduler.getInstance().schedule(m_autonomousCommand);;
+ }
+ }
+
+ /** This function is called periodically during autonomous. */
+ @Override
+ public void autonomousPeriodic() {
+ }
+
+ @Override
+ public void teleopInit() {
+ // This makes sure that the autonomous stops running when
+ // teleop starts running. If you want the autonomous to
+ // continue until interrupted by another command, remove
+ // this line or comment it out.
+ if (m_autonomousCommand != null) {
+ m_autonomousCommand.cancel();
+ }
+ }
+
+ /** This function is called periodically during operator control. */
+ @Override
+ public void teleopPeriodic() {
+ }
+
+ @Override
+ public void testInit() {
+ // Cancels all running commands at the start of test mode.
+ CommandScheduler.getInstance().cancelAll();
+ }
+
+ /** This function is called periodically during test mode. */
+ @Override
+ public void testPeriodic() {
+ }
+
+ /** This function is called once when the robot is first started up. */
+ @Override
+ public void simulationInit() {
+ }
+
+ /** This function is called periodically whilst in simulation. */
+ @Override
+ public void simulationPeriodic() {
+ }
+}
diff --git a/docs/code_examples/2026KitBotInline/RobotContainer.java b/docs/code_examples/2026KitBotInline/RobotContainer.java
new file mode 100644
index 0000000..6600d8b
--- /dev/null
+++ b/docs/code_examples/2026KitBotInline/RobotContainer.java
@@ -0,0 +1,102 @@
+// Copyright (c) FIRST and other WPILib contributors.
+// Open Source Software; you can modify and/or share it under the terms of
+// the WPILib BSD license file in the root directory of this project.
+
+package frc.robot;
+
+import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
+import edu.wpi.first.wpilibj2.command.Command;
+import edu.wpi.first.wpilibj2.command.button.CommandXboxController;
+import edu.wpi.first.wpilibj2.command.button.Trigger;
+
+import static frc.robot.Constants.OperatorConstants.*;
+import static frc.robot.Constants.FuelConstants.*;
+import frc.robot.commands.Autos;
+import frc.robot.subsystems.CANDriveSubsystem;
+import frc.robot.subsystems.CANFuelSubsystem;
+
+/**
+ * This class is where the bulk of the robot should be declared. Since
+ * Command-based is a "declarative" paradigm, very little robot logic should
+ * actually be handled in the {@link Robot} periodic methods (other than the
+ * scheduler calls). Instead, the structure of the robot (including subsystems,
+ * commands, and trigger mappings) should be declared here.
+ */
+public class RobotContainer {
+ // The robot's subsystems
+ private final CANDriveSubsystem driveSubsystem = new CANDriveSubsystem();
+ private final CANFuelSubsystem ballSubsystem = new CANFuelSubsystem();
+
+ // The driver's controller
+ private final CommandXboxController driverController = new CommandXboxController(
+ DRIVER_CONTROLLER_PORT);
+
+ // The operator's controller
+ private final CommandXboxController operatorController = new CommandXboxController(
+ OPERATOR_CONTROLLER_PORT);
+
+ // The autonomous chooser
+ private final SendableChooser
+
+This example will cover how the code for an intake such as the one above might be set up.
+
+```mermaid
+flowchart TD
+ subgraph Subsystem
+ A[IntakeSubsystem]
+ end
+ Subsystem-->IO
+ subgraph IO
+ direction LR
+ B[IntakeIO]-->E[IntakeIOInputs]
+ end
+ IO-->IOImpl
+ subgraph IOImpl
+ C[IntakeIOReal]
+ D[IntakeIOSim]
+ end
+```
+
+Let's start by defining the methods in the `IntakeIO` interface.
+There are two motors on this slapdown intake--one that controls the pivot, and one that controls the rollers.
+The intake needs to set its position (extended or retracted), so we will need a `setAngle(Rotation2d angle)` method.
+We will also need a way to set the rollers' output, so let's add a `setRollerVoltage(double volts)` method.
+For convenience, let's add a method `stop()` that calls `setRollerVoltage()` with a voltage of 0.
+
+We also need to add our `IntakeIOInputs` to the `IntakeIO` file.
+This should contain all of the sensor information we need to know about our intake so that we can debug its behaviour with logs.
+Then we can add our logged fields for the motor.
+
+Here is a list of common logged fields for motors:
+
+- Velocity (Often but not always in rotations per second)
+ - This is the main field we care about to see if the motor is moving.
+- Current draw (Amps)
+ - This lets us see if the motor is stalling (trying to move but stuck) as well as how much energy the motor is using.
+- Temperature (Celsius)
+ - If a motor gets too hot it will turn itself off to protect its electronics.
+ This lets us see if we are having issues related to that.
+ In addition, motors are less efficient as they heat up.
+- Voltage (Voltage)
+ - This lets us see how much we are commanding our motors to move.
+- Position (Rotations or inches, often after a gear reduction)
+ - This lets us track the position of the motor and its corresponding mechanism.
+
+We can add all of these values into our `IntakeIOInputs` class.
+
+Finally, add a `updateInputs(IntakeIOInputs inputs)` method that our `IOImplementation`s can call to record these values.
+Our `IntakeIO` file should look something like this now:
+
+```Java
+// Imports go here
+
+public interface IntakeIO {
+ @AutoLog
+ public class IntakeIOInputs {
+
+ // Pivot motor values
+ public double pivotVelocityRotationsPerSec;
+ public double pivotCurrentDrawAmps;
+ public double pivotTemperatureCelsius;
+ public double pivotVoltage;
+ public Rotation2d pivotMotorPosition;
+
+ // Roller motor values
+ public double rollerVelocityRotationsPerSec;
+ public double rollerCurrentDrawAmps;
+ public double rollerTemperatureCelsius;
+ public double rollerVoltage;
+ }
+
+ // Methods that IOImplementations will implement
+ public void setAngle(Rotation2d angle);
+
+ public void setRollerVoltage(double volts);
+
+ // Note the use of "default"
+ // This means that we don't have to re-implement this method in each IOImplementation, because it will default to
+ // whatever the specific implementation of setVoltage() is
+ public default void stop() {
+ setRollerVoltage(0);
+ }
+
+ public void updateInputs(IntakeIOInputs inputs);
+}
+```
+
+Next, let's write `IntakeIOReal`.
+This will contain all of the hardware we want to interact with on the real robot.
+
+First, we will need to define the hardware we want to use.
+In this case, they will be two `TalonFX`s.
+
+```Java
+private final TalonFX pivot = new TalonFX(IntakeSubsystem.PIVOT_MOTOR_ID);
+private final TalonFX roller = new TalonFX(IntakeSubsystem.ROLLER_MOTOR_ID);
+```
+
+Next we will need to implement each of the methods from `IntakeIO`.
+Each should `@Override` the template method.
+For the sake of brevity, I won't cover that in detail here. *MAKE SUBSYSTEM WALKTHROUGH AND LINK HERE*
+
+In the end you should have something like:
+
+```Java
+public class IntakeIOReal implements IntakeIO {
+ private final TalonFX pivot = new TalonFX(IntakeSubsystem.PIVOT_MOTOR_ID);
+ private final TalonFX roller = new TalonFX(IntakeSubsystem.ROLLER_MOTOR_ID);
+
+ @Override
+ public void updateInputs(IntakeIOInputs inputs) {
+ // Note that the exact calls here are just examples, and might not work if copy-pasted
+
+ inputs.pivotVelocityRotationsPerSec = pivot.getVelocity();
+ inputs.pivotCurrentDrawAmps = pivot.getStatorCurrent();
+ inputs.pivotTemperatureCelsius = pivot.getDeviceTemp();
+ inputs.pivotVoltage = pivot.getMotorVoltage();
+ inputs.pivotMotorPosition = pivot.getMotorPosition();
+
+ // Roller motor values
+ inputs.rollerVelocityRotationsPerSec = roller.getVelocity();
+ inputs.rollerCurrentDrawAmps = roller.getStatorCurrent();
+ inputs.rollerTemperatureCelsius = roller.getDeviceTemp();
+ inputs.rollerVoltage = roller.getMotorVoltage();
+ }
+
+ @Override
+ public void setRollerVoltage(double volts) {
+ roller.setVoltage(volts);
+ }
+
+ // Note how we don't need to define stop() because it has a default implementation that does what we want
+
+ @Override
+ public void setAngle(Rotation2d angle) {
+ pivot.setAngle(angle);
+ }
+}
+```
+
+We can make a similar class for `IntakeIOSim`, although instead of getting motor outputs directly we would have to use `motor.getSimState()`.
+For more information about that, check the [CTRE docs](https://pro.docs.ctr-electronics.com/en/stable/docs/api-reference/simulation/simulation-intro.html).
+
+Finally, let's write the `IntakeSubsystem` class.
+This class will include an instance of `IntakeIO` and an instance of `IntakeIOInputs`.
+It will also contain Command factories to allow the rest of our code to interface with it.
+
+Add the io and io inputs to the class:
+
+```Java
+// Snip imports
+
+public class IntakeSubsystem extends SubsystemBase {
+ private final IntakeIO io;
+ private final IntakeIOInputsAutoLogged inputs = new IntakeIOInputsAutoLogged();
+
+ public IntakeSubsystem(IntakeIO io) {
+ // Pass in either the sim io or real io
+ this.io = io;
+ }
+}
+```
+
+Then we can add a few Command factories to control the subsystem:
+
+```Java
+public Command intake(double volts) {
+ return Commands.run(() -> {
+ io.setAngle(INTAKE_ANGLE);
+ io.setRollerVoltage(volts);
+ });
+}
+
+public Command stop() {
+ return Commands.runOnce(() -> {
+ io.setAngle(RETRACTED_ANGLE);
+ io.stop();
+ });
+}
+```
+
+Finally, let's add our `periodic()` method to update and log our inputs.
+
+```Java
+@Override
+public void periodic() {
+ io.updateInputs();
+ // Make sure to import the "littletonRobotics" Logger, not one of the other ones.
+ Logger.processInputs("Intake", inputs);
+}
+```
+
+Overall, `IntakeSubsystem` should roughly look like:
+
+```Java
+// Snip imports
+
+public class IntakeSubsystem extends SubsystemBase {
+ IntakeIO io;
+ IntakeIOInputsAutoLogged inputs;
+
+ public IntakeSubsystem(IntakeIO io) {
+ // Pass in either the sim io or real io
+ this.io = io;
+ inputs = new IntakeIOInputsAutoLogged();
+ }
+
+ public Command intake(double volts) {
+ return Commands.run(() -> {
+ io.setAngle(INTAKE_ANGLE);
+ io.setRollerVoltage(volts);
+ });
+ }
+
+ public Command stop() {
+ return Commands.runOnce(() -> {
+ io.setAngle(RETRACTED_ANGLE);
+ io.stop();
+ });
+ }
+
+ @Override
+ public void periodic() {
+ io.updateInputs();
+ // Make sure to import the "littletonRobotics" Logger, not one of the other ones.
+ Logger.processInputs("Intake", inputs);
+ }
+}
+```
+
+### More complex subsystems
+
+The intake is a very simple to program subsystem, but more complex ones exist.
+A swerve drive might have the following set of classes:
+
+```mermaid
+flowchart TD
+ subgraph Subsystem
+ A[SwerveSubsystem]
+ end
+
+ Subsystem--- 4x -->SwerveModuleIO
+ subgraph SwerveModuleIO
+ direction LR
+ B[SwerveModuleIO]-->E[SwerveModuleIOInputs]
+ end
+ SwerveModuleIO-->SwerveModuleIOImpl
+ subgraph SwerveModuleIOImpl
+ C[SwerveModuleIOReal]
+ D[SwerveModuleIOSim]
+ end
+
+ Subsystem--->GyroIO
+ subgraph GyroIO
+ direction LR
+ X[GyroIO]-->GyroIOInputs
+ end
+ GyroIO-->GyroIOImpl
+ subgraph GyroIOImpl
+ GyroIOReal
+ GyroIOSim
+ end
+```
+
+This means that we will have one `SwerveSubsystem` class.
+Within that class, we will have 4 instances of `SwerveModuleIO` and its corresponding `SwerveModuleIOInputs`, one for each module.
+We will also have an instance of `GyroIO` and `GyroIOInputs`.
+The `SwerveSubsystem` file handles coordinating and combining data from these `IO`s, and each `IO` handles turning the control signals from the `Subsystem` into motion in the hardware (or sim!).
diff --git a/docs/programming/AdvantageKit.md b/docs/programming/AdvantageKit.md
new file mode 100644
index 0000000..9e122f9
--- /dev/null
+++ b/docs/programming/AdvantageKit.md
@@ -0,0 +1,61 @@
+
+
+# AdvantageKit
+
+## AdvantageKit is a logging framework developed by team 6328
+
+### What is logging?
+
+Logging is recording some or all of the state (such as the current values of variables, inputs and outputs, and what Commands are running) of the robot so that we can play it back later.
+
+### Why log?
+
+Logging helps with debugging by letting us see exactly what was happening to the robot and what it was doing when it broke.
+This is especially useful at competition, when we have limited time and testing ability to diagnose problems.
+For instance, at Houston 2023 we had an issue in our second quals match where our grabber stopped responding to input.
+Using the logs of that match, we saw that the sensor readings of the grabber had stopped responding, which suggested that the CAN bus to the grabber had broken.
+
+### Why AdvantageKit?
+
+AdvantageKit logs every input and output to and from the robot.
+This means we can perfectly recreate the state of the robot in the log or with a simulator.
+
+
+
+It also means that we can run the same inputs through modified code, and simulate how the robot would have responded.
+AdvantageKit calls this replay.
+One of the examples 6328 uses is when they used a log to diagnose an issue with the way they tracked vision targets, adjusted it, then used replay to confirm that the change would have produced the correct outputs with the same inputs.
+
+AdvantageKit is a mature and developed framework for this type of logging that should continue to be maintained for the foreseeable future.
+
+AdvantageKit is closely integrated with AdvantageScope, a log and sim viewer built by 6328.
+
+### Drawbacks
+
+Running this amount of logging has performance overhead on the rio, using valuable cpu time each loop.
+Logging also requires a non-insignificant architecture change to our codebase by using an IO layer under each of our subsystems.
+While this does require some additional effort to write subsystems, it also makes simulating subsystems easier so it is a worthwhile tradeoff.
+
+8033-specific usage of AdvantageKit features will be covered in more detail in the next couple of lessons.
+
+### Resources
+
+- [AdvantageKit docs](https://docs.advantagekit.org/)
+- [AdvantageKit repository](https://github.com/Mechanical-Advantage/AdvantageKit)
+- [AdvantageScope log viewer](https://github.com/Mechanical-Advantage/AdvantageScope)
+- [6328 logging talk](https://youtu.be/mmNJjKJG8mw)
+
+### Examples
+
+- [6328 2023 code](https://github.com/Mechanical-Advantage/RobotCode2023)
+- [3476 2023 code](https://github.com/FRC3476/FRC-2023)
+- [8033 2025 code](https://github.com/HighlanderRobotics/Reefscape)
+
+### Exercises
+
+- Follow this [tutorial](2.8_KitbotAKitRefactor.md) to add AdvantageKit to your kitbot code.
+
+### Notes
+
+- See the [AdvantageKit Structure Reference](2.7_AKitStructureReference.md) article for more on the IO layer structure
+- [Here](https://drive.google.com/drive/folders/1qNMZ7aYOGI31dQNAwt7rhFo97NR7mxtr) are some logs from our 2023-2024 season
diff --git a/docs/programming/autonomous.md b/docs/programming/autonomous.md
index bed8a88..d4ed7ae 100644
--- a/docs/programming/autonomous.md
+++ b/docs/programming/autonomous.md
@@ -4,7 +4,7 @@
## Overview
-In this section we will be going over
+In this section we will be going over:
1. Creating an autonomous command group
2. Using RobotPreferences to quickly change our autonomous values
@@ -20,26 +20,37 @@ In this section we will be going over
- An autonomous command is a command that is ran during "autonomous mode" under the **autonomousInit** method in **Robot.java**
- It could be a single **command** or a **command group**
-- It's especially helpful to have if you don't have any cameras to drive the robot during a
-"sandstorm" period (2019 game mechanic where the drivers couldn't see during the pre tele-op phase)
-- For this tutorial we will create an autonomous **command group** that makes the robot drive forward 5 feet, wait 5 seconds, and then pitch the shooter up during autonomous
+- It's especially helpful to have if you don't have any cameras to drive the robot during autonomous (rare, but does happen)
+- For this tutorial we will create a simple autonomous **command ** that makes the robot drive forward slightly.
## Creating Commands For Autonomous
- Since we can't control our robot during an autonomous command we will want to create commands that allow the robot to move independently of a driver
-## Creating the DriveDistance Command
+## Creating a basic Autonomous Command
!!! summary ""
- **1)** Create a new command called **DriveDistance**
+ **1)** Create a new command called **AutoCommand** using the `create new class/command` feature in Vscode.
+
!!! summary ""
**2)** Before the constructor create a **double** called **distance**
+ ```Java
+ private Double distance;
+ ```
- We will use this to tell the command to finish when the robot drives the inputted distance
+
+ **3)** Also create a **Timer** called `runtime`.
+
+ ```Java
+ private Time runTime;
+ ```
+
+ - This will be used to control how long the robot will move for.
!!! summary ""
- **3)** In the **DriveDistance** constructor add a **double** parameter called **inches**
+ **3)** In the **AutoCommand** constructor add a **DriveSubsystem** parameter called **driveSubsystem**
!!! summary ""
**4)** Inside type:
@@ -74,50 +85,42 @@ In this section we will be going over
```java
package frc.robot.commands;
- import edu.wpi.first.wpilibj.command.Command;
- import frc.robot.Robot;
+ import edu.wpi.first.wpilibj2.command.Command;
+ import frc.robot.subsystems.Drivetrain;
import frc.robot.RobotPreferences;
public class DriveDistance extends Command {
- private double distance;
+ private final Drivetrain drivetrain;
+ private final double distance;
- public DriveDistance(double inches) {
- // Use requires() here to declare subsystem dependencies
- // eg. requires(chassis);
- requires(Robot.m_drivetrain);
- distance = inches;
+ public DriveDistance(Drivetrain drivetrain, double inches) {
+ this.drivetrain = drivetrain;
+ this.distance = inches;
+ addRequirements(drivetrain);
}
- // Called just before this Command runs the first time
@Override
- protected void initialize() {
- Robot.m_drivetrain.resetDriveEncoder();
+ public void initialize() {
+ drivetrain.resetDriveEncoder();
}
// Called repeatedly when this Command is scheduled to run
@Override
- protected void execute() {
- Robot.m_drivetrain.arcadeDrive(RobotPreferences.driveDistanceSpeed(), 0.0);
+ public void execute() {
+ drivetrain.arcadeDrive(RobotPreferences.driveDistanceSpeed(), 0.0);
}
// Make this return true when this Command no longer needs to run execute()
@Override
- protected boolean isFinished() {
- return Robot.m_drivetrain.getDriveEncoderDistance() == distance;
+ public boolean isFinished() {
+ return drivetrain.getDriveEncoderDistance() >= distance;
}
// Called once after isFinished returns true
@Override
- protected void end() {
- Robot.m_drivetrain.arcadeDrive(0.0, 0.0);
- }
-
- // Called when another command which requires one or more of the same
- // subsystems is scheduled to run
- @Override
- protected void interrupted() {
- end();
+ public void end(boolean interrupted) {
+ drivetrain.arcadeDrive(0.0, 0.0);
}
}
```
diff --git a/docs/programming/driving_robot.md b/docs/programming/driving_robot.md
index 2158e0f..1cb2c77 100644
--- a/docs/programming/driving_robot.md
+++ b/docs/programming/driving_robot.md
@@ -23,138 +23,89 @@ Before we begin we must create the class file for the drivetrain subsystem. See
In the Drivetrain class we will tell the subsystem what type of components it will be using.
-- A Drivetrain needs motor controllers. In our case we will use 4 Talon SRs (a brand of controller for motors).
- - You could use other motor controllers such as Victor SPs or Talon SRXs but we will be using Talon SRs
- - If you are using other motor controllers, replace Talon with TalonSRX, Victor, or VictorSP in the code you write depending on the type you use.
+- A Drivetrain needs motor controllers. In our case we will use Neo SparkMaxes (a brand of controller for motors made by Rev Robotics).
+ - You could use other motor controllers such as Victor SPs or Talon SRs but we will be using NEO SparkMaxes
+ - If you are using other motor controllers, replace SparkMax with Talon, TalonSRX, Victor, or VictorSP in the code you write depending on the type you use.
- You can use 2 motors (left and right), but for this tutorial we will use 4.
-!!! Tip
- Be sure to read [Visual Studio Code Tips](../basics/vscode_tips.md){target=_blank} before getting started! It will make your life a lot easier.
+/// note | More Info
-### Creating the Talon Variables
+ Be sure to read [Visual Studio Code Tips](../basics/vscode_tips.md){target=_blank} before getting started! It will make your life a lot easier.
-!!! summary ""
- **1)** Create 4 global variables of data type **Talon** and name them: `leftFrontTalon`, `rightFrontTalon`, `leftBackTalon`, `rightBackTalon`
-
- - To get started type the word Talon followed by the name i.e. `#!java Talon leftFrontTalon;`
- - These will eventually hold the object values for Talons and their port numbers.
+///
-!!! summary ""
- **2)** Next assign their values to `#!java null` ([more info on `null`](../basics/java_basics.md#overview){target=_blank}).
-
- - We do this to make sure it is empty at this point.
- - When we assign these variables a value, we will be getting the motor controller's port numbers out of Constants
- - This means we cannot assign them at the global level
+### Creating the SparkMax Variables
-??? Example
- The code you typed should be this:
+**1)** Create 4 global variables of data type **SparkMax** and name them: `leftLeader`, `rightLeader`, `leftFollower`, `rightFollower`
- ```java
- Talon leftFrontTalon = null;
- Talon leftBackTalon = null;
- Talon rightFrontTalon = null;
- Talon rightBackTalon = null;
- ```
+- To get started type the word SparkMax followed by the name i.e. `#!java private Final SparkMax leftLeader;`
+- These will eventually hold the object values for SparkMaxes, their port numbers, and their motor type (brushed or brushless).
- Your full **Drivetrain.java** should look like this:
- ```java
- package frc.robot.subsystems;
-
- import edu.wpi.first.wpilibj.Talon;
- import edu.wpi.first.wpilibj.command.Subsystem;
-
- /**
- * Add your docs here.
- */
- public class Drivetrain extends Subsystem {
- // Put methods for controlling this subsystem
- // here. Call these from Commands.
-
- Talon leftFrontTalon = null;
- Talon leftBackTalon = null;
- Talon rightFrontTalon = null;
- Talon rightBackTalon = null;
-
- @Override
- public void periodic() {
- // This method will be called once per scheduler run
- }
- }
- ```
+**2)** These are declared without values right now.
+
+- We do this to make sure it is empty at this point.
+- When we assign these variables a value, we will be getting the motor controller's port numbers out of Constants
+ - This means we cannot assign them at the global level
+
+
+/// details | Example code
+
+**SparkMax Motor Member Variables:**
+
+```java title="DriveSubsystem.java"
+--8<-- "2026KitBotInline/subsystems/CANDriveSubsystem.java:motors"
+```
+
+///
+
-??? fail "If an error occurs (red squiggles)"
- 1. Click the word Talon
- 
- 2. 💡 Click the light bulb
- 
- 3. Select "Import 'Talon' (edu.wpi.first.wpilibj)"
- 
- 4. Your error should be gone!
+**If an error occurs (red squiggles)**
+
+1. Mouse Over the word SparkMax: The following menu should appear.
+
+
+2. 💡 Click "quick fix"
+
+
+3. Select "Import 'SparkMax' (com.revrobotics.spark)"
+
+
+4. Your error should be gone!
### Creating and filling the constructor
-!!! summary ""
- **1)** Create the constructor for Drivetrain.java ([more info on constructors](../basics/java_basics.md#constructors){target=_blank})
-
- - The constructor is where we will assign values to our talon variables.
+Now that we have created the SparkMaxes and the Drive Constants we must initialize them and tell them what port on the roboRIO they are on.
-!!! summary ""
- Now that we have created the Talons we must initialize them and tell them what port on the roboRIO they are on.
+**1)** Initialize (set value of) `leftLeader` to `#!java new SparkMax(LEFT_LEADER_ID, MotorType.kBrushless)`.
- **2)** Initialize (set value of) `leftFrontTalon` to `#!java new Talon(0)`.
-
- - This initializes a new talon, `leftFrontTalon`, in a new piece of memory and states it is on port 0 of the roboRIO.
- - This should be done within the constructor `#!java Drivetrain()`
- - This calls the constructor `#!java Talon(int)` in the Talon class.
- - The constructor `#!java Talon(int)` takes a variable of type `#!java int`. In this case the `#!java int` (integer) refers to the port number on the roboRIO.
-
- ??? Info "roboRIO port diagram"
- 
+- This initializes a new SparkMax, `leftLeader`, in a new piece of memory and states it is on the port defined by `LEFT_LEADER_ID`.
+- This should be done within the constructor `#!java Drivetrain()`
+- This calls the constructor `#!java SparkMax(int, MotorType)` in the SparkMax class.
+ - The constructor `#!java SparkMax(int, MotorType)` takes a variable of type `#!java int` for the CAN ID and `MotorType` for brushless or brushed. In this case the `#!java int` (integer) refers to the CAN ID on the roboRIO.
+
+ **roboRIO port diagram**
-??? Example
+
- The code you typed should be this:
- ```java
- public Drivetrain() {
- // Talons
- leftFrontTalon = new Talon(0);
- }
- ```
+/// details | Constructor Initialization Example
- Your full **Drivetrain.java** should look like this:
+```java title="Constructor declaration"
+public CANDriveSubSystem () {}
+```
- ```java
- package frc.robot.subsystems;
-
- import edu.wpi.first.wpilibj.Talon;
- import edu.wpi.first.wpilibj.command.Subsystem;
-
- /**
- * Add your docs here.
- */
- public class Drivetrain extends Subsystem {
- // Put methods for controlling this subsystem
- // here. Call these from Commands.
-
- Talon leftFrontTalon = null;
- Talon leftBackTalon = null;
- Talon rightFrontTalon = null;
- Talon rightBackTalon = null;
-
- public Drivetrain() {
- // Talons
- leftFrontTalon = new Talon(0);
- }
-
- @Override
- public void periodic() {
- // This method will be called once per scheduler run
- }
- ```
+**Full Constructor: **
+
+```java title="FUll Constructor"
+--8<-- "2026KitBotInline/subsystems/CANDriveSubsystem.java:constructor"
+```
+
+See [CANDriveSubsystem.java](../code_examples/2026KitBotInline/src/main/java/frc/robot/subsystems/CANDriveSubsystem.java) for the complete constructor implementation.
+
+///
### Using Constants
@@ -162,104 +113,91 @@ In the Drivetrain class we will tell the subsystem what type of components it wi
Since each subsystem has its own components with their own ports, it is easy to lose track of which ports are being used and for what. To counter this you can use a class called **Constants** to hold all these values in a single location.
-!!! summary ""
- **1)** To use Constants, instead of putting `0` for the port on the Talon type:
- ```java
- Constants.DRIVETRAIN_LEFT_FRONT_TALON
- ```
-
+
- Names should follow the pattern SUBSYSTEM_NAME_OF_COMPONENT
- The name is all caps since it is a **constant** ([more info on constants](../basics/java_basics.md#constants){target=_blank}).
-!!! summary ""
- **2)** Click on the underlined text
- 
-!!! summary ""
- **3)** Click on the 💡light bulb and select “create constant…”
- 
-
-!!! summary ""
- **4)** Click on Constants.java tab that just popped up
- 
-
-!!! summary ""
- **5)** Change the `0` to the correct port for that motor controller on your robot/roboRIO
- 
-
- !!! Danger
- ***If you set this to the wrong value, you could damage your robot when it tries to move!***
-
-!!! summary ""
- **6)** Repeat these steps for the remaining Talons.
- !!! Tip
- Remember to save both **Drivetrain.java** and **Constants.java**
+Before we initalize the SparkMax objects we are going to create constants to hold the CAN ID's of the motors. This will happen in constants.java
-??? Example
+- Inside the constants class, create a new class called `public static DriveConstants`.
+- Inside `DriveConstants` class, create for constants called `LEFT_LEADER_ID`, `LEFT_FOLLOWER_ID`, `RIGHT_LEADER_ID`, and `RIGHT_FOLLOWER_ID`.
+- Back in your `DriveTrain` class in `drivetrain.java`, import the `DriveConstants` class as follows: `Import frc.robot.Constants.DriveConstants;`.
- The code you type should be this:
+/// tip | Declaring Constants
+Make sure to declare constants with `public static final` so they cannot be changed at runtime.
+///
- ```java
- leftFrontTalon = new Talon(Constants.DRIVETRAIN_LEFT_FRONT_TALON);
- ```
+/// danger
+***If you set this to the wrong value, you could damage your robot when it tries to move!***
+///
+/// note
+To use Constants, instead of putting `0` for the port in the SparkMax type:
- Your full **Drivetrain.java** should look like this:
+```java title="constants.java"
+public static final int LEFT_LEADER_ID = 1;
+```
+///
- ```java
- package frc.robot.subsystems;
-
- import edu.wpi.first.wpilibj.Talon;
- import edu.wpi.first.wpilibj.command.Subsystem;
- import frc.robot.Constants;
-
- /**
- * Add your docs here.
- */
- public class Drivetrain extends Subsystem {
- // Put methods for controlling this subsystem
- // here. Call these from Commands.
-
- Talon leftFrontTalon = null;
- Talon leftBackTalon = null;
- Talon rightFrontTalon = null;
- Talon rightBackTalon = null;
-
- public Drivetrain() {
- // Talons
- leftFrontTalon = new Talon(Constants.DRIVETRAIN_LEFT_FRONT_TALON);
- leftBackTalon = new Talon(Constants.DRIVETRAIN_LEFT_BACK_TALON);
- rightFrontTalon = new Talon(Constants.DRIVETRAIN_RIGHT_FRONT_TALON);
- rightBackTalon = new Talon(Constants.DRIVETRAIN_RIGHT_BACK_TALON);
- }
-
- @Override
- public void periodic() {
- // This method will be called once per scheduler run
- }
- }
- ```
+/// note
+Replace the remaining numbers with constants.
+
+///
- Your full **Constants.java** should look similar to this:
+///Tip
- ```java
- package frc.robot;
-
- public class Constants {
- // Talons
- public static final int DRIVETRAIN_LEFT_FRONT_TALON = 0;
- public static final int DRIVETRAIN_LEFT_BACK_TALON = 1;
- public static final int DRIVETRAIN_RIGHT_FRONT_TALON = 2;
- public static final int DRIVETRAIN_RIGHT_BACK_TALON = 3;
- }
- ```
+Remember to save both **Drivetrain.java** and **Constants.java**
+
+///
+
+/// details | DriveConstants Example
+
+**Drive Constants Definition:**
+
+```java
+--8<-- "2026KitBotInline/Contants.java:constants"
+```
+
+///
+
+**Full Constants.java with all Robot Constants:**
- !!! Warning
- Remember to use the values for **YOUR** specific robot or you could risk damaging it!
+See [Constants.java](../code_examples/2026KitBotInline/Constants.java) for the complete constants file including OperatorConstants and other subsystem constants.
-### Creating the arcade drive
+!!! Warning
+ Remember to use the values for **YOUR** specific robot or you could risk damaging it!
-#### What is the Drive Class
+### Configuring the SparkMaxes
+
+**Setting CAN Timeout:**
+
+Each SparkMax motor must be configured with a CANTimeout. (How long to wait for a response from the motor controller)
+
+```Java
+// Set can timeout. Because this project only sets parameters once on
+// construction, the timeout can be long without blocking robot operation.
+leftLeader.setCANTimeout(250);
+rightLeader.setCANTimeout(250);
+leftFollower.setCANTimeout(250);
+rightFollower.setCANTimeout(250);
+```
+
+**Voltage Compensation and Current Limiting:**
+
+Create the configuration to apply to motors. Voltage compensation helps the robot perform more similarly on different battery voltages (at the cost of a little bit of top speed on a fully charged battery). The current limit helps prevent tripping breakers.
+
+```Java
+SparkMaxConfig config = new SparkMaxConfig();
+config.voltageCompensation(12);
+config.smartCurrentLimit(DriveConstants.DRIVE_MOTOR_CURRENT_LIMIT);
+```
+
+See [CANDriveSubsystem.java](../code_examples/2026KitBotInline/subsystems/CANDriveSubsystem.java) for the full configuration implementation in the constructor.
+
+## Creating the arcade drive
+
+### What is the Drive Class
- The FIRST Drive class has many pre-configured methods available to us including DifferentialDrive, and many alterations of MecanumDrive.
- DifferentialDrive contains subsections such as TankDrive and ArcadeDrive.
@@ -268,116 +206,76 @@ Since each subsystem has its own components with their own ports, it is easy to
- Arcade drives run by taking a moveSpeed and rotateSpeed. moveSpeed defines the forward and reverse speed and rotateSpeed defines the turning left and right speed.
- To create an arcade drive we will be using our already existing Drivetrain class and adding to it.
-#### Programing a RobotDrive
+### Programing a RobotDrive
!!! summary ""
- **1)** In the same place we created our talons (outside of the constructor) we will create a **DifferentialDrive** and **SpeedControllerGroups** for our left and right motor controllers.
+ **1)** Create the DifferentialDrive object.
- Outside of the constructor type:
-
- ```java
- SpeedControllerGroup leftMotors = null;
- SpeedControllerGroup rightMotors = null;
+ **Member Variable Declaration:**
+ ```java
+ private final DifferentialDrive drive;
+ ```
+ This defines the drive object that we will use to drive the robot.
- DifferentialDrive differentialDrive = null;
+ **Constructor Initialization:**
+ ```java
+ drive = new DifferentialDrive(leftLeader, rightLeader);
```
+ This initializes the differential drive object with the left and right leader motors.
- - Since DifferentialDrive only takes 2 parameters we need to create speed controller groups to combine like motor controllers together.
- - In this case we will combine the left motors together and the right motors together.
+ - Since DifferentialDrive takes 2 parameters we pass the left and right leader motors.
+ - The follower motors are configured to follow these leaders through the SparkMax configuration.
!!! Warning
You should only group motors that are spinning the same direction physically when positive power is being applied otherwise you could damage your robot.
-!!! summary ""
- **2)** Now we must initialize the **SpeedControllerGroups** and **DifferentialDrive** like we did our talons. ...
-
- In the constructor type:
-
- ```java
- leftMotors = new SpeedControllerGroup(leftFrontTalon, leftBackTalon);
- rightMotors = new SpeedControllerGroup(rightFrontTalon, rightBackTalon);
-
- differentialDrive = new DifferentialDrive(leftMotors, rightMotors);
+/// note
+ **2)** In order to configure the motors to drive correctly, we need to configure one on each side as the leader and one as the follower.
+ In the constructor we are going to set the follower motors and link them to the leader motors. To do this we will need to include a couple more classes from the REV Library:
+ ```Java
+ import com.revrobotics.spark.SparkBase.PersistMode;
+ import com.revrobotics.spark.SparkBase.ResetMode;
```
-
-??? Example
-
- The code you type outside the constructor should be this:
-
- ```java
- SpeedControllerGroup leftMotors = null;
- SpeedControllerGroup rightMotors = null;
+ Then in the constructor, configure the followers to follow the leaders:
- DifferentialDrive differentialDrive = null;
+ **Set follower configuration:**
+ ```Java
+ config.follow(leftLeader);
+ leftFollower.configure(config, ResetMode.kResetSafeParameters, PersistMode.kPersistParameters);
+ config.follow(rightLeader);
+ rightFollower.configure(config, ResetMode.kResetSafeParameters, PersistMode.kPersistParameters);
```
- The code you type inside the constructor should be this:
-
- ```java
- leftMotors = new SpeedControllerGroup(leftFrontTalon, leftBackTalon);
- rightMotors = new SpeedControllerGroup(rightFrontTalon, rightBackTalon);
+ **Configure right leader:**
+ ```Java
+ config.disableFollowerMode();
+ rightLeader.configure(config, ResetMode.kResetSafeParameters, PersistMode.kPersistParameters);
+ ```
- differentialDrive = new DifferentialDrive(leftMotors, rightMotors);
+ **Invert left leader for correct motor direction:**
+ ```Java
+ config.inverted(true);
+ leftLeader.configure(config, ResetMode.kResetSafeParameters, PersistMode.kPersistParameters);
```
- Your full **Drivetrain.java** should look like this:
+///
- ```java
- package frc.robot.subsystems;
-
- import edu.wpi.first.wpilibj.SpeedControllerGroup;
- import edu.wpi.first.wpilibj.Talon;
- import edu.wpi.first.wpilibj.command.Subsystem;
- import edu.wpi.first.wpilibj.drive.DifferentialDrive;
- import frc.robot.Constants;
-
- /**
- * Add your docs here.
- */
- public class Drivetrain extends Subsystem {
- // Put methods for controlling this subsystem
- // here. Call these from Commands.
-
- Talon leftFrontTalon = null;
- Talon leftBackTalon = null;
- Talon rightFrontTalon = null;
- Talon rightBackTalon = null;
-
- SpeedControllerGroup leftMotors = null;
- SpeedControllerGroup rightMotors = null;
-
- DifferentialDrive differentialDrive = null;
-
- public Drivetrain() {
- // Talons
- leftFrontTalon = new Talon(Constants.DRIVETRAIN_LEFT_FRONT_TALON);
- leftBackTalon = new Talon(Constants.DRIVETRAIN_LEFT_BACK_TALON);
- rightFrontTalon = new Talon(Constants.DRIVETRAIN_RIGHT_FRONT_TALON);
- rightBackTalon = new Talon(Constants.DRIVETRAIN_RIGHT_BACK_TALON);
-
- leftMotors = new SpeedControllerGroup(leftFrontTalon, leftBackTalon);
- rightMotors = new SpeedControllerGroup(rightFrontTalon, rightBackTalon);
-
- differentialDrive = new DifferentialDrive(leftMotors, rightMotors);
- }
-
- @Override
- public void periodic() {
- // This method will be called once per scheduler run
- }
- }
- ```
+/// details | Full Drive Subsystem Example
+
+See [CANDriveSubsystem.java](../code_examples/2026KitBotInline/src/main/java/frc/robot/subsystems/CANDriveSubsystem.java) for the complete implementation with all motor configuration and initialization.
-#### Creating the arcadeDrive method
+///
+
+### Creating the arcadeDrive method
Now it’s time to make an arcadeDrive from our differentialDrive!
-!!! summary ""
+!!! abstract
**1)** Let’s create a public void method called “arcadeDrive” with type “double” parameters moveSpeed and rotateSpeed.
- Below the constructor type:
+ Below the `periodic` method create a new method called `arcadeDrive`. This method will be called from our Drive command to actually move the robot.
```java
public void arcadeDrive(double moveSpeed, double rotateSpeed) {
@@ -388,13 +286,13 @@ Now it’s time to make an arcadeDrive from our differentialDrive!
!!! Tip
By putting something in the parentheses it makes the method require a parameter when it is used. When the method gets used and parameters are passed, they will be store in moveSpeed and rotateSpeed (in that order). See [parameters](../basics/java_basics.md#parameters){target=_blank} for more info.
-!!! summary ""
+!!! abstract ""
**2)** Now lets make our method call the differentialDrive's arcadeDrive method.
Inside our method type:
- ```java
- differentialDrive.arcadeDrive(moveSpeed, rotateSpeed);
+ ```Java
+ drive.arcadeDrive(moveSpeed, rotateSpeed);
```
DifferentialDrive's arcadeDrive method takes parameters moveValue and rotateValue.
@@ -408,139 +306,34 @@ Now it’s time to make an arcadeDrive from our differentialDrive!
You may want to do this for initial testing to make sure everything is going the right direction.
-??? Example
+// details | Drive Arcade Method Example
- The code you type should be this:
+**Simple Arcade Drive Method:**
- ```java
- public void arcadeDrive(double moveSpeed, double rotateSpeed) {
- differentialDrive.arcadeDrive(moveSpeed, rotateSpeed);
- }
- ```
-
- Your full **Drivetrain.java** should look like this:
+```Java
+public void arcadeDrive(double moveSpeed, double rotateSpeed) {
+ drive.arcadeDrive(moveSpeed, rotateSpeed);
+}
+```
- ```java
- package frc.robot.subsystems;
-
- import edu.wpi.first.wpilibj.SpeedControllerGroup;
- import edu.wpi.first.wpilibj.Talon;
- import edu.wpi.first.wpilibj.command.Subsystem;
- import edu.wpi.first.wpilibj.drive.DifferentialDrive;
- import frc.robot.Constants;
-
- /**
- * Add your docs here.
- */
- public class Drivetrain extends Subsystem {
- // Put methods for controlling this subsystem
- // here. Call these from Commands.
-
- Talon leftFrontTalon = null;
- Talon leftBackTalon = null;
- Talon rightFrontTalon = null;
- Talon rightBackTalon = null;
-
- SpeedControllerGroup leftMotors = null;
- SpeedControllerGroup rightMotors = null;
-
- DifferentialDrive differentialDrive = null;
-
- public Drivetrain() {
- // Talons
- leftFrontTalon = new Talon(Constants.DRIVETRAIN_LEFT_FRONT_TALON);
- leftBackTalon = new Talon(Constants.DRIVETRAIN_LEFT_BACK_TALON);
- rightFrontTalon = new Talon(Constants.DRIVETRAIN_RIGHT_FRONT_TALON);
- rightBackTalon = new Talon(Constants.DRIVETRAIN_RIGHT_BACK_TALON);
-
- leftMotors = new SpeedControllerGroup(leftFrontTalon, leftBackTalon);
- rightMotors = new SpeedControllerGroup(rightFrontTalon, rightBackTalon);
-
- differentialDrive = new DifferentialDrive(leftMotors, rightMotors);
- }
-
- public void arcadeDrive(double moveSpeed, double rotateSpeed) {
- differentialDrive.arcadeDrive(moveSpeed, rotateSpeed);
- }
-
- @Override
- public void periodic() {
- // This method will be called once per scheduler run
- }
- }
- ```
+**Modern Command Factory Pattern:**
-***
+In newer WPILib code, you can use a command factory method instead:
-## Making our robot controllable
+```Java
+public Command driveArcade(DoubleSupplier xSpeed, DoubleSupplier zRotation) {
+ return this.run(
+ () -> drive.arcadeDrive(xSpeed.getAsDouble(), zRotation.getAsDouble()));
+}
+```
-### Creating the Joystick
+See [CANDriveSubsystem.java](../code_examples/2026KitBotInline/src/main/java/frc/robot/subsystems/CANDriveSubsystem.java) for the complete implementation using the command factory pattern.
-In order to drive our robot, it needs to know what will be controlling it. To do so, we will create a new joystick in RobotContainer.java
+///
-!!! summary ""
- **1)** Open RobotContainer.java
-
- **2)** Type:
- ```java
- public Joystick driverController = new Joystick(Constants.DRIVER_CONTROLLER);
- ```
-
-
-
- - Import any classes if necessary such as: `#!java import edu.wpi.first.wpilibj.Joystick;`
- - A variable `driverController` of type Joystick pointing to a joystick on port `DRIVER_CONTROLLER` from **Constants**
-
- **3)** Click the 💡 light bulb to create a new **CONSTANT** and set the value to the port number the joystick uses on the laptop (this can be found in the Driverstation software).
+### Making our robot controllable
-
-
-??? Example
-
- The code you type should be this:
-
- ```java
- public Joystick driverController = new Joystick(Constants.DRIVER_CONTROLLER);
- ```
-
- Your full **RobotContainer.java** should look like this:
-
- ```java
- package frc.robot;
-
- import edu.wpi.first.wpilibj.Joystick;
-
- /**
- * This class is where the bulk of the robot should be declared. Since
- * Command-based is a "declarative" paradigm, very little robot logic should
- * actually be handled in the {@link Robot} periodic methods (other than the
- * scheduler calls). Instead, the structure of the robot (including subsystems,
- * commands, and button mappings) should be declared here.
- */
- public class RobotContainer {
- // The robot's subsystems and commands are defined here...
- public Joystick driverController = new Joystick(Constants.DRIVER_CONTROLLER);
- }
- ```
-
- Your full **Constants.java** should look similar to this:
-
- ```java
- package frc.robot;
-
- public class Constants {
- // Talons
- public static final int DRIVETRAIN_LEFT_FRONT_TALON = 0;
- public static final int DRIVETRAIN_LEFT_BACK_TALON = 1;
- public static final int DRIVETRAIN_RIGHT_FRONT_TALON = 2;
- public static final int DRIVETRAIN_RIGHT_BACK_TALON = 3;
-
- // Joysticks
- public static final int DRIVER_CONTROLLER = 0;
- }
- ```
-
-### Creating the DriveArcade Command
+## Creating the Drivearcade Command
- Remember that **methods** tell the robot what it can do but in order to make it do these things we must give it a **command**. See [Command Based Robot](../basics/wpilib.md#command-based-robot){target=_blank}
- Now that we have created the method, we need to create a command to call and use that method.
@@ -548,51 +341,68 @@ In order to drive our robot, it needs to know what will be controlling it. To do
Before we begin we must create the class file for the DriveArcade command. See [Creating a New Command](new_project.md#creating-a-new-command){target=_blank} for info on how to do this and info on what each pre-created method does.
-#### In the constructor
+### Define variables
!!! summary ""
- **1)** In the constructor `#!java DriveArcade()` type:
-
- ```java
- addRequirements(RobotContainer.m_drivetrain);
- ```
-
- - This means, this command will end all other commands currently using drivetrain and will run instead when executed.
- - It also means, other commands that require drivetrain will stop this command and run instead when executed.
+ **1)** Create `xspeed` and `zrotation` variables. (to be passed to drive subsystem). These will be declared as `DoubleSuppliers`, which is a function that return a type. This is important for later.
+ **2)** Create an emtpy `driveSubsystem` instance of `Drivetrain`
!!! Warning
- If you use the light bulb to import ‘Robot', be sure to import the one with “frc.robot”
+ `DoubleSupplier` and `Drivetrain` will have to be imported as follows:
+ ```Java
+ import frc.robot.subsystems.Drivetrain;
+ import java.util.function.DoubleSupplier;
+ ```
+
+ ```Java
+ private final DoubleSupplier xSpeed;
+ private final DoubleSupplier zRotation;
+ private final Drivetrain driveSubsystem;
+ ```
-#### In the execute method
+### In the constructor
!!! summary ""
- **1)** In the execute method we will create 2 variables of type double called moveSpeed and rotateSpeed.
-
- - We want these variables to be the value of the axis of the controller we are using to drive the robot. So we will set them equal to that by using the joystick getRawAxis method.
- - Controllers return an axis value between 1 and -1 to indicate how far the joystick is pushed up or down. Our personal controller returns up as -1 so we want to invert it.
- - In Java you can put a negative “ - “in front of a numeric value to invert it (value * -1)
- - The joystick’s getRawAxis method will get the position value of the axis as you move it. The method takes parameter “axis number.” (This can be found in the Driverstation software and we will store it in Constants).
+ **1)** Inside the parenthesis of the the constructor `arcadeDrive()` add 3 variables:
+ ```Java
+ public DriveArcade(
+ DoubleSupplier xSpeed, DoubleSupplier zRotation, Drivetrain driveSubsystem)
+ ```
+ These are values that will be passed into the command in `RobotContainer.java`
- In the execute() method type:
+!!! summary ""
+ **2)** Inside constructor `#!java DriveArcade()` type:
```java
- double moveSpeed = -RobotContainer.driverController.getRawAxis(Constants.DRIVER_CONTROLLER_MOVE_AXIS);
- double rotateSpeed = RobotContainer.driverController.getRawAxis(Constants.DRIVER_CONTROLLER_ROTATE_AXIS);
+ this.xSpeed = xSpeed;
+ this.zRotation = zRotation;
+ this.driveSubsystem = driveSubsystem;
+ addRequirements(this.drivetrain);
```
-
+
+ - The 3 lines starting with `this` set the global variables we defined at the top of our class file to the values being passed into the consturctor.
!!! Tip
- Remember to use the light bulb for importing and creating constants if needed!
+ `this` is how the class instance `object` refers to itself in code.
+
+!!! summary ""
+ - `addRequirements` means this command will end all other commands currently using drivetrain and will run instead when executed.
+ - It also means, other commands that require drivetrain will stop this command and run instead when executed.
+
+ !!! Warning
+ If you use the light bulb to import ‘Robot', be sure to import the one with “frc.robot”
+
+### In the execute method
!!! summary ""
- **2)** Also in the execute method we will we want to call the **arcadeDrive** method we created in **Drivetrain** and give it the variables **moveSpeed** and **rotateSpeed** we created as parameters.
+ **1)** In the execute method we will we want to call the **arcadeDrive** method we created in **Drivetrain** and give it the variables **moveSpeed** `xspeed` and **rotateSpeed** `zrotation` we created as parameters.
In the execute() method below rotateSpeed type:
- ```java
- RobotContainer.m_drivetrain.arcadeDrive(moveSpeed, rotateSpeed);
+ ```Java
+ driveSubsystem.arcadeDrive(xSpeed.getAsDouble(), zRotation.getAsDouble());
```
-#### In the isFinished method
+### In the isFinished method
Since we will be using this command to control the robot we want it to run indefinitely.
@@ -607,10 +417,10 @@ Since we will be using this command to control the robot we want it to run indef
- Alternatively we can make a condition which can return true
- For example `(timePassed > 10)` will return true after 10 seconds but return false anytime before 10 seconds have passed.
-#### In the end method
+### In the end method
!!! summary ""
- **1)** We will call the arcadeDrive method and give it 0 and 0 as the parameters.
+ **1)** We will call the arcadeDrive method and give it 0 and 0 as the parameters. this will stop the robot when the command completes.
In the end() method type:
@@ -620,146 +430,86 @@ Since we will be using this command to control the robot we want it to run indef
- This make the motors stop running when the command ends by setting the movement speed to zero and rotation speed to zero.
-#### Completed Example
+### Completed Example
-??? Example
+Complete DriveArcade Command Example
- Your full **Constants.java** should look similar to this:
+**Full Constants.java:**
- ```java
- package frc.robot;
-
- public class Constants {
- // Talons
- public static final int DRIVETRAIN_LEFT_FRONT_TALON = 0;
- public static final int DRIVETRAIN_LEFT_BACK_TALON = 1;
- public static final int DRIVETRAIN_RIGHT_FRONT_TALON = 2;
- public static final int DRIVETRAIN_RIGHT_BACK_TALON = 3;
-
- // Joysticks
- public static final int DRIVER_CONTROLLER = 0;
- public static final int DRIVER_CONTROLLER_MOVE_AXIS = 1; // Change for your controller
- public static final int DRIVER_CONTROLLER_ROTATE_AXIS = 2; // Change for your controller
- }
- ```
+See [Constants.java](../code_examples/2026KitBotInline/src/main/java/frc/robot/Constants.java) for the complete constants file with all required constant definitions.
- Your full **DriveArcade.java** should look like this:
+**Full RobotContainer.java:**
- ```java
- package frc.robot.commands;
-
- import edu.wpi.first.wpilibj.command.Command;
- import frc.robot.RobotContainer;
- import frc.robot.Constants;
-
- public class DriveArcade extends Command {
- public DriveArcade() {
- // Use addRequirements() here to declare subsystem dependencies.
- addRequirements(RobotContainer.m_drivetrain);
- }
-
- // Called just before this Command runs the first time
- @Override
- protected void initialize() {
- }
-
- // Called repeatedly when this Command is scheduled to run
- @Override
- protected void execute() {
- double moveSpeed = -RobotContainer.driverController.getRawAxis(Constants.DRIVER_CONTROLLER_MOVE_AXIS);
- double rotateSpeed = RobotContainer.driverController.getRawAxis(Constants.DRIVER_CONTROLLER_ROTATE_AXIS);
-
- RobotContainer.m_drivetrain.arcadeDrive(moveSpeed, rotateSpeed);
- }
-
- // Called once the command ends or is interrupted.
- @Override
- protected void end(boolean interrupted) {
- Robot.m_drivetrain.arcadeDrive(0, 0);
- }
-
- // Make this return true when this Command no longer needs to run execute()
- @Override
- protected boolean isFinished() {
- return false;
- }
- }
- ```
+See [RobotContainer.java](../code_examples/2026KitBotInline/src/main/java/frc/robot/RobotContainer.java) for the complete RobotContainer implementation including all command bindings.
-### Using setDefaultCommand
+**Full Drive Subsystem:**
+
+See [CANDriveSubsystem.java](../code_examples/2026KitBotInline/src/main/java/frc/robot/subsystems/CANDriveSubsystem.java) for the complete drive subsystem with all motor initialization and configuration.
+
+
+## Finishing Up in RobotContainer
+
+### Creating the Joystick
+
+In order to drive our robot, it needs to know what will be controlling it. To do so, we will use the joystick in `RobotContainer.java`, as `m_drivecontroller`.
-- Commands passed to this method will run when the robot is enabled.
-- They also run if no other commands using the subsystem are running.
- - This is why we write **addRequirements(Robot.m_subsystemName)** in the commands we create, it ends currently running commands using that subsystem to allow a new command is run.
-
!!! summary ""
- **1)** Back in **RobotContainer.java** in the constructor we will call the `setDefaultCommand` of `m_drivetrain` and pass it the `DriveArcade` command
+ **1)** Open Constants.java
+ Check and make sure the `kDriverControllerPort` constant is present.
+ **2)** Open RobotContainer.java
+ - in the imports section, change `ExampleCommand` to `DriveArcade`.
+ - inside the class, find the line ` private final ExampleSubsystem m_exampleSubsystem = new ExampleSubsystem();` and change `ExampleSubsystem` to `Drivetrain` and `m_exampleSubsystem` to `drivetrain`.
- In the **RobotContainer.java** constructor type:
+
- ```java
- m_drivetrain.setDefaultCommand(new DriveArcade());
+### Using setDefaultCommand
+
+!!! summary ""
+ **1)** Back in **RobotContainer.java** We will need to remove everything inside the `configureBindings` method.
+ **2)** in the `configureBindings`we will call the `setDefaultCommand` of `drivetrain` and create a new `DriveArcade` command with parameters.
+
+ !!! Tip
+ - Commands in this method will run when the robot is enabled.
+ - They also run if no other commands using the subsystem are running.
+ - This is why we write **addRequirements(Robot.subsystemName)** in the commands we create, it ends currently running commands using that subsystem to allow a new command is run.
+ - We will the default command for the drive subsystem to an instance of the `DriveArcade` with the values provided by the joystick axes on the driver controller.
+ - The Y axis of the controller is inverted so that pushing the stick away from you (a negative value) drives the robot forwards (a positive value).
+ - Similarly for the X axis where we need to flip the value so the joystick matches the WPILib convention of counter-clockwise positive
+
+ ```Java
+ driveSubsystem.setDefaultCommand(new DriveArcade(
+ () -> -m_driverController.getLeftY()
+ () -> -m_driverController.getRightX(),
+ driveSubsystem));
```
+ !!! Tip
+ - Notice the `()->` notation above. This notation creates lamdas or anonymous methods. [More about Lambdas](https://www.w3schools.com/java/java_lambda.asp){target=blank}
+ - The lambas are required because we set the parameter types of `xpeed` and 'zrotation' in our `DriveArcade` to be `DoubleSuppliers`, which are methods that return doubles. (Which is what the lambdas above return.)
+ - These are declared as such so that they get and send the updated values from `m_driverController.getLeftY()` and `m_driverController.getRightX()` to the drive motors continuously.
+
!!! Tip
Remember to use the light bulb for importing if needed!
+ !!! Tip
+ The `New` keyword creates a new instance of a class (object)
-??? Example
+// details | Full RobotContainer Example
- Your full **RobotContainer.java** should look like this:
+See [RobotContainer.java](../code_examples/2026KitBotInline/src/main/java/frc/robot/RobotContainer.java) for the complete RobotContainer implementation.
+
+The key part for drive configuration is in `configureBindings()`:
+
+```java
+// Set the default command for the drive subsystem
+driveSubsystem.setDefaultCommand(
+ driveSubsystem.driveArcade(
+ () -> -driverController.getLeftY() * DRIVE_SCALING,
+ () -> -driverController.getRightX() * ROTATION_SCALING));
+```
+
+This sets arcade drive as the default command, using:
+
+- The negative Y-axis of the left joystick (inverted so pushing away drives forward)
+- The negative X-axis of the right joystick (inverted for WPILib counter-clockwise positive convention)
+- Both axes scaled for controllability
- ```java
- package frc.robot;
-
- import edu.wpi.first.wpilibj.Joystick;
- import frc.robot.commands.*;
- import frc.robot.subsystems.*;
- import edu.wpi.first.wpilibj2.command.Command;
-
- /**
- * This class is where the bulk of the robot should be declared. Since Command-based is a
- * "declarative" paradigm, very little robot logic should actually be handled in the {@link Robot}
- * periodic methods (other than the scheduler calls). Instead, the structure of the robot
- * (including subsystems, commands, and button mappings) should be declared here.
- */
- public class RobotContainer {
- // The robot's subsystems and commands are defined here...
- public static final Drivetrain m_drivetrain = new Drivetrain();
- private final ExampleSubsystem m_exampleSubsystem = new ExampleSubsystem();
-
- private final ExampleCommand m_autoCommand = new ExampleCommand(m_exampleSubsystem);
-
- public Joystick driverController = new Joystick(Constants.DRIVER_CONTROLLER);
-
- /**
- * The container for the robot. Contains subsystems, OI devices, and commands.
- */
- public RobotContainer() {
- // Configure the button bindings
- configureButtonBindings();
-
- // Set default commands on subsystems
- m_drivetrain.setDefaultCommand(new DriveArcade());
- }
-
- /**
- * Use this method to define your button->command mappings. Buttons can be created by
- * instantiating a {@link GenericHID} or one of its subclasses ({@link
- * edu.wpi.first.wpilibj.Joystick} or {@link XboxController}), and then passing it to a
- * {@link edu.wpi.first.wpilibj2.command.button.JoystickButton}.
- */
- private void configureButtonBindings() {
- }
-
-
- /**
- * Use this to pass the autonomous command to the main {@link Robot} class.
- *
- * @return the command to run in autonomous
- */
- public Command getAutonomousCommand() {
- // An ExampleCommand will run in autonomous
- return m_autoCommand;
- }
- }
- ```
diff --git a/docs/programming/new_project.md b/docs/programming/new_project.md
index 0e7bc3a..67aa8cd 100644
--- a/docs/programming/new_project.md
+++ b/docs/programming/new_project.md
@@ -59,14 +59,16 @@ Newly created projects have many files within them. We only care about the conte
- An example Command
- **ExampleSubsystem.java**
- An example SubSystem
-- **Constants.java** (new in 2020, replaces RobotMap.java)
+- **Constants.java**
- Used to map physical ports (digital if using the CAN bus) of sensors or devices connected to the robot and assign them a variable name to be used in other parts of the code.
- This provides flexibility for changing wiring, makes checking the wiring easier, and significantly reduces the number of magic numbers floating around.
- Can also be used to store generic constant values as variables in the code
+ - This gives a unified place to store and modify values that might be used many places in the code, so they only have to be changes once.
+
- **Main.java**
- Used for advanced programming
- Will be ignored/left as is for this tutorial
-- **RobotContainer.java** (new in 2020, replaces OI.java)
+- **RobotContainer.java**
- Used to declare our subsystem
- Used to create a connection between commands and Operator Interfaces (OI) such as Joysticks or buttons
- **Robot.java**
diff --git a/docs/programming/yagsl_swerve_tutorial.md b/docs/programming/yagsl_swerve_tutorial.md
new file mode 100644
index 0000000..844dcc3
--- /dev/null
+++ b/docs/programming/yagsl_swerve_tutorial.md
@@ -0,0 +1,671 @@
+# Setting Up a Swerve Drive with YAGSL for FRC
+
+This tutorial provides a comprehensive, step-by-step guide to setting up a swerve drive using Yet Another Generic Swerve Library (YAGSL) for FIRST Robotics Competition (FRC) projects. YAGSL is designed to simplify swerve drive implementation by providing a generic, well-documented library that works with various motor controllers and sensors, eliminating the need for custom code for each robot configuration.
+
+## 1. Introduction to YAGSL
+
+YAGSL (Yet Another Generic Swerve Library) is a swerve drive library developed by current and former BroncBotz mentors for FRC teams. Its primary goal is to make swerve drive programming as straightforward as using a `DifferentialDrive`, while supporting a wide range of hardware combinations.
+
+### Key Features
+- **Generic Design**: Works with mixed hardware (e.g., REV SparkMax with CTRE CANCoder, TalonFX with Pigeon2, etc.)
+- **JSON-Based Configuration**: Robot-specific settings are stored in JSON files, allowing the same code to work across different robots
+- **Active Maintenance**: Regularly updated and community-supported
+- **Comprehensive Documentation**: Extensive guides, examples, and troubleshooting resources
+
+### Why YAGSL?
+Unlike many swerve templates that require extensive modification, YAGSL abstracts hardware differences, so teams can focus on robot logic rather than drive code. It's particularly useful for teams with multiple robots or those using non-standard hardware combinations.
+
+For more details, see the [YAGSL Overview](https://docs.yagsl.com/overview/what-we-do).
+
+## 2. Prerequisites and Dependencies
+
+Before starting, ensure you have the following installed and configured.
+
+### Software Requirements
+- **WPILib**: Latest stable version for your season (2025 recommended)
+ - Installation guide: [WPILib Setup](https://docs.wpilib.org/en/stable/docs/zero-to-robot/step-2/wpilib-setup.html)
+- **REV Hardware Client 2**: For configuring REV devices
+ - Download: [REV Hardware Client](https://docs.revrobotics.com/rev-hardware-client-2)
+- **CTRE Tuner X**: For configuring CTRE devices (Phoenix 6)
+ - Installation: [Phoenix 6 Installation](https://v6.docs.ctr-electronics.com/en/latest/docs/installation/installation-frc.html)
+
+### Vendor Dependencies (Vendordeps)
+YAGSL requires vendor libraries for all supported hardware, even if not used on your robot. Install these via WPILib's vendor dependency system:
+
+- **REVLib**: `https://software-metadata.revrobotics.com/REVLib.json`
+- **Phoenix 6**: `https://maven.ctr-electronics.com/release/com/ctre/phoenix6/latest/Phoenix6-frc2025-latest.json`
+- **ReduxLib**: `https://frcsdk.reduxrobotics.com/ReduxLib.json`
+- **PhotonVision** (optional, for vision): `https://maven.photonvision.org/repository/internal/org/photonvision/PhotonLib-json/1.0/PhotonLib-json-1.0.json`
+- **YAGSL**: `https://yet-another-software-suite.github.io/YAGSL/yagsl.json`
+
+Installation steps: [3rd Party Libraries](https://docs.wpilib.org/en/stable/docs/software/vscode-overview/3rd-party-libraries.html#installing-libraries)
+
+### Hardware Knowledge
+You should know your robot's physical characteristics before configuration. See section 3 for details.
+
+## 3. Hardware Requirements and Getting to Know Your Robot
+
+A swerve drive consists of:
+- **Gyroscope/IMU**: For heading tracking (e.g., Pigeon2, NavX, or built-in IMU)
+- **Swerve Modules**: Each containing:
+ - Drive motor (e.g., NEO, Falcon500, Kraken)
+ - Angle/steering motor (e.g., NEO 550, TalonFXS)
+ - Absolute encoder (e.g., CANCoder, Canandmag, Thrifty Encoder)
+- **CAN Bus**: For communication (required for most modern FRC hardware)
+
+### Pre-Configuration Checklist
+Before configuring YAGSL, gather these details about your robot:
+
+- **IMU Type and ID**: What gyroscope are you using and its CAN ID?
+- **Module Configuration**: For each swerve module:
+ - Drive motor type, CAN ID, and gearing
+ - Angle motor type, CAN ID, and gearing
+ - Encoder type, CAN ID, and mounting offset
+ - Physical location relative to robot center (X, Y coordinates in inches)
+- **Physical Properties**:
+ - Wheel diameter
+ - Drive gear ratio (motor rotations per wheel rotation)
+ - Angle gear ratio (motor rotations per 360° module rotation)
+ - Robot track width and wheelbase
+ - Maximum speed (feet per second)
+- **CAN Bus Configuration**: Ensure all devices have unique IDs and proper termination
+
+For a complete list, see [Getting to Know Your Robot](https://docs.yagsl.com/configuring-yagsl/getting-to-know-your-robot).
+
+## 4. Configuration Steps (JSON Files, Module Setup)
+
+YAGSL uses JSON configuration files to define your robot's swerve drive. These files are placed in the `deploy/swerve/` directory of your robot project.
+
+### Directory Structure
+```
+deploy/
+└── swerve/
+ ├── controllerproperties.json
+ ├── modules/
+ │ ├── frontleft.json
+ │ ├── frontright.json
+ │ ├── backleft.json
+ │ └── backright.json
+ ├── physicalproperties.json
+ ├── pidfproperties.json
+ └── swervedrive.json
+```
+
+### Configuration Files Overview
+
+#### swervedrive.json - Global Drive Configuration
+
+This file defines the overall swerve drive configuration, including the IMU (gyroscope) settings and references to the individual module configuration files.
+
+!!! summary "Key Properties"
+ - `imu`: Configures the gyroscope/IMU used for heading tracking
+ - `type`: The type of IMU ("pigeon2", "navx", "adxrs450", etc.)
+ - `id`: CAN ID of the IMU device
+ - `canbus`: CAN bus name (usually "rio" for roboRIO bus)
+ - `invertedIMU`: Whether to invert the IMU reading (used for orientation correction)
+ - `modules`: Array of module configuration file names
+
+**Example - Pigeon2 IMU:**
+```json
+{
+ "imu": {
+ "type": "pigeon2",
+ "id": 13,
+ "canbus": "rio"
+ },
+ "invertedIMU": false,
+ "modules": [
+ "frontleft.json",
+ "frontright.json",
+ "backleft.json",
+ "backright.json"
+ ]
+}
+```
+
+**Example - NavX IMU:**
+```json
+{
+ "imu": {
+ "type": "navx",
+ "id": 0,
+ "canbus": null
+ },
+ "invertedIMU": false,
+ "modules": [
+ "frontleft.json",
+ "frontright.json",
+ "backleft.json",
+ "backright.json"
+ ]
+}
+```
+
+**Complete swervedrive.json Example:**
+```json
+{
+ "imu": {
+ "type": "pigeon2",
+ "id": 13,
+ "canbus": "rio"
+ },
+ "invertedIMU": false,
+ "modules": [
+ "frontleft.json",
+ "frontright.json",
+ "backleft.json",
+ "backright.json"
+ ]
+}
+```
+
+#### Module JSON Files - Individual Swerve Module Configuration
+
+Each swerve module (wheel) has its own configuration file defining the drive motor, angle motor, encoder, and physical location.
+
+!!! summary "Key Properties"
+ - `drive`: Configuration for the drive (translation) motor
+ - `type`: Motor controller type ("sparkmax", "talonfx", "talonsrx", etc.)
+ - `id`: CAN ID of the motor controller
+ - `canbus`: CAN bus name
+ - `angle`: Configuration for the angle (steering) motor
+ - `encoder`: Configuration for the absolute encoder
+ - `type`: Encoder type ("cancoder", "analog", "thrifty", etc.)
+ - `inverted`: Motor inversion settings
+ - `drive`: Whether to invert drive motor direction
+ - `angle`: Whether to invert angle motor direction
+ - `absoluteEncoderInverted`: Whether to invert encoder reading
+ - `absoluteEncoderOffset`: Encoder offset in rotations (0.0 to 1.0)
+ - `location`: Physical location relative to robot center
+ - `front`: Distance forward from center (inches)
+ - `left`: Distance left from center (inches, negative for right side)
+
+**Example - SparkMax with CANCoder:**
+```json
+{
+ "drive": {
+ "type": "sparkmax",
+ "id": 2,
+ "canbus": null
+ },
+ "angle": {
+ "type": "sparkmax",
+ "id": 1,
+ "canbus": null
+ },
+ "encoder": {
+ "type": "cancoder",
+ "id": 10,
+ "canbus": null
+ },
+ "inverted": {
+ "drive": false,
+ "angle": false
+ },
+ "absoluteEncoderInverted": false,
+ "absoluteEncoderOffset": 0.0,
+ "location": {
+ "front": 12.0,
+ "left": -12.0
+ }
+}
+```
+
+**Example - TalonFX with CANCoder:**
+```json
+{
+ "drive": {
+ "type": "talonfx",
+ "id": 2,
+ "canbus": null
+ },
+ "angle": {
+ "type": "talonfx",
+ "id": 1,
+ "canbus": null
+ },
+ "encoder": {
+ "type": "cancoder",
+ "id": 10,
+ "canbus": null
+ },
+ "inverted": {
+ "drive": false,
+ "angle": false
+ },
+ "absoluteEncoderInverted": false,
+ "absoluteEncoderOffset": 0.0,
+ "location": {
+ "front": 12.0,
+ "left": -12.0
+ }
+}
+```
+
+**Complete frontleft.json Example:**
+```json
+{
+ "drive": {
+ "type": "sparkmax",
+ "id": 2,
+ "canbus": null
+ },
+ "angle": {
+ "type": "sparkmax",
+ "id": 1,
+ "canbus": null
+ },
+ "encoder": {
+ "type": "cancoder",
+ "id": 10,
+ "canbus": null
+ },
+ "inverted": {
+ "drive": false,
+ "angle": false
+ },
+ "absoluteEncoderInverted": false,
+ "absoluteEncoderOffset": 0.0,
+ "location": {
+ "front": 12.0,
+ "left": -12.0
+ }
+}
+```
+
+#### physicalproperties.json - Physical Robot Parameters
+
+This file defines the physical characteristics of your robot and swerve modules that affect calculations.
+
+!!! summary "Key Properties"
+ - `optimalVoltage`: Battery voltage for calculations (usually 12.0V)
+ - `wheelDiameter`: Diameter of drive wheels in inches
+ - `driveGearRatio`: Gear ratio from motor to wheel (motor rotations per wheel rotation)
+ - `angleGearRatio`: Gear ratio from motor to module rotation (motor rotations per 360° module turn)
+
+**Example - 4-inch wheels with 6.75:1 drive ratio:**
+```json
+{
+ "optimalVoltage": 12.0,
+ "wheelDiameter": 4.0,
+ "driveGearRatio": 6.75,
+ "angleGearRatio": 12.8
+}
+```
+
+**Example - 3-inch wheels with 8.14:1 drive ratio:**
+```json
+{
+ "optimalVoltage": 12.0,
+ "wheelDiameter": 3.0,
+ "driveGearRatio": 8.14,
+ "angleGearRatio": 12.8
+}
+```
+
+**Complete physicalproperties.json Example:**
+```json
+{
+ "optimalVoltage": 12.0,
+ "wheelDiameter": 4.0,
+ "driveGearRatio": 6.75,
+ "angleGearRatio": 12.8
+}
+```
+
+#### pidfproperties.json - Motor Control Tuning
+
+This file contains PIDF (Proportional, Integral, Derivative, Feedforward) tuning values for both drive and angle motors.
+
+!!! summary "Key Properties"
+ - `drive`: PIDF values for drive motors (translation)
+ - `p`: Proportional gain
+ - `i`: Integral gain
+ - `d`: Derivative gain
+ - `f`: Feedforward gain
+ - `iz`: Integral zone (error threshold for integral accumulation)
+ - `angle`: PIDF values for angle motors (steering)
+
+**Example - SparkMax tuning values:**
+```json
+{
+ "drive": {
+ "p": 0.0020645,
+ "i": 0.0,
+ "d": 0.0,
+ "f": 0.0,
+ "iz": 0.0
+ },
+ "angle": {
+ "p": 0.01,
+ "i": 0.0,
+ "d": 0.0,
+ "f": 0.0,
+ "iz": 0.0
+ }
+}
+```
+
+**Example - TalonFX tuning values:**
+```json
+{
+ "drive": {
+ "p": 1.0,
+ "i": 0.0,
+ "d": 0.0,
+ "f": 0.0,
+ "iz": 0.0
+ },
+ "angle": {
+ "p": 50.0,
+ "i": 0.0,
+ "d": 0.32,
+ "f": 0.0,
+ "iz": 0.0
+ }
+}
+```
+
+**Complete pidfproperties.json Example:**
+```json
+{
+ "drive": {
+ "p": 0.0020645,
+ "i": 0.0,
+ "d": 0.0,
+ "f": 0.0,
+ "iz": 0.0
+ },
+ "angle": {
+ "p": 0.01,
+ "i": 0.0,
+ "d": 0.0,
+ "f": 0.0,
+ "iz": 0.0
+ }
+}
+```
+
+#### controllerproperties.json - Advanced Control Settings
+
+This file configures advanced control parameters for heading correction and velocity control (usually left at defaults).
+
+!!! summary "Key Properties"
+ - `heading`: PID values for heading correction
+ - `p`: Proportional gain for heading control
+ - `i`: Integral gain
+ - `d`: Derivative gain
+ - `velocity`: Velocity control PID values
+ - `x`: PID for X-axis velocity control
+ - `y`: PID for Y-axis velocity control
+
+**Example - Default controller settings:**
+```json
+{
+ "heading": {
+ "p": 0.4,
+ "i": 0.0,
+ "d": 0.0
+ },
+ "velocity": {
+ "x": {
+ "p": 2.0,
+ "i": 0.0,
+ "d": 0.0
+ },
+ "y": {
+ "p": 2.0,
+ "i": 0.0,
+ "d": 0.0
+ }
+ }
+}
+```
+
+**Complete controllerproperties.json Example:**
+```json
+{
+ "heading": {
+ "p": 0.4,
+ "i": 0.0,
+ "d": 0.0
+ },
+ "velocity": {
+ "x": {
+ "p": 2.0,
+ "i": 0.0,
+ "d": 0.0
+ },
+ "y": {
+ "p": 2.0,
+ "i": 0.0,
+ "d": 0.0
+ }
+ }
+}
+```
+
+### Using the Configuration Tool
+YAGSL provides an online configuration generator: [YAGSL Config Tool](https://broncbotz3481.github.io/YAGSL-Example/)
+
+1. Input your robot's physical parameters
+2. Select hardware types and IDs
+3. Download the generated configuration files
+4. Place them in `src/main/deploy/swerve/`
+
+For manual configuration details, see [Configuration Documentation](https://docs.yagsl.com/configuring-yagsl/configuration).
+
+## 5. Code Setup and Integration
+
+### Importing YAGSL
+Add YAGSL as a vendor dependency (see section 2), then import in your code:
+```java
+import swervelib.parser.SwerveParser;
+import swervelib.SwerveDrive;
+import swervelib.telemetry.SwerveDriveTelemetry;
+import swervelib.telemetry.SwerveDriveTelemetry.TelemetryVerbosity;
+```
+
+### Creating the SwerveDrive Object
+In your subsystem constructor:
+```java
+public class SwerveSubsystem extends SubsystemBase {
+ private final SwerveDrive swerveDrive;
+
+ public SwerveSubsystem() {
+ // Configure telemetry verbosity
+ SwerveDriveTelemetry.verbosity = TelemetryVerbosity.HIGH;
+
+ try {
+ // Create swerve drive from JSON configuration
+ File swerveDirectory = new File(Filesystem.getDeployDirectory(), "swerve");
+ double maxSpeed = Units.feetToMeters(14.5); // Maximum speed in m/s
+ swerveDrive = new SwerveParser(swerveDirectory).createSwerveDrive(maxSpeed);
+
+ // Optional: Configure additional settings
+ swerveDrive.setHeadingCorrection(true);
+ swerveDrive.setCosineCompensator(true);
+
+ } catch (Exception e) {
+ throw new RuntimeException("Failed to create swerve drive", e);
+ }
+ }
+}
+```
+
+### Telemetry Setup
+YAGSL provides extensive telemetry for debugging. Configure verbosity:
+```java
+SwerveDriveTelemetry.verbosity = TelemetryVerbosity.HIGH; // Options: NONE, LOW, HIGH
+```
+
+This adds NetworkTables entries under `/SwerveDrive/` for monitoring module states, IMU data, and odometry.
+
+For more code setup details, see [Code Setup Documentation](https://docs.yagsl.com/configuring-yagsl/code-setup).
+
+## 6. Basic Driving Code Examples
+
+### Field-Oriented Drive Command
+
+!!! Tip
+ Field-oriented drive means the robot moves relative to the field coordinate system, not its own orientation. Forward on the joystick always moves the robot toward the same direction on the field (e.g., toward the opponent's goal), regardless of how the robot is currently rotated. This is the most intuitive and commonly used drive mode for FRC competition robots.
+
+```java
+/**
+ * Command to drive the robot using translative values and heading as angular velocity.
+ */
+public Command driveCommand(DoubleSupplier translationX, DoubleSupplier translationY, DoubleSupplier angularRotationX) {
+ return run(() -> {
+ // Scale inputs for smoother control
+ Translation2d scaledInputs = SwerveMath.scaleTranslation(
+ new Translation2d(translationX.getAsDouble(), translationY.getAsDouble()),
+ 0.8
+ );
+
+ // Drive field-oriented
+ swerveDrive.drive(
+ scaledInputs,
+ angularRotationX.getAsDouble() * swerveDrive.getMaximumChassisAngularVelocity(),
+ true, // fieldRelative
+ false // openLoop
+ );
+ });
+}
+```
+
+### Robot-Oriented Drive
+
+!!! Tip
+ Robot-oriented drive means the robot moves relative to its own orientation. Forward on the joystick always moves the robot in the direction it's currently facing. This mode is useful for precise movements or when field orientation isn't important, but can be confusing for drivers during competition.
+
+```java
+public void driveRobotOriented(double xSpeed, double ySpeed, double rot) {
+ swerveDrive.drive(
+ new Translation2d(xSpeed, ySpeed).times(swerveDrive.getMaximumChassisVelocity()),
+ rot * swerveDrive.getMaximumChassisAngularVelocity(),
+ false, // fieldRelative = false
+ false // openLoop
+ );
+}
+```
+
+### ChassisSpeeds Drive
+
+!!! Tip
+ ChassisSpeeds drive accepts a WPILib ChassisSpeeds object, which represents the desired velocity of the robot chassis. This is useful when integrating with path planning libraries like PathPlanner or when you have calculated velocities from other sources. It provides the most control over robot motion.
+
+```java
+public void driveFieldOriented(ChassisSpeeds velocity) {
+ swerveDrive.driveFieldOriented(velocity);
+}
+```
+
+### Joystick Integration
+
+!!! Tip
+ Joystick integration shows how to connect driver inputs to the drive commands. The default command runs continuously while no other command is active. Note the axis inversions (-driverController.getLeftY()) which account for typical joystick orientations where pushing forward gives negative Y values.
+
+```java
+private final CommandXboxController driverController = new CommandXboxController(0);
+
+public RobotContainer() {
+ SwerveSubsystem drivebase = new SwerveSubsystem();
+
+ // Set default command for field-oriented drive
+ drivebase.setDefaultCommand(
+ drivebase.driveCommand(
+ () -> -driverController.getLeftY(), // Forward/backward (inverted)
+ () -> -driverController.getLeftX(), // Left/right (inverted)
+ () -> -driverController.getRightX() // Rotation (inverted)
+ )
+ );
+}
+```
+
+### Odometry and Pose Reset
+
+!!! Tip
+ Odometry tracks the robot's position and orientation on the field using wheel encoders and IMU data. Pose reset is useful for correcting odometry drift, often done at the start of autonomous or when vision systems provide accurate position data.
+
+```java
+// Get current pose
+public Pose2d getPose() {
+ return swerveDrive.getPose();
+}
+
+// Reset odometry
+public void resetOdometry(Pose2d pose) {
+ swerveDrive.resetOdometry(pose);
+}
+```
+
+For more examples, see the [YAGSL Examples Repository](https://github.com/Yet-Another-Software-Suite/YAGSL/tree/main/examples).
+
+## 7. Tuning and Debugging
+
+### PIDF Tuning
+YAGSL uses PIDF controllers for both drive and angle motors. Start with these values:
+
+**SparkMax-based systems:**
+```json
+{
+ "drive": {"p": 0.0020645, "i": 0, "d": 0, "f": 0, "iz": 0},
+ "angle": {"p": 0.01, "i": 0, "d": 0, "f": 0, "iz": 0}
+}
+```
+
+**TalonFX-based systems:**
+```json
+{
+ "drive": {"p": 1, "i": 0, "d": 0, "f": 0, "iz": 0},
+ "angle": {"p": 50, "i": 0, "d": 0.32, "f": 0, "iz": 0}
+}
+```
+
+Tuning process:
+1. Set P, I, D, F to 0
+2. Increase P until oscillation occurs
+3. Increase D to reduce jitter
+4. Fine-tune as needed
+
+For detailed tuning guides, see [WPILib PID Tuning](https://docs.wpilib.org/en/stable/docs/software/advanced-controls/introduction/tuning-turret.html) and [YAGSL PIDF Tuning](https://docs.yagsl.com/configuring-yagsl/how-to-tune-pidf).
+
+### The Eight Steps for Inversion
+If your swerve drive spins out of control or has incorrect field orientation, use these systematic steps to fix inversion issues:
+
+1. Set `invertIMU` to `false` in `swervedrive.json` and all drive motor `inverted` to `false` in module JSONs
+2. Set `invertIMU` to `true`
+3. Invert all drive motors (`"drive": {"inverted": true}`)
+4. Set `invertIMU` to `false`
+5. Flip module locations (swap front/back or left/right in configuration)
+6. Uninvert drive motors (`"drive": {"inverted": false}`)
+7. Set `invertIMU` to `true`
+8. Invert drive motors again (`"drive": {"inverted": true}`)
+
+Test after each step. Most robots work after step 1, 3, or 7.
+
+For complete details, see [When to Invert](https://docs.yagsl.com/configuring-yagsl/when-to-invert) and [The Eight Steps](https://docs.yagsl.com/configuring-yagsl/the-eight-steps).
+
+### Common Issues
+- **Modules not facing correct direction**: Check absolute encoder offsets
+- **Robot drifting in odometry**: Verify IMU orientation and module locations
+- **Gears grinding**: PID tuning issue, not inversion
+- **Inconsistent behavior**: Ensure all modules have same hardware configuration
+
+## 8. Links to Relevant Documentation
+
+- **YAGSL Main Documentation**: [docs.yagsl.com](https://docs.yagsl.com/)
+- **Configuration Tool**: [YAGSL Config Generator](https://broncbotz3481.github.io/YAGSL-Example/)
+- **Examples Repository**: [GitHub Examples](https://github.com/Yet-Another-Software-Suite/YAGSL/tree/main/examples)
+- **WPILib Swerve Kinematics**: [Swerve Drive Kinematics](https://docs.wpilib.org/en/stable/docs/software/kinematics-and-odometry/swerve-drive-kinematics.html)
+- **CTRE Swerve Overview**: [Phoenix 6 Swerve](https://v6.docs.ctr-electronics.com/en/stable/docs/api-reference/mechanisms/swerve/swerve-overview.html)
+- **REV Swerve Resources**: [REV Swerve Documentation](https://docs.revrobotics.com/brushless/neo/vortex/vortex-shafts)
+
+## Additional Resources
+
+- **Complete YAGSL Example Project**: [YAGSL-Example Repository](https://github.com/BroncBotz3481/YAGSL-Example) - A complete, working FRC robot project demonstrating YAGSL implementation
+- **YAGSL Community**: Join the [BroncBotz Discord](https://discord.gg/broncbotz) for support
+- **Known Configurations**: [YAGSL Configs Repository](https://github.com/BroncBotz3481/YAGSL-Configs)
+- **Advanced Features**: Check examples for PathPlanner, PhotonVision, and SysId integration
+
+This tutorial covers the essentials for getting started with YAGSL. For advanced features like vision integration or custom control algorithms, explore the examples and documentation further. Remember to test thoroughly on a test bench before field use!
\ No newline at end of file
diff --git a/docs/setup/install_software.md b/docs/setup/install_software.md
index c8e69b8..7dc2049 100644
--- a/docs/setup/install_software.md
+++ b/docs/setup/install_software.md
@@ -12,6 +12,7 @@ Before we can start programing a robot we must install the necessary software fo
**See table of contents for a breakdown of this section.**
!!! tip
+
You can install both the **Development Tools** and the **FRC Game Tools** on the same computer or separate computers. However many teams (3255 included) have a development laptop (with both) and a dedicated driverstation laptop (with only the FRC Game Tools) that often stays disconnected from the internet.
***
@@ -55,3 +56,7 @@ In order to enable wireless connectivity to the robot outside of FRC events or t
For **Windows ONLY:**
[Official FRC Radio Configuration Utility and Use guide (Windows only)](https://docs.wpilib.org/en/stable/docs/getting-started/getting-started-frc-control-system/radio-programming.html){target=_blank}
+
+## customizing WPILIB Vscode
+
+
diff --git a/docs/version_control/BasicGit.md b/docs/version_control/BasicGit.md
new file mode 100644
index 0000000..ca97e52
--- /dev/null
+++ b/docs/version_control/BasicGit.md
@@ -0,0 +1,113 @@
+
+# Basic Git
+
+------------
+
+Git is a version control system, or a way for us to collaborate on code and manage having multiple versions of code working in parallel
+
+While many modern cloud applications, like google docs, have some form of auto-save to the cloud, we don't necessarily want a single auto-updating version of our code.
+As we're working, the changes we make can cause code to break very quickly in ways that might not be immediately obvious, which means it's good to be able to take a "snapshot" of the code at a point where it worked.
+So, we use a tool called Git to manage different versions of our files and save them to Github, which lets us share the codebase between computers.
+Instead of automatically syncing to Github, we save our code in small named chunks called commits.
+These named versions makes it easy to revert changes that break previously working behaviour and see when and by who code was written.
+Git also lets us have different, parallel versions, called branches, of code.
+This means that while one person works on code for the autonomous, another could work on vision, for example, without overriding each other.
+
+## Resources
+
+Read one of the following:
+
+- [WPILib Git intro](https://docs.wpilib.org/en/stable/docs/software/basic-programming/git-getting-started.html)
+- [Github Git intro](https://docs.github.com/en/get-started/using-git/about-git)
+- [Github Git intro video (start at 0:43)](https://youtu.be/r8jQ9hVA2qs?t=43)
+
+Install the following:
+
+- [Windows Git install](https://gitforwindows.org/)
+- [Linux/Mac Git install](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git)
+- [Github Desktop](https://desktop.github.com/download/)
+
+## Basic Git Commands
+
+To use Git, developers use specific commands to copy, create, change, and combine code. These commands can be executed directly from the command line or by using an application like GitHub Desktop. Here are some common commands for using Git:
+
+**git init**: initializes a brand new Git repository and begins tracking an existing directory. It adds a hidden subfolder within the existing directory that houses the internal data structure required for version control.
+
+**git clone** creates a local copy of a project that already exists remotely. The clone includes all the project's files, history, and branches.
+
+**git add** stages a change. Git tracks changes to a developer's codebase, but it's necessary to stage and take a snapshot of the changes to include them in the project's history. This command performs staging, the first part of that two-step process. Any changes that are staged will become a part of the next snapshot and a part of the project's history. Staging and committing separately gives developers complete control over the history of their project without changing how they code and work.
+
+**git commit** saves the snapshot to the project history and completes the change-tracking process. In short, a commit functions like taking a photo. Anything that's been staged with git add will become a part of the snapshot with git commit.
+
+**git status** shows the status of changes as untracked, modified, or staged.
+
+**git branch** shows the branches being worked on locally.
+
+**git merge** merges lines of development together. This command is typically used to combine changes made on two distinct branches. For example, a developer would merge when they want to combine changes from a feature branch into the main branch for deployment.
+
+**git pull** updates the local line of development with updates from its remote counterpart. Developers use this command if a teammate has made commits to a branch on a remote, and they would like to reflect those changes in their local environment.
+
+**git push** updates the remote repository with any commits made locally to a branch.
+
+For more information, see the [full reference guide to git commands](https://git-scm.com/docs).
+
+## Git Log
+
+>Git log is a tool to view your history in Git. By default Git Log shows all of the commits in the repository, ordered from newest to oldest. in VSCode, the graph panels shows the Git log/History in a visual way.
+
+
+
+## Github Setup
+
+Github is a website that hosts Git repositories. The Robolancers store all of their codes on Github.
+
+1. Sign up for a Github Account here: [Sign up for Github](https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F&source=header-home)
+2. Enable 2 factor Authentitaction (Required to add code): [2fa setup](https://docs.github.com/en/authentication/securing-your-account-with-two-factor-authentication-2fa/configuring-two-factor-authentication)
+
+## Examples
+
+
+
+- Typing `git add .` then `git commit -m "commit name"` then `git push` is the bread and butter of using Git.
+ This sequence tells Git to collect all of your uncommitted changes, commit them, then push them to Github.
+ If you'd like to combine these into one command, you can add an alias to your .gitconfig file (ask a lead or mentor for help).
+- `git checkout branch-name` switches between branches
+- `git checkout -b new-branch` makes a new branch and switches to it.
+ Note that the first time you push from this branch you will need to enter some extra parameters, but the terminal should prompt you with the correct command when you enter `git push`
+- `git status` displays the current branch and what changes you have uncommitted and staged
+- `git pull` updates the code on your device with the latest code from Github.
+ Recommended to do this whenever someone else has been working on the same branch, otherwise you might make conflicting changes
+- [A simple demo video of committing some changes](../assets/images/git/GitDemoVideo.mp4)
+
+## Managing Git in Vscode
+
+### Git Commands in Vscode GUI
+
+
+
+### Git branches menu
+
+Accessed by clicking on the branch name at the bottom left
+
+
+### Merge in another branch in vscode
+
+
+
+## Notes
+
+- We use GitHub's pull request (PR) feature to manage branches and merges.
+Always make sure to merge to main using a PR.
+PR's will be explained further in the [Git Workflow docs](GitWorkflow.md).
+- Always commit code that at the very least compiles (you can check this by running the "Build robot code" option in WPILib's command bar)
+- Commit messages should be short (~10 words), simple, and descriptive.
+ If it's too long, use multiple lines in the commit message
+- Commits should be frequent. Whenever you reach a working state, you should commit before you accidentally break anything again
+- Don't commit directly to the `main` branch, as `main` should **always** contain working code.
+ New code should be developed on separate branches and can only be merged through a pull request after being reviewed and approved.
+- **ALWAYS ALWAYS ALWAYS** commit and push before you leave a meeting, especially if you are using a computer that is not yours!
+ It is never fun to have to commit someone else's code at the start of the day or find out an hour in that you've been working off of someone else's uncommitted (potentially broken!) code.
+ Uncommitted code also makes it harder to track what is and isn't finished.
+- Run a `git status` at the start of a meeting to make sure you committed your code and that you are on the right branch
+
+### Names
diff --git a/docs/version_control/GitWorkflow.md b/docs/version_control/GitWorkflow.md
new file mode 100644
index 0000000..1ab5a21
--- /dev/null
+++ b/docs/version_control/GitWorkflow.md
@@ -0,0 +1,121 @@
+# Git Workflow
+
+## Branches
+
+Branches are a deviation or split from the main branch that can be adding or removing a specific feature
+For example, I can open a branch to work on a new doc page for this training repo.
+Since I am on my own branch, I am not interfering with the main branch's commit history, which is supposed to be kept clean.
+A "clean" commit history is made up of large, well named commits to make it easy to quickly skim recent changes.
+Because I am on my own branch, another student can also work on their own article without fear of interfering with my work.
+
+To create a branch run:
+`git checkout -b "