List of available classes and brief descriptions of their functions
AlliancePose2d/AllianceTranslation2d
- Wrapper on base geometry classes.
- Input as Blue alliance version, use
blue()orred()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)returnsvaluerounded toplacesdecimal placesbuildPose()creates a new Pose2d from double values in metres and degreesat[Pose/Translation/Rotation]()checks if input values are within standard tolerances (under ControlConstants) of each othernear[Pose/Translation/Rotation]()checks if input values are within input tolerances of eachothernormaliseAngle(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 allianceflip[Pose/Translation]()mirrors over centrelinerotate[Pose/Translation]()rotates 180 around field centreinAllianceZone()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
CommandXboxControllerwith 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 periodstartTele()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()andput()automatically handle the associated data type and set defaults appropriatelybutton()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, andString, 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 trajectoryputFieldPath()renders a line between given pointstrailFieldObject()renders a line of the last 50 poses given
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
LEDStripsubsystem setNetworkTableAddress(...)to render first 4 LEDs to network tables- 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
JoystickTransmuter
- Interface for modifying the output of a joystick.
- Define with supplier for each joystick axis, return is a Translation2d combining both.
- Takes in all other transmuter layers, and processes them in order:
- Rotation
- Deadband
- InputCurve
- Brake
- FieldObjectList
Brake
- Defined with additional axis (or other supplier) to scale joystick output
Deadband
- Clamps joystick value to
0when below deadband limit. - Rescales output to be [0..1] rather than [limit..1]
CrossDeadband
- Restricts output to whichever axis is greater, allowing for cardinal movement.
- Configurable overlap region behaviour:
<1- Deadband between axis, can only move if stick is close to an axis>1- Overlapping regions, giving smooth control unless close to an axis=1- Sharp change, control is only the closest axis
- Also impliments a regular deadband at the centre.
InputCurve
- Simple power curve applied to joystick value.
- Power
>1gives more fine control - Power
<1gives less fine control - Output always [-1..1] regardless of power
Rotation
- Arbitrarily rotates joystick input.
- Can be configured to monitor a value from the dashboard.
GeoFence
- Built from videogame collision detection logic, using vision localisation and swerve drive.
- Efficiently calculates the distance between the robot and the object, and reduces the component of the input in that direction down to 0 when the robot is in contact with it.
- Various shapes exist with their own processing behaviour.
radiusdefines the extent of the object beyond the simple geometry.bufferdefines the distance from the object where the robot starts to be affected.
TriggerObject
- Derived from GeoFence objects, primarily checks if the robot is within the area to allow for location-based triggers.
- Can apply a speed limit within the triggering area.
- TriggerVector defines a target and approach heading; while driving towards the target, the trigger will activate, and remain active while holding that input.
CommandSwerveDrivetrain
- Constructs and handles the CTRE hardware devices
RumbleRequester
- Provides a convenient interface for managing a controller's rumble.
- Each instance manages one side of one controller.
- Operates on requests: Rumbles while there are any requests, when all requests are removed it stops rumbling.
- Constructs a command that run the rumble request when scheduled and removes the request when finished.
LEDStrip
- Owns all LED blocks and manages them.
- Renders the LED blocks and patterns.
- Knows all the LED block's length.
Vision/Limelight
- Manages multiple photon or limelight cameras.
- Removes unwanted or uncertain tags before calculating.
- Estimates where on the field the robot is.
- Updates the turret headings.
BinaryMotor
- Simplest interface for TalonFX motor
- Define with default speed:
start()runs motor at default speed,stop()stops motor setSpeed()allows any speed to be used, if needed.runCmd()/startCmd()/reverseCmd()/stopCmd()/setSpeedCmd()return command form of
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 overriddensetTarget()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 bygetTarget()andgetPosition().stop()sets motor output to zero.devicesValid()check the motor connection.
- Simulation:
- 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.
EndLimitedMotor
- A motor with limited range, with an endstop sensor at one end of travel.
LimitedMotor
- Same as
EndLimitedMotor, except the sensor can be anywhere along the range of travel.
LinearExtension
- Wrapper around
PositionMotorconverting angles to linear distances with configurable ratio.
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
- 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