Advanced Robotics Programming: Difference between revisions
(39 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
The Advanced Robotics Programming Class focuses on teaching our ''Titan Robotics Framework'' (TRC Library). The target audience | The Advanced Robotics Programming Class focuses on teaching our ''Titan Robotics Framework'' (TRC Library). The target audience is for students who already know the Java language. Titan Robotics Framework is designed for both FTC and FRC. After finishing this class, you should be able to write code for both FTC and FRC robots with minimal platform specific changes. | ||
== | == Titan Robotics Framework == | ||
You can read about our Framework Library [https://trc492.github.io/pages/AdvancedRoboticsProgramming.html here] | |||
== | == Class Curriculum == | ||
=== Session 0: Pre-Work === | |||
* | Before coming to the programming class, you need to install the required software on your laptop. Please do this at home before coming to class. We do not want to dedicate class time to install software because they are time consuming and require downloading gigabytes of data from the Internet which would overwhelm our Internet bandwidth if all students were downloading at the same time. Therefore, please make sure you finish these tasks at home before coming to class. FRC software installation instructions can be found [https://trc492.github.io/pages/FrcProgrammingSoftwareInstallation.html here]. | ||
* Create GitHub account if not already have one. | |||
* Download and install GitHub Desktop. | |||
* Clone FrcTemplate project. | |||
* Download and install WPILib with Visual Studio Code. | |||
* Download and install Git Command Line tools. | |||
== | === Session 1: Simple Motor === | ||
==== Topics ==== | |||
* ''' | * Introduce to '''Visual Studio Code'''. | ||
** Start Visual Studio Code. | |||
** Open FrcTemplate project in Visual Studio Code. | |||
** Brief walk through of FrcTemplate code: Code organization (team492, trclib, frclib) | |||
*** '''autocommands''': contains Autonomous code | |||
*** '''autotasks''': contains Auto-Assist tasks | |||
*** '''commandbased''': contains commandbased code (not used) | |||
*** '''drivebases''': contains standard supported drive bases (Differential, Mecanum, Swerve) | |||
*** '''subsystems''': contains code for all upper subsystems | |||
*** '''Main.java''': main entry point of robot code (provided by ''FIRST'', do not change) | |||
*** '''Robot.java''': top level robot object | |||
*** '''RobotParams.java''': contains robot configurations and subsystem parameters | |||
*** '''FrcAuto.java, FrcTeleOp.java, FrcTest.java, FrcDisabled.java''': contain code for respective robot run mode | |||
** Brief walk through of Visual Studio Code. | |||
*** WPILib Plug-in (commonly used operations) | |||
**** '''Set Team Number''': set our team number 492 (Very important: team number is used to find our robot for pushing code) | |||
**** '''Check for WPILib Updates''': Check for latest WPILib from the Internet | |||
**** '''Manage Vendor Libraries''': Install/Remove/CheckUpdate of various 3rd party vendor libraries | |||
**** '''Build Robot Code''': Compile your robot code | |||
**** '''Depoloy Robot Code''': Compile and push code to robot | |||
**** '''Debug Robot Code''': Compile, push code to robot and start real time debugger | |||
*** Common Source Control Operations | |||
**** '''Branches''': Create/Remove/Switch code branches | |||
**** '''Fetch''': Sync latest changes from GitHub | |||
**** '''Discard''': Discard changes to a file and revert back to last committed version | |||
**** '''Stage''': Stage the changed file for commit | |||
**** '''Compare changes''': Compare the changes with last committed version | |||
**** '''Commit''': Commit changes to your local repository | |||
**** '''Push''': Push changes from your local repository to GitHub | |||
* Introduce to '''Simple Motor'''. | |||
** Exercise: Creating and Controlling a Simple Motor. | |||
*** '''RobotParams.java''': Add a switch for the Simple Motor in Preferences. | |||
*** '''Robot.java''': Instantiate and initialize a Simple Motor in the ''robotInit'' method. | |||
**** Create ''FrcCANTalonSRX'' | |||
**** Reset to factory default | |||
**** Enable Voltage Compensation | |||
**** Enable Brake Mode | |||
**** Invert Motor Direction (if appropriate) | |||
*** '''Robot.java''': In the ''updateStatus'' method, add code to display the motor status: joystick value, actual motor power. | |||
*** '''FrcTeleOp.java''': Create code to control the Simple Motor in TeleOp. | |||
**** In the ''periodic'' method, add code to read the gamepad joystick and set motor power with the value. | |||
==== Hardware ==== | |||
* Simple DC motor | |||
* Robot-In-A-Box | |||
* Driver Station with a Gamepad | |||
=== Session 2: Simple Servo === | |||
==== Topics ==== | |||
* Introduce to '''Simple Servo'''. | |||
** Exercise: Creating and Controlling a Simple Servo. | |||
*** '''RobotParams.java''': Add a switch for the Simple Servo in Preferences. | |||
*** '''Robot.java''': Instantiate and initialize a Simple Servo in the ''robotInit'' method. | |||
**** Create ''FrcServo'' | |||
**** Set Logical Range | |||
**** Set Physical Range | |||
**** Set Maximum Step Rate | |||
**** Add Servo Follower (if appropriate) | |||
**** Invert Servo Direction (if appropriate) | |||
**** Set Servo to initial position | |||
*** '''Robot.java''': In the ''updateStatus'' method, add code to display the servo status: servo power, servo position. | |||
*** '''FrcTeleOp.java''': Create code to control the Simple Servo in TeleOp. | |||
**** In the ''driverControllerButtonEvent'' method, add code to move servo to a set position on a button press and back on a button release | |||
**** In the ''periodic'' method, add code to read the gamepad joystick and set the servo power with the value | |||
==== Hardware ==== | |||
* Servo | |||
* Robot-In-A-Box | |||
* Driver Station with a Gamepad | |||
=== Session 3: Elevator Subsystem === | |||
==== Topics ==== | |||
* Introduce to '''PID Control'''. | |||
* Introduce to the '''Motor Actuator''' class. | |||
** Motor Actuator Parameters: | |||
*** '''setPrimaryMotor''': Set the characteristics of the primary motor. | |||
*** '''setFollowerMotor''': Set the characteristics of the follower motor if there is one. | |||
*** '''setLowerLimitSwitch''': Set the characteristics of the lower limit switch if there is one. | |||
*** '''setUpperLimitSwitch''': Set the characteristics of the upper limit switch if there is one. | |||
*** '''setExternalEncoder''': Set the characteristics of the external encoder if there is one. | |||
*** '''setPositionScaleAndOffset''': Set motor position scale and offset for translating to real world units | |||
*** '''setPositionPresets''': Set position presets | |||
** Exercise: Creating and Controlling an Elevator as a Motor Actuator. | |||
*** '''Elevator.java''': Create a new class named ''Elevator''. | |||
**** Create the parameters for the Elevator | |||
***** Set the characteristics of the primary motor | |||
***** Set the characteristics of the follower motor if there is one | |||
***** Set Elevator scale and offset to real world unit in inches | |||
***** Set position presets if appropriate | |||
**** Create the Elevator as a Motor Actuator using the parameters | |||
**** Enable software PID control | |||
**** Set PID Coefficients and Tolerance | |||
**** Set PID Power Compensation | |||
**** Optionally set Stall Protection | |||
*** '''RobotParams.java''': Add a switch for the Elevator in Preferences. | |||
*** '''Robot.java''': Instantiate and initialize the Elevator object in the ''robotInit'' method. | |||
**** Create Elevator object | |||
**** Add code to zero calibrate the Elevator | |||
*** '''Robot.java''': In the ''updateStatus'' method, add code to display the Elevator status: power, pos/target, state of limit switches. | |||
*** '''FrcTeleOp.java''': Create code to control the Elevator in TeleOp. | |||
**** In the ''periodic'' method, add code to read the gamepad joystick and set Elevator power with the value (setPower and setPidPower) | |||
**** In the ''driverControllerButtonEvent'' method, add code to use the DPad to move the Elevator up and down the preset positions | |||
*** Calibrate Elevator Scale, Offset and Position Limits. | |||
*** Tune Elevator position PID control. | |||
*** Tune Elevator gravity compensation. | |||
==== Hardware ==== | |||
* Screw-driven elevator | |||
* DC motor with built-in encoder | |||
* Lower limit switch (optional) | |||
* Robot-In-A-Box | |||
* Driver Station with a Gamepad | |||
=== Session 4: Arm Subsystem === | |||
==== Topics ==== | |||
* Introduce Arm Subsystem as a Motor Actuator. | |||
** Exercise: Creating and Controlling an Arm as a Motor Actuator. | |||
*** '''Arm.java''': Create a new class named ''Arm''. | |||
**** Create the parameters for the Arm | |||
***** Set the characteristics of the primary motor | |||
***** Set the characteristics of the follower motor if there is one | |||
***** Set Arm scale and offset to real world unit in degrees | |||
***** Set position presets if appropriate | |||
**** Create the Arm as a Motor Actuator using the parameters | |||
**** Enable software PID control | |||
**** Set PID Coefficients and Tolerance | |||
**** Set PID Power Compensation | |||
**** Optionally set Stall Protection | |||
*** '''Robot.java''': Instantiate and initialize the Arm object. Add code to zero calibrate the Arm. | |||
*** '''Robot.java''': In the ''updateStatus'' method, add code to display the Arm status: power, pos/target, state of limit switches | |||
*** '''FrcTeleOp.java''': Create code to control the Arm in TeleOp. | |||
**** In the ''periodic'' method, add code to read the gamepad joystick and set Arm power with the value (setPower and setPidPower) | |||
**** In the ''driverControllerButtonEvent'' method, add code to use the DPad to move the Arm up and down the preset positions | |||
*** Calibrate Arm Scale, Offset and Position Limits. | |||
*** Tune Arm position PID control. | |||
*** Tune Arm gravity compensation. | |||
===== Hardware ===== | |||
* Swing Arm with elbow | |||
* DC motor with built-in encoder to drive the elbow | |||
* Lower limit switch (optional) | |||
* Robot-In-A-Box | |||
* Driver Station with a Gamepad | |||
=== Session 5: Turret Subsystem === | |||
==== Topics ==== | |||
* Introduce Turret Subsystem as a Motor Actuator. | |||
** Exercise: Creating and Controlling a Turret as a Motor Actuator. | |||
*** '''Turret.java''': Create a new class named ''Turret''. | |||
**** Create the parameters for the Turret | |||
***** Set the characteristics of the primary motor | |||
***** Set the characteristics of the follower motor if there is one | |||
***** Set Turret scale and offset to real world unit in degrees | |||
***** Set position presets if appropriate | |||
**** Create the Turret as a Motor Actuator using the parameters | |||
**** Enable software PID control | |||
**** Set PID Coefficients and Tolerance | |||
**** Optionally set Stall Protection | |||
*** '''Robot.java''': Instantiate and initialize the Turret object. Add code to zero calibrate the Turret. | |||
*** '''Robot.java''': In the ''updateStatus'' method, add code to display the Turret status: power, pos/target, state of limit switches | |||
*** '''FrcTeleOp.java''': Create code to control the Turret in TeleOp. | |||
**** In the ''periodic'' method, add code to read the gamepad joystick and set Turret power with the value (setPower and setPidPower) | |||
**** In the ''driverControllerButtonEvent'' method, add code to use the DPad to move the Turret left and right of the preset positions | |||
*** Calibrate Turret Scale, Offset and Position Limits. | |||
*** Tune Turret position PID control. | |||
==== Hardware ==== | |||
* Turret with rotating base | |||
* DC motor with built-in encoder to drive the rotating base | |||
* Zero position limit switch | |||
* Rotation direction limit switch | |||
* Robot-In-A-Box | |||
* Driver Station with a Gamepad | |||
=== Session 6: Shooter Subsystem === | |||
==== Topics ==== | |||
* Introduce Shooter Subsystem (one/two-motor shooter with optional pan/tilt motor actuators). | |||
** Exercise: Creating and Controlling a Shooter. | |||
*** '''Shooter.java''': Create a new class named ''Shooter''. | |||
**** Create the parameters for the Shooter: one or two shooter motors, optional pan/tilt motor actuators | |||
***** Set the characteristics of the shooter motor 1 | |||
***** Set the characteristics of the shooter motor 2 if there is one | |||
**** Create the Shooter using the parameters | |||
**** Set Shooter scale to real world units in RPM | |||
**** Enable software PID control | |||
**** Set PID Coefficients and Tolerance | |||
**** Optionally set Shooter Preset Velocities | |||
*** '''Robot.java''': Instantiate and initialize the Shooter object. | |||
*** '''Robot.java''': In the ''updateStatus'' method, add code to display the Shooter motor status: power, vel/target | |||
*** '''FrcTeleOp.java''': Create code to control the Shooter in TeleOp. | |||
**** In the ''driverControllerButtonEvent'' method, add code to use the DPad to increment/decrement the Shooter velocities | |||
**** In the ''periodic'' method, add code to set the shooter velocity with the value set by the DPad | |||
*** Tune Shooter velocity PID control. | |||
==== Hardware ==== | |||
* Shooter with two motors | |||
* DC motor with built-in encoder as the shooter motors | |||
* Robot-In-A-Box | |||
* Driver Station with a Gamepad | |||
=== Session 7: Intake Subsystem === | |||
==== Topics ==== | |||
* Introduce Smart Intake Subsystem (one/two motor intake with optional digital/analog sensor). | |||
** Exercise: Creating and Controlling a one/two motor Intake with digital/analog sensor. | |||
*** '''Intake.java''': Create a new class named ''Intake''. | |||
**** Create the parameters for the Intake: one motor with optional follower motor and a digital/analog sensor | |||
***** Set the characteristics of the primary motor | |||
***** Set the characteristics of the follower motor if there is one | |||
***** Set the characteristics of the sensor if there is one | |||
**** Create the Intake using the parameters | |||
*** '''Robot.java''': Instantiate and initialize the Intake object. | |||
*** '''Robot.java''': In the ''updateStatus'' method, add code to display the Intake status: motor power, sensor state and hasObject. | |||
*** '''FrcTeleOp.java''': Create code to control the Intake in TeleOp. | |||
**** In the ''driverControllerButtonEvent'' method, add code to press a button to turn AutoIntake ON and release to cancel the operation. | |||
*** Tune the analog threshold value if it is an analog sensor. | |||
==== Hardware ==== | |||
* Intake with rotating brushes or rollers | |||
* DC motor (no encoder needed) to drive the intake | |||
* Sensor to detect the presence of game element taken in | |||
* Robot-In-A-Box | |||
* Driver Station with a Gamepad | |||
=== Session 8: Grabber Subsystem === | |||
==== Topics ==== | |||
* Introduce Smart Grabber Subsystem (one/two servo with optional digital/analog sensor). | |||
** Exercise: Creating and Controlling a one/two servo Grabber with digital/analog sensor. | |||
*** '''Grabber.java''': Create a new class named ''Grabber''. | |||
**** Create the parameters for the Grabber: one/two servo with optional digital/analog sensor | |||
***** Set the characteristics of the primary servo | |||
***** Set the characteristics of the follower servo if there is one | |||
***** Set the characteristics of the sensor trigger if there is a sensor | |||
**** Create the Grabber using the parameters | |||
*** '''Robot.java''': Instantiate and initialize the Grabber object. | |||
*** '''Robot.java''': In the ''updateStatus'' method, add code to display the Grabber status: servo position, sensor state and hasObject. | |||
*** '''FrcTeleOp.java''': Create code to control the Grabber in TeleOp. | |||
**** In the ''driverControllerButtonEvent'' method, add code to press a button to turn AutoGrabber ON and release to cancel the operation. | |||
*** Tune the analog threshold value if it is an analog sensor. | |||
==== Hardware ==== | |||
* Grabber with servo-controlled claws | |||
* One or two servos | |||
* Sensor to detect the presence of game element grabbed | |||
* Robot-In-A-Box | |||
* Driver Station with a Gamepad | |||
=== Session 9: Drive Base Subsystem === | |||
* Introduce Drive Base Subsystem. | |||
** '''Differential Drive Base''' | |||
*** 4/6-wheel differential drive train (West Coast Drive). | |||
*** Non-holonomic drive: 2-DOF (Degrees of Freedom) - Forward/Backward and Turn. | |||
*** Kinematics: Translate 2-DOF to left and right wheel power. | |||
** '''Mecanum Drive Base''' | |||
*** 4-wheel Mecanum wheel drive train. | |||
*** Holonomic drive: 3-DOF (Degrees of Freedom) - Forward/Backward, Strafe Left/Right, Turn. | |||
*** Kinematics: Translate 3-DOF to four independent wheel powers. | |||
** '''Swerve Drive Base''' | |||
*** 4-swerve module drive train. | |||
*** Holonomic drive: 3-DOF (Degrees of Freedom) - Forward/Backward, Strafe Left/Right, Turn (all four wheels steerable). | |||
*** Kinematics: Translate 3-DOF to four independent wheel powers as well as steering positions. | |||
** Exercise: Creating and Controlling a Drive Base. | |||
*** '''DifferentialDrive.java, MecanumDrive.java, SwerveDrive.java''': No need to create these because the Template code already provides them. | |||
*** '''RobotParams.java''': Creates the parameters for the Drive Base. A lot of these parameters are already provided because we standardize most of them. Some parameters are specific to the robot base for the season and need to be determined. | |||
**** Wheel-Base Length and Width: these must be provided for Swerve Drive kinematics | |||
**** Drive Motor Names: these are standardized and should not change | |||
**** Drive Motor IDs: these are standardized and should not change | |||
**** Drive Motor Inverted: these should be adjusted according to the motor directions of each drive wheel | |||
**** Steer Motor Names: these are standardized for Swerve Drive only and should not change | |||
**** Steer Motor IDs: these are standardized for Swerve Drive only and should not change | |||
**** Steer Motor Inverted: these should be adjusted according to the steer motor direction of each swerve module | |||
**** Steer Motor Scale: these should be determined by the steering encoder resolution and gear ratio | |||
**** Steer Encoder Types: these should be specified according to the steering encoders being used | |||
**** Steer Encoder Names: these are standardized for Swerve Drive only and should not change | |||
**** Steer Encoder IDs: these are standardized for Swerve Drive only and should not change | |||
**** Steer Encoder Inverted: these should be adjusted according to the encoder directions of the swerve modules | |||
**** Steer Encoder Zero Positions: these should be calibrated for each swerve module | |||
**** Steer PID Coefficients: these should be tuned for the swerve modules | |||
**** Steer Module Names: these are standardized for Swerve Drive only and should not change | |||
**** Drive Base Kinematics Scale: X, Y and Turn scales must be calibrated | |||
**** Drive Base Performance Parameters (max velocity, max acceleration, max turn rate etc.): these should be determined | |||
*** '''Robot.java''': Instantiate the appropriate Drive Base for the robot. | |||
*** '''Robot.java''': In the ''updateStatus'' method, the Template already provided code to display the Drive Base status: drive wheel encoder values, steer encoder values, drive base odometry. | |||
*** '''FrcTeleOp.java''': In the ''periodic'' method, the Template already provided code to read joystick values to control the driving of the Drive Base. | |||
*** '''FrcTeleOp.java''': In the ''driverControllerButtonEvent'' method, the Template also provided code to react to different buttons to modify driving modes (e.g. Field vs Robot oriented driving, slow vs normal drive speed etc.). | |||
*** Tune Swerve Drive Steering PID Coefficients. | |||
*** Tune Drive Base Odoemetry Scales. | |||
*** Tune Drive Base PID Coefficients. | |||
==== Hardware ==== | |||
* FTC Swerve Drive Base with FRC electronics | |||
* Passive Odometry | |||
* Driver Station with a Gamepad | |||
=== Session 10: Vision Subsystem === | |||
* Introduce Robotics Vision Subsystem. | |||
** Vision running on the Robot Controller | |||
*** CPU intensive, may affect robot performance | |||
** Vision running on Vision Coprocessor | |||
*** FTC: Limelight 3A | |||
*** FRC: Limelight 3, Raspberry Pi, NVidia Jetson | |||
** Vision Processing | |||
*** '''AprilTag Detection''' | |||
**** Giant ''QR Code'' placed around the field | |||
**** Identify fixed game elements around the field | |||
**** Localization of the robot | |||
*** '''Object Recognition''' | |||
**** Neural Network based object recognition | |||
**** CPU intensive, better with Vision Coprocessor | |||
**** Identify scoring elements on the field | |||
**** Enable auto pickup or scoring | |||
*** '''Color Blob Detection''' | |||
**** OpenCV based object detection by color | |||
**** Does not understand object type and shape | |||
**** Require result filtering to reduce false positives | |||
** Vision Detected Object Information | |||
*** Detected Object Raw Info: specific to the detected object type | |||
*** Detected Object Rectangle: object rectangle from the camera in screen pixel coordinate | |||
*** Detected Object Width, Height and Area: object dimension info for filtering if necessary | |||
*** Detected Object Pose: Pose information of the detected object relative to the camera | |||
*** Robot Pose: Robot Field Pose info (from AprilTag) | |||
** How Vision Pipeline Works? | |||
*** Vision pipeline starts with capturing a video frame for processing. | |||
*** Process the frame to detect the object(s). | |||
*** Compute detected object info. | |||
*** Communicate the result back to the Robot Controller. | |||
**** FTC: Coprocessor communicates via USB or I2C | |||
**** FRC: Coprocessor communicates via Ethernet using Network Table | |||
*** Vision processing is asynchronous: When calling vision to detect an object, it will return immediately either with the result of the last detected object or with a null if it is still busy processing the next frame. | |||
*** When calling vision, caller must check if the returned result has the info or if it is null. If it is null, it may mean Vision is still busy processing the next frame or it doesn't find the object it is seeking. In either case, the caller needs to keep calling Vision repeatedly until either it finds the object(s) or it has reached the timeout limit. One should always set a timeout when calling Vision repeatedly to prevent the code hanging forever if Vision doesn't find anything. | |||
*** Once the detected object info is obtained, the caller can use the info to determine what to do with it. | |||
**** Determine the object type detected or object position so to perform the subsequent tasks accordingly (e.g. detected team prop position in FTC). | |||
**** Navigate the robot towards the detected object as the scoring location or to pick the object up. | |||
==== Hardware ==== | |||
* Robot-In-A-Box | |||
* Raspberry Pi Coprocessor | |||
* USB camera | |||
=== Session 11: Path Following === | |||
* Introduce to Path Following | |||
** PID Drive | |||
** Pure Pursuit Drive | |||
=== Session 12: Auto-Assist Pickup === | |||
* DriveBase | |||
* Intake | * Intake | ||
* | * Vision | ||
=== Session 13: Auto-Assist Shoot === | |||
* DriveBase | |||
* Shooter | * Shooter | ||
* | * Vision | ||
== | === Session 14: Autonomous === | ||
* Asynchronous operations | |||
* Synchronization | |||
* State machine |
Latest revision as of 14:46, 18 August 2024
The Advanced Robotics Programming Class focuses on teaching our Titan Robotics Framework (TRC Library). The target audience is for students who already know the Java language. Titan Robotics Framework is designed for both FTC and FRC. After finishing this class, you should be able to write code for both FTC and FRC robots with minimal platform specific changes.
Titan Robotics Framework
You can read about our Framework Library here
Class Curriculum
Session 0: Pre-Work
Before coming to the programming class, you need to install the required software on your laptop. Please do this at home before coming to class. We do not want to dedicate class time to install software because they are time consuming and require downloading gigabytes of data from the Internet which would overwhelm our Internet bandwidth if all students were downloading at the same time. Therefore, please make sure you finish these tasks at home before coming to class. FRC software installation instructions can be found here.
- Create GitHub account if not already have one.
- Download and install GitHub Desktop.
- Clone FrcTemplate project.
- Download and install WPILib with Visual Studio Code.
- Download and install Git Command Line tools.
Session 1: Simple Motor
Topics
- Introduce to Visual Studio Code.
- Start Visual Studio Code.
- Open FrcTemplate project in Visual Studio Code.
- Brief walk through of FrcTemplate code: Code organization (team492, trclib, frclib)
- autocommands: contains Autonomous code
- autotasks: contains Auto-Assist tasks
- commandbased: contains commandbased code (not used)
- drivebases: contains standard supported drive bases (Differential, Mecanum, Swerve)
- subsystems: contains code for all upper subsystems
- Main.java: main entry point of robot code (provided by FIRST, do not change)
- Robot.java: top level robot object
- RobotParams.java: contains robot configurations and subsystem parameters
- FrcAuto.java, FrcTeleOp.java, FrcTest.java, FrcDisabled.java: contain code for respective robot run mode
- Brief walk through of Visual Studio Code.
- WPILib Plug-in (commonly used operations)
- Set Team Number: set our team number 492 (Very important: team number is used to find our robot for pushing code)
- Check for WPILib Updates: Check for latest WPILib from the Internet
- Manage Vendor Libraries: Install/Remove/CheckUpdate of various 3rd party vendor libraries
- Build Robot Code: Compile your robot code
- Depoloy Robot Code: Compile and push code to robot
- Debug Robot Code: Compile, push code to robot and start real time debugger
- Common Source Control Operations
- Branches: Create/Remove/Switch code branches
- Fetch: Sync latest changes from GitHub
- Discard: Discard changes to a file and revert back to last committed version
- Stage: Stage the changed file for commit
- Compare changes: Compare the changes with last committed version
- Commit: Commit changes to your local repository
- Push: Push changes from your local repository to GitHub
- WPILib Plug-in (commonly used operations)
- Introduce to Simple Motor.
- Exercise: Creating and Controlling a Simple Motor.
- RobotParams.java: Add a switch for the Simple Motor in Preferences.
- Robot.java: Instantiate and initialize a Simple Motor in the robotInit method.
- Create FrcCANTalonSRX
- Reset to factory default
- Enable Voltage Compensation
- Enable Brake Mode
- Invert Motor Direction (if appropriate)
- Robot.java: In the updateStatus method, add code to display the motor status: joystick value, actual motor power.
- FrcTeleOp.java: Create code to control the Simple Motor in TeleOp.
- In the periodic method, add code to read the gamepad joystick and set motor power with the value.
- Exercise: Creating and Controlling a Simple Motor.
Hardware
- Simple DC motor
- Robot-In-A-Box
- Driver Station with a Gamepad
Session 2: Simple Servo
Topics
- Introduce to Simple Servo.
- Exercise: Creating and Controlling a Simple Servo.
- RobotParams.java: Add a switch for the Simple Servo in Preferences.
- Robot.java: Instantiate and initialize a Simple Servo in the robotInit method.
- Create FrcServo
- Set Logical Range
- Set Physical Range
- Set Maximum Step Rate
- Add Servo Follower (if appropriate)
- Invert Servo Direction (if appropriate)
- Set Servo to initial position
- Robot.java: In the updateStatus method, add code to display the servo status: servo power, servo position.
- FrcTeleOp.java: Create code to control the Simple Servo in TeleOp.
- In the driverControllerButtonEvent method, add code to move servo to a set position on a button press and back on a button release
- In the periodic method, add code to read the gamepad joystick and set the servo power with the value
- Exercise: Creating and Controlling a Simple Servo.
Hardware
- Servo
- Robot-In-A-Box
- Driver Station with a Gamepad
Session 3: Elevator Subsystem
Topics
- Introduce to PID Control.
- Introduce to the Motor Actuator class.
- Motor Actuator Parameters:
- setPrimaryMotor: Set the characteristics of the primary motor.
- setFollowerMotor: Set the characteristics of the follower motor if there is one.
- setLowerLimitSwitch: Set the characteristics of the lower limit switch if there is one.
- setUpperLimitSwitch: Set the characteristics of the upper limit switch if there is one.
- setExternalEncoder: Set the characteristics of the external encoder if there is one.
- setPositionScaleAndOffset: Set motor position scale and offset for translating to real world units
- setPositionPresets: Set position presets
- Exercise: Creating and Controlling an Elevator as a Motor Actuator.
- Elevator.java: Create a new class named Elevator.
- Create the parameters for the Elevator
- Set the characteristics of the primary motor
- Set the characteristics of the follower motor if there is one
- Set Elevator scale and offset to real world unit in inches
- Set position presets if appropriate
- Create the Elevator as a Motor Actuator using the parameters
- Enable software PID control
- Set PID Coefficients and Tolerance
- Set PID Power Compensation
- Optionally set Stall Protection
- Create the parameters for the Elevator
- RobotParams.java: Add a switch for the Elevator in Preferences.
- Robot.java: Instantiate and initialize the Elevator object in the robotInit method.
- Create Elevator object
- Add code to zero calibrate the Elevator
- Robot.java: In the updateStatus method, add code to display the Elevator status: power, pos/target, state of limit switches.
- FrcTeleOp.java: Create code to control the Elevator in TeleOp.
- In the periodic method, add code to read the gamepad joystick and set Elevator power with the value (setPower and setPidPower)
- In the driverControllerButtonEvent method, add code to use the DPad to move the Elevator up and down the preset positions
- Calibrate Elevator Scale, Offset and Position Limits.
- Tune Elevator position PID control.
- Tune Elevator gravity compensation.
- Elevator.java: Create a new class named Elevator.
- Motor Actuator Parameters:
Hardware
- Screw-driven elevator
- DC motor with built-in encoder
- Lower limit switch (optional)
- Robot-In-A-Box
- Driver Station with a Gamepad
Session 4: Arm Subsystem
Topics
- Introduce Arm Subsystem as a Motor Actuator.
- Exercise: Creating and Controlling an Arm as a Motor Actuator.
- Arm.java: Create a new class named Arm.
- Create the parameters for the Arm
- Set the characteristics of the primary motor
- Set the characteristics of the follower motor if there is one
- Set Arm scale and offset to real world unit in degrees
- Set position presets if appropriate
- Create the Arm as a Motor Actuator using the parameters
- Enable software PID control
- Set PID Coefficients and Tolerance
- Set PID Power Compensation
- Optionally set Stall Protection
- Create the parameters for the Arm
- Robot.java: Instantiate and initialize the Arm object. Add code to zero calibrate the Arm.
- Robot.java: In the updateStatus method, add code to display the Arm status: power, pos/target, state of limit switches
- FrcTeleOp.java: Create code to control the Arm in TeleOp.
- In the periodic method, add code to read the gamepad joystick and set Arm power with the value (setPower and setPidPower)
- In the driverControllerButtonEvent method, add code to use the DPad to move the Arm up and down the preset positions
- Calibrate Arm Scale, Offset and Position Limits.
- Tune Arm position PID control.
- Tune Arm gravity compensation.
- Arm.java: Create a new class named Arm.
- Exercise: Creating and Controlling an Arm as a Motor Actuator.
Hardware
- Swing Arm with elbow
- DC motor with built-in encoder to drive the elbow
- Lower limit switch (optional)
- Robot-In-A-Box
- Driver Station with a Gamepad
Session 5: Turret Subsystem
Topics
- Introduce Turret Subsystem as a Motor Actuator.
- Exercise: Creating and Controlling a Turret as a Motor Actuator.
- Turret.java: Create a new class named Turret.
- Create the parameters for the Turret
- Set the characteristics of the primary motor
- Set the characteristics of the follower motor if there is one
- Set Turret scale and offset to real world unit in degrees
- Set position presets if appropriate
- Create the Turret as a Motor Actuator using the parameters
- Enable software PID control
- Set PID Coefficients and Tolerance
- Optionally set Stall Protection
- Create the parameters for the Turret
- Robot.java: Instantiate and initialize the Turret object. Add code to zero calibrate the Turret.
- Robot.java: In the updateStatus method, add code to display the Turret status: power, pos/target, state of limit switches
- FrcTeleOp.java: Create code to control the Turret in TeleOp.
- In the periodic method, add code to read the gamepad joystick and set Turret power with the value (setPower and setPidPower)
- In the driverControllerButtonEvent method, add code to use the DPad to move the Turret left and right of the preset positions
- Calibrate Turret Scale, Offset and Position Limits.
- Tune Turret position PID control.
- Turret.java: Create a new class named Turret.
- Exercise: Creating and Controlling a Turret as a Motor Actuator.
Hardware
- Turret with rotating base
- DC motor with built-in encoder to drive the rotating base
- Zero position limit switch
- Rotation direction limit switch
- Robot-In-A-Box
- Driver Station with a Gamepad
Session 6: Shooter Subsystem
Topics
- Introduce Shooter Subsystem (one/two-motor shooter with optional pan/tilt motor actuators).
- Exercise: Creating and Controlling a Shooter.
- Shooter.java: Create a new class named Shooter.
- Create the parameters for the Shooter: one or two shooter motors, optional pan/tilt motor actuators
- Set the characteristics of the shooter motor 1
- Set the characteristics of the shooter motor 2 if there is one
- Create the Shooter using the parameters
- Set Shooter scale to real world units in RPM
- Enable software PID control
- Set PID Coefficients and Tolerance
- Optionally set Shooter Preset Velocities
- Create the parameters for the Shooter: one or two shooter motors, optional pan/tilt motor actuators
- Robot.java: Instantiate and initialize the Shooter object.
- Robot.java: In the updateStatus method, add code to display the Shooter motor status: power, vel/target
- FrcTeleOp.java: Create code to control the Shooter in TeleOp.
- In the driverControllerButtonEvent method, add code to use the DPad to increment/decrement the Shooter velocities
- In the periodic method, add code to set the shooter velocity with the value set by the DPad
- Tune Shooter velocity PID control.
- Shooter.java: Create a new class named Shooter.
- Exercise: Creating and Controlling a Shooter.
Hardware
- Shooter with two motors
- DC motor with built-in encoder as the shooter motors
- Robot-In-A-Box
- Driver Station with a Gamepad
Session 7: Intake Subsystem
Topics
- Introduce Smart Intake Subsystem (one/two motor intake with optional digital/analog sensor).
- Exercise: Creating and Controlling a one/two motor Intake with digital/analog sensor.
- Intake.java: Create a new class named Intake.
- Create the parameters for the Intake: one motor with optional follower motor and a digital/analog sensor
- Set the characteristics of the primary motor
- Set the characteristics of the follower motor if there is one
- Set the characteristics of the sensor if there is one
- Create the Intake using the parameters
- Create the parameters for the Intake: one motor with optional follower motor and a digital/analog sensor
- Robot.java: Instantiate and initialize the Intake object.
- Robot.java: In the updateStatus method, add code to display the Intake status: motor power, sensor state and hasObject.
- FrcTeleOp.java: Create code to control the Intake in TeleOp.
- In the driverControllerButtonEvent method, add code to press a button to turn AutoIntake ON and release to cancel the operation.
- Tune the analog threshold value if it is an analog sensor.
- Intake.java: Create a new class named Intake.
- Exercise: Creating and Controlling a one/two motor Intake with digital/analog sensor.
Hardware
- Intake with rotating brushes or rollers
- DC motor (no encoder needed) to drive the intake
- Sensor to detect the presence of game element taken in
- Robot-In-A-Box
- Driver Station with a Gamepad
Session 8: Grabber Subsystem
Topics
- Introduce Smart Grabber Subsystem (one/two servo with optional digital/analog sensor).
- Exercise: Creating and Controlling a one/two servo Grabber with digital/analog sensor.
- Grabber.java: Create a new class named Grabber.
- Create the parameters for the Grabber: one/two servo with optional digital/analog sensor
- Set the characteristics of the primary servo
- Set the characteristics of the follower servo if there is one
- Set the characteristics of the sensor trigger if there is a sensor
- Create the Grabber using the parameters
- Create the parameters for the Grabber: one/two servo with optional digital/analog sensor
- Robot.java: Instantiate and initialize the Grabber object.
- Robot.java: In the updateStatus method, add code to display the Grabber status: servo position, sensor state and hasObject.
- FrcTeleOp.java: Create code to control the Grabber in TeleOp.
- In the driverControllerButtonEvent method, add code to press a button to turn AutoGrabber ON and release to cancel the operation.
- Tune the analog threshold value if it is an analog sensor.
- Grabber.java: Create a new class named Grabber.
- Exercise: Creating and Controlling a one/two servo Grabber with digital/analog sensor.
Hardware
- Grabber with servo-controlled claws
- One or two servos
- Sensor to detect the presence of game element grabbed
- Robot-In-A-Box
- Driver Station with a Gamepad
Session 9: Drive Base Subsystem
- Introduce Drive Base Subsystem.
- Differential Drive Base
- 4/6-wheel differential drive train (West Coast Drive).
- Non-holonomic drive: 2-DOF (Degrees of Freedom) - Forward/Backward and Turn.
- Kinematics: Translate 2-DOF to left and right wheel power.
- Mecanum Drive Base
- 4-wheel Mecanum wheel drive train.
- Holonomic drive: 3-DOF (Degrees of Freedom) - Forward/Backward, Strafe Left/Right, Turn.
- Kinematics: Translate 3-DOF to four independent wheel powers.
- Swerve Drive Base
- 4-swerve module drive train.
- Holonomic drive: 3-DOF (Degrees of Freedom) - Forward/Backward, Strafe Left/Right, Turn (all four wheels steerable).
- Kinematics: Translate 3-DOF to four independent wheel powers as well as steering positions.
- Exercise: Creating and Controlling a Drive Base.
- DifferentialDrive.java, MecanumDrive.java, SwerveDrive.java: No need to create these because the Template code already provides them.
- RobotParams.java: Creates the parameters for the Drive Base. A lot of these parameters are already provided because we standardize most of them. Some parameters are specific to the robot base for the season and need to be determined.
- Wheel-Base Length and Width: these must be provided for Swerve Drive kinematics
- Drive Motor Names: these are standardized and should not change
- Drive Motor IDs: these are standardized and should not change
- Drive Motor Inverted: these should be adjusted according to the motor directions of each drive wheel
- Steer Motor Names: these are standardized for Swerve Drive only and should not change
- Steer Motor IDs: these are standardized for Swerve Drive only and should not change
- Steer Motor Inverted: these should be adjusted according to the steer motor direction of each swerve module
- Steer Motor Scale: these should be determined by the steering encoder resolution and gear ratio
- Steer Encoder Types: these should be specified according to the steering encoders being used
- Steer Encoder Names: these are standardized for Swerve Drive only and should not change
- Steer Encoder IDs: these are standardized for Swerve Drive only and should not change
- Steer Encoder Inverted: these should be adjusted according to the encoder directions of the swerve modules
- Steer Encoder Zero Positions: these should be calibrated for each swerve module
- Steer PID Coefficients: these should be tuned for the swerve modules
- Steer Module Names: these are standardized for Swerve Drive only and should not change
- Drive Base Kinematics Scale: X, Y and Turn scales must be calibrated
- Drive Base Performance Parameters (max velocity, max acceleration, max turn rate etc.): these should be determined
- Robot.java: Instantiate the appropriate Drive Base for the robot.
- Robot.java: In the updateStatus method, the Template already provided code to display the Drive Base status: drive wheel encoder values, steer encoder values, drive base odometry.
- FrcTeleOp.java: In the periodic method, the Template already provided code to read joystick values to control the driving of the Drive Base.
- FrcTeleOp.java: In the driverControllerButtonEvent method, the Template also provided code to react to different buttons to modify driving modes (e.g. Field vs Robot oriented driving, slow vs normal drive speed etc.).
- Tune Swerve Drive Steering PID Coefficients.
- Tune Drive Base Odoemetry Scales.
- Tune Drive Base PID Coefficients.
- Differential Drive Base
Hardware
- FTC Swerve Drive Base with FRC electronics
- Passive Odometry
- Driver Station with a Gamepad
Session 10: Vision Subsystem
- Introduce Robotics Vision Subsystem.
- Vision running on the Robot Controller
- CPU intensive, may affect robot performance
- Vision running on Vision Coprocessor
- FTC: Limelight 3A
- FRC: Limelight 3, Raspberry Pi, NVidia Jetson
- Vision Processing
- AprilTag Detection
- Giant QR Code placed around the field
- Identify fixed game elements around the field
- Localization of the robot
- Object Recognition
- Neural Network based object recognition
- CPU intensive, better with Vision Coprocessor
- Identify scoring elements on the field
- Enable auto pickup or scoring
- Color Blob Detection
- OpenCV based object detection by color
- Does not understand object type and shape
- Require result filtering to reduce false positives
- AprilTag Detection
- Vision Detected Object Information
- Detected Object Raw Info: specific to the detected object type
- Detected Object Rectangle: object rectangle from the camera in screen pixel coordinate
- Detected Object Width, Height and Area: object dimension info for filtering if necessary
- Detected Object Pose: Pose information of the detected object relative to the camera
- Robot Pose: Robot Field Pose info (from AprilTag)
- How Vision Pipeline Works?
- Vision pipeline starts with capturing a video frame for processing.
- Process the frame to detect the object(s).
- Compute detected object info.
- Communicate the result back to the Robot Controller.
- FTC: Coprocessor communicates via USB or I2C
- FRC: Coprocessor communicates via Ethernet using Network Table
- Vision processing is asynchronous: When calling vision to detect an object, it will return immediately either with the result of the last detected object or with a null if it is still busy processing the next frame.
- When calling vision, caller must check if the returned result has the info or if it is null. If it is null, it may mean Vision is still busy processing the next frame or it doesn't find the object it is seeking. In either case, the caller needs to keep calling Vision repeatedly until either it finds the object(s) or it has reached the timeout limit. One should always set a timeout when calling Vision repeatedly to prevent the code hanging forever if Vision doesn't find anything.
- Once the detected object info is obtained, the caller can use the info to determine what to do with it.
- Determine the object type detected or object position so to perform the subsequent tasks accordingly (e.g. detected team prop position in FTC).
- Navigate the robot towards the detected object as the scoring location or to pick the object up.
- Vision running on the Robot Controller
Hardware
- Robot-In-A-Box
- Raspberry Pi Coprocessor
- USB camera
Session 11: Path Following
- Introduce to Path Following
- PID Drive
- Pure Pursuit Drive
Session 12: Auto-Assist Pickup
- DriveBase
- Intake
- Vision
Session 13: Auto-Assist Shoot
- DriveBase
- Shooter
- Vision
Session 14: Autonomous
- Asynchronous operations
- Synchronization
- State machine