Skip to content

Commit

Permalink
pseudocode written 💪
Browse files Browse the repository at this point in the history
based off TelescopingClimber.kt of 2022 robot
  • Loading branch information
NeonCoal committed Jan 10, 2024
1 parent 3a3aa6e commit ce9b76a
Showing 1 changed file with 44 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,47 @@ import edu.wpi.first.wpilibj2.boardmand.SubsystemBase
import org.littletonrobotics.junction.Logger
class TelescopingArm(val io: TelescopingClimberIO) : SubsystemBase() {

}
}

Pseudocode:
Class TelescopingArm
Define io as TelescopingClimberIO
Define inputs as TelescopingClimberIOInputs
Define loadedFeedForward as ElevatorFeedforward with load constants
Define noLoadFeedForward as ElevatorFeedForward with no-load constants
Define activelyHold as boolean, set initial value to false
Define PID constants (kP, kI, kD) with tunable numbers
Define desiredState as DesiredTelescopeStates
Define constraints as TrapezoidProfile.Constraints with max velocity and acceleration
Define leftSetpoint and rightSetpoint as TrapezoidProfile.State based on current positions and velocities

Method periodic()
Update inputs from IO
Log various inputs and states
If PID constants have changed, configure IO with new PID values

Define limit switch properties for left and right forward and reverse limits

Method setOpenLoop(leftPower, rightPower, useSoftLimits)
If using soft limits and limits are reached, set power to zero, else set provided power

Define currentPosition property
Return the greater of left or right position

Define currentState property
Determine current state based on the currentPosition within various ranges

Method setPosition(leftSetpoint, rightSetpoint, isUnderLoad)
Calculate acceleration for left and right
Update setpoints
Set position with appropriate feedforward calculation based on load

Method holdPosition(loaded)
Set position for left and right with feedforward calculation for zero velocity

Method zeroLeftEncoder()
Zero the left encoder via IO

Method zeroRightEncoder()
Zero the right encoder via IO
End Class

0 comments on commit ce9b76a

Please sign in to comment.