Advanced Robotics Programming: Difference between revisions

From TrcWiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 56: Line 56:
**** Enable Voltage Compensation
**** Enable Voltage Compensation
**** Enable Brake Mode
**** Enable Brake Mode
**** Invert motor direction
**** Invert Motor Direction (if appropriate)
*** '''FrcTeleOp.java''': Create code to control the Simple Motor in TeleOp.
*** '''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.
**** In the ''periodic'' method, add code to read the gamepad joystick and set motor power with the value.

Revision as of 16:50, 26 July 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

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

  • Verify software setup.
    • Visual Studio Code with WPILib
    • FrcTemplate project cloned
  • 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)
        • 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
        • Check for WPILib Updates: Check for latest WPILib from the Internet
        • Manage Vendor Libraries: Install/Remove/CheckUpdate of various 3rd party vendor libraries
      • 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.
      • Robot.java: Instantiate and initialize a Simple Motor.
        • Create FrcCANTalonSRX
        • Reset to factory default
        • Enable Voltage Compensation
        • Enable Brake Mode
        • Invert Motor Direction (if appropriate)
      • 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.
        • In the updateStatus method, add code to display the motor status: joystick value, actual motor power.

Hardware

  • Simple DC motor
  • Robot-In-A-Box
  • Driver Station with a Gamepad

Session 2: Simple Servo and Elevator Subsystems

Topics

  • Introduce to Simple Servo.
    • Exercise: Creating and Controlling a Simple Servo.
      • Robot.java: Instantiate and initialize a Simple Servo.
        • 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
      • 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
        • In the periodic method, add code to read the gamepad joystick and set the servo power with the value
        • In the updateStatus method, add code to display the servo status: servo power, servo position.
  • Introduce to PID Control.
  • Introduce to the Motor Actuator class.
    • Motor Actuator Parameters:
      • setMotorInverted
      • setFollowerMotor
      • setLowerLimitSwitch
      • setUpperLimitSwitch
      • setExternalEncoder
      • setVoltageCompensationEnabled
      • setPositionScaleAndOffset
      • setPositionPresets
    • Exercise: Creating and Controlling an Elevator as a Motor Actuator.
      • Elevator.java: Create a new class named Elevator.
        • Create the parameters for the Elevator
        • 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
        • Optionally set Elevator Preset Positions
      • Robot.java: Instantiate and initialize the Elevator object. Add code to zero calibrate the Elevator.
      • 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
        • In the updateStatus method, add code to display the Elevator status: power, pos/target, state of limit switches
      • Calibrate Elevator Scale, Offset and Position Limits.
      • Tune elevator position PID control.

Hardware

  • Screw-driven elevator
  • DC motor with built-in encoder
  • Lower limit switch (optional)
  • Robot-In-A-Box
  • Driver Station with a Gamepad

Session 3: Arm Subsystem

Topics

  • Create the Arm class as a Motor Actuator.
  • Create code to instantiate an Arm subsystem.
  • Create code to control the arm in TeleOp.
  • Create code to display the state of the arm on the Dashboard.
  • Calibrate arm scale, offset and position limits.
  • Tune gravity compensation.
  • Tune arm position PID control.
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 4: Turret Subsystem

Topics

  • Create the Turret class as a Motor Actuator.
  • Create code to instantiate a Turret subsystem.
  • Create code to control the turret in TeleOp.
  • Create code to display the state of the turret on the Dashboard.
  • Determine the turret rotation scale.
  • Tune turret position PID control.

Hardware

  • Turret with rotating base (Old FRC turret stored on the shop shelf?)
  • 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 5: Intake Subsystem

Topics

  • Create the Intake class.
  • Create code to instantiate an Intake subsystem.
  • Create code to control the intake in TeleOp.
  • Create code to display the state of the intake on the Dashboard.
  • Tune the analog threshold value if it is an analog sensor.

Hardware

  • Intake with rotating brushes or rollers (Build one based on FTC Centerstage Intake)
  • 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 6: Grabber Subsystem

Topics

Hardware

Session 7: Shooter Subsystem

Topics

Hardware

Session 8: Vision Subsystem

  • AprilTag Detection
  • Object Detection
  • Color Blob Detection

Session 9: DriveBase Subsystem

  • Swerve PID Tuning
  • Odometry Tuning
  • DriveBase PID Tuning

Session 10: Path Following

  • PurePursuit

Session 11: Auto-Assist Pickup

  • DriveBase
  • Intake
  • Vision

Session 12: Auto-Assist Shoot

  • DriveBase
  • Shooter
  • Vision

Session 13: Autonomous

  • Asynchronous operations
  • Synchronization
  • State machine