Skip to content

Latest commit

 

History

History
169 lines (139 loc) · 7.22 KB

README.md

File metadata and controls

169 lines (139 loc) · 7.22 KB

List of available classes and brief descriptions of their functions

Util

AlliancePose2d/AllianceTranslation2d

  • Wrapper on base geometry classes.
  • Input as Blue alliance version, use blue() or red() to get specific version
  • Use get() to get alliance specific version, based on driverstation alliance

Conversions

  • mod(value, base) returns mathematical modulus (default % operator doesn't handle negative correctly)
  • wrap(int, min, max) returns value within endpoints inclusive (default only handles double)
  • clamp() allows limits in any order (default needs min, max) with a range of overloads
    • int and double with endpoints
    • single input double clamps [-1..1]
    • input Translation2d clamps magnitude [0..1]
  • round(value, places) returns value rounded to places decimal places
  • buildPose() creates a new Pose2d from double values in metres and degrees
  • at[Pose/Translation/Rotation]() checks if input values are within standard tolerances (under ControlConstants) of each other
  • near[Pose/Translation/Rotation]() checks if input values are within input tolerances of eachother
  • normaliseAngle(newAngle, currentAngle, maxAngle) for turret-style rotation pathing
    • Works for any range of motion. Max angle is symetric, e.g. max=180 -> range=[-180..180]
    • Favours the centre over shortest path if shortest is >135 degrees

FieldUtils

  • alliance...() various functions for getting and comparing the current alliance
  • flip[Pose/Translation]() mirrors over centreline
  • rotate[Pose/Translation]() rotates 180 around field centre
  • inAllianceZone() checks if given position is fully within the defined alliance zone

Launchpad

  • Interface for launchpad controller
  • Predefined triggers for all buttons, can be used in the same way as normal controller buttons
  • Can set colour to individual buttons, spans of buttons, or use predefined display grids

LockableXboxController

  • Wrapper on CommandXboxController with a configurable button to unlock it with a rumble to confirm.
  • All buttons read false and axes read 0 while controller is locked.
  • Holding the unlock button for 1.5s (configurable) locks the controller again, with a rumble to confirm.

MatchTime

  • Time handler to convert ststem time to match time
  • startAuto() to calibrate the timing of the Auto period
  • startTele() to calibrate the timing of the Teleop period

PBDash

  • Custom NetworkTables interface with configurable data keys
  • Predefined keys can use any type, and are given a default value
    • Can be globally accessed through a variable rather than by string
    • get() and put() automatically handle the associated data type and set defaults appropriately
    • button() returns true when the value has changed, then resets it
    • Various triggers can be used to monitor the value
  • Generic access for int, double, boolean, and String, automatic default pushed on first use
  • Various functions to add objects to the field render
    • putFieldObject() sets position of named object(s)
    • addToFieldObject() appends poses to existing object, with padding to ensure it renders as a trajectory
    • putFieldPath() renders a line between given points
    • trailFieldObject() renders a line of the last 50 poses given

LEDs

Block

  • A defined string of LEDs within the whole strip, defined by length
  • Has no internal reference to its position in the strip. Start position is given when render() is called by the LEDStrip subsystem
  • Has option to render first 4 LEDs to network tables (setNetworkTableAddress(...))
  • Patterns can be applied to multiple blocks simultaneously

Patterns

  • dummy: no render
  • conditional: takes any two patterns to render based on boolean condition
  • supplied: takes a colour supplier
  • chase: two colours of given lengths, move by one pixel at given frequency. can be used for alternating patterns

ControlTransmutation

JoystickTransmuter

Brake

Deadband

CrossDeadband

InputCurve

GeoFence

TriggerObject

Subsystems

CommandSwerveDrivetrain

RumbleRequester

LEDStrip

Vision/Limelight

Generic

BinaryMotor

PositionMotor

  • Wrapper around a TalonFX motor for position control using Motion Magic.
  • All positions and targets are measured in mechanicsm rotations.
  • setTarget() set the target position; baseSetTarget()sends the target directly to the motor, bypassing overridden setTarget() method in subclasses.
  • Various commands for position control:
    • setTargetCmd() set a target once, accepting either fixed value or DoubleSupplier.
    • gotoTargetCmd() set a target and wait until the motor reaches it.
    • adjustTargetCmd() continuously adjust the target by the supply amount, mainly use for joystick control.
    • getAngle()/getPosition() return the current position; getTarget() returns the requested target.
    • atTarget() check whether the motor within 0.1 of its target, using the value returned by getTarget() and getPosition().
    • stop() sets motor output to zero; devicesValid() check the motor connection.
  • Stimultion:
    • Using DCMotorSim to caculated movement from the simulated motor voltage.
    • simulationPeriodic() updated the simulated motor position every simulation cycle.
    • Feeds simulated position back to the TalonFX motor.

LimitedMotor/LinearExtension

VelocityMotor

  • Wrapper around a TalonFX motor for position control using Motion Magic.
  • Controls motor speed in mechanism rotations per second
  • setSpeed() set the target motor velocity
  • setSpeedCmd() sets the velocity once using DoubleSupplier
  • runCmd() continously updates the target velocity from a Double Supplier, setting it to zero when the command ends.
  • getSpeed() returns the measured velocity
  • devicesValid() checks the motor connection.
  • Simulation:
    • Using DCMotorSim to caculated movement from the simulated motor voltage.
    • simulationPeriodic() updated the simulated motor velocity every simulation cycle.
    • Feeds simulated velocity back to the TalonFX motor.

BiMotor

  • Extend VelocityMotor to control two TalonFX motors together.
  • Use a leader-follower configuration, where the second motor follow the first.
  • Constructor accepts seperate CAN IDs fro the leader and the follower, a shared configuration, and flipped option.
  • The flipped option determines whether the follower runs aligned with or opposed to the leader.
  • Inherits velocity controls methods and commands from VelocityMotor.
  • Overrides devicesValid() to check that both motors are connected.

SpringMotor

  • Wrapper around a TalonFX motor for position control using two different Motion Magic configuration slots.
  • setTarget() stores the desired target position in mechamism rotations.
  • setTargetCmd() sets the target once, accepting etheir fixed value or a DoubleSupplier.
  • getAngle() returns the current motor position in mechamism rotations.
  • periodic() continuosly sends the target to the motor and selects the control slots based on its current position:
    • Slot 1
    • Slot 0

AutoBuilder

AutoBuilder

  • Takes text input from dashboard and converts it into a chain of tokens which are then parsed to generate an auto command

CommandGen

  • Contains the code to generate commands from input tokens
  • Check TODO marks in ParsedRepr.java to add new instruction options to the list
  • Check TODO marks in CommandGen.java to impliment new instruction options