2022-Robot
Robot code for 2022 FRC Season by Argos, FRC team #1756
Loading...
Searching...
No Matches
ClimberSubsystem Class Reference

Controls the climber of the robot. More...

#include <climber_subsystem.h>

Inheritance diagram for ClimberSubsystem:

Public Member Functions

 ClimberSubsystem (const argos_lib::RobotInstance instance, const std::vector< ClimberPoint > *preClimbPoints)
 
void Periodic () override
 
void ManualControl (double hookSpeed, double armSpeed)
 manually moves the hook, and/or arm More...
 
void MoveHook (double hookSpeed)
 Move hook at specified percent speed. More...
 
void MoveArm (double armSpeed)
 Move arm at specified percent speed. More...
 
void UpdateHookHome ()
 Update hook home position. More...
 
void UpdateArmHome ()
 Update arm home position. More...
 
void ArmSetPosition (units::inch_t extension)
 Sets arm linear actuator positions under closed loop control. More...
 
void ArmSetPosition (units::inch_t extension, units::inches_per_second_t cruiseVelocity, units::inches_per_second_squared_t acceleration)
 Sets arm linear actuator positions under closed loop control using motion magic. More...
 
void HooksSetPosition (units::inch_t extension)
 Set hooks to a given position under closed-loop control. More...
 
void HooksSetPosition (units::inch_t extension, units::inches_per_second_t cruiseVelocity, units::inches_per_second_squared_t acceleration)
 Set hooks to a given position under closed-loop control using motion magic. More...
 
bool IsHookHomed ()
 Detect if hook homing is complete. More...
 
bool IsArmHomed ()
 Detect if arm homing is complete. More...
 
bool IsHookMoving ()
 Detect if hook is in motion. More...
 
bool IsArmMoving ()
 Detect if arm is in motion. More...
 
bool IsManualOverride ()
 Detect if manual control has been enabled. More...
 
void Disable ()
 Runs on robot disable to reset manual control. More...
 
void ManualOverride ()
 Override automatic control. More...
 
void SetHookSoftLimits ()
 Enables the hook soft limits. More...
 
void DisableHookSoftLimits ()
 Disables hook soft limit. More...
 
void SetClimbReady ()
 Readies the climber for climb sequence. More...
 
void ClimberToSetpoint (ClimberPoint setPoint)
 Closed-loop climber to set-point. More...
 
void SetClimbMotorsPID (char slot)
 Set Climb Motors PID slot to change power. More...
 
bool ClimberAtPoint (ClimberPoint target)
 Determing if the climber is at a setpoint. More...
 
void NextReadyPoint ()
 Go to the next ClimberPoint in the pre-climb sequence. More...
 
void PreviousReadyPoint ()
 Go to the previous ClimberPoint in the pre-climb sequence. More...
 
void AllowReady ()
 Allow climber to go through the ready sequence freely. Publicly exposes m_allowReady. More...
 
void DisallowReady ()
 Disable ability to go through ready sequence. Publicly exposes m_allowReady. More...
 
bool IsReadySequenceAllowed ()
 Publicly exposes m_allowReady. More...
 
bool ClimberReadyToClimb ()
 Determines if climber is able to climb current position. More...
 

Static Public Member Functions

template<typename T >
static constexpr bool InThreshold (const T value, const T target, const T threshold)
 Detect if a value is within a threshold of a target value. More...
 

Private Member Functions

bool HooksAtPosition (units::inch_t target)
 Detects if the hooks are at a particular target. More...
 
bool ArmsAtPosition (units::inch_t target)
 Detects if the arms are at a particular target. More...
 

Private Attributes

const argos_lib::CANAddress m_motorLiftRightAddr
 
const argos_lib::CANAddress m_motorLiftLeftAddr
 
const argos_lib::CANAddress m_motorMoveHookAddr
 
WPI_TalonFX m_motorLiftRight
 Right ball-screw driver motor for raising arms. More...
 
WPI_TalonFX m_motorLiftLeft
 Left ball-screw driver motor for raising arms. More...
 
WPI_TalonFX m_motorMoveHook
 Hook chain drive motor. More...
 
bool m_hookHomed
 True if the hooks are homed. More...
 
bool m_armHomed
 True if the arms are homed. More...
 
bool m_allowReady
 True if the climber can go through ready sequence. More...
 
bool m_manualOverride
 True if the operator has manually overriden while closed-loop is running. More...
 
const std::vector< ClimberPoint > * m_pPreClimbPoints
 std::vector containing ClimberPoints in the ready sequence More...
 
std::vector< ClimberPoint >::const_iterator m_itClimberPoint
 Random-Access iterator that points to a specific ClimberPoint in the readySequence (used as bi-directional) More...
 
argos_lib::NTMotorPIDTuner m_armPIDTuner
 Member for tuning arm PID controls. More...
 
argos_lib::NTMotorPIDTuner m_hookPIDTuner
 Member for tuning hook controls. More...
 

Detailed Description

Controls the climber of the robot.

Constructor & Destructor Documentation

◆ ClimberSubsystem()

ClimberSubsystem::ClimberSubsystem ( const argos_lib::RobotInstance  instance,
const std::vector< ClimberPoint > *  preClimbPoints 
)
explicit

Member Function Documentation

◆ AllowReady()

void ClimberSubsystem::AllowReady ( )

Allow climber to go through the ready sequence freely. Publicly exposes m_allowReady.

◆ ArmsAtPosition()

bool ClimberSubsystem::ArmsAtPosition ( units::inch_t  target)
private

Detects if the arms are at a particular target.

Parameters
targetTarget (height in inches) the arms should be at
Returns
true Arms are at target position
false Arms are outside target position

◆ ArmSetPosition() [1/2]

void ClimberSubsystem::ArmSetPosition ( units::inch_t  extension)

Sets arm linear actuator positions under closed loop control.

Parameters
extensionArm position where positive is upward

◆ ArmSetPosition() [2/2]

void ClimberSubsystem::ArmSetPosition ( units::inch_t  extension,
units::inches_per_second_t  cruiseVelocity,
units::inches_per_second_squared_t  acceleration 
)

Sets arm linear actuator positions under closed loop control using motion magic.

Parameters
extensionArm position where positive is upward
cruiseVelocityMax movement velocity
accelerationMax movement acceleration

◆ ClimberAtPoint()

bool ClimberSubsystem::ClimberAtPoint ( ClimberPoint  target)

Determing if the climber is at a setpoint.

Parameters
targetTarget point
Returns
true The climber is at the given point within acceptable error
false Climber not at point, or outside acceptable error

◆ ClimberReadyToClimb()

bool ClimberSubsystem::ClimberReadyToClimb ( )

Determines if climber is able to climb current position.

Returns
true Climber is a the end of the ready sequence, can climb
false Climber is not at the end of the ready sequence, cannot climb

◆ ClimberToSetpoint()

void ClimberSubsystem::ClimberToSetpoint ( ClimberPoint  setPoint)

Closed-loop climber to set-point.

Parameters
setPointPoint to send the climber to

◆ Disable()

void ClimberSubsystem::Disable ( )

Runs on robot disable to reset manual control.

◆ DisableHookSoftLimits()

void ClimberSubsystem::DisableHookSoftLimits ( )

Disables hook soft limit.

◆ DisallowReady()

void ClimberSubsystem::DisallowReady ( )

Disable ability to go through ready sequence. Publicly exposes m_allowReady.

◆ HooksAtPosition()

bool ClimberSubsystem::HooksAtPosition ( units::inch_t  target)
private

Detects if the hooks are at a particular target.

Parameters
targetTarget (in inches) the hooks should be at along their rails
Returns
true Hooks are at target position
false Hooks are outside target position

◆ HooksSetPosition() [1/2]

void ClimberSubsystem::HooksSetPosition ( units::inch_t  extension)

Set hooks to a given position under closed-loop control.

Parameters
extensionHook position where 0 is at the shoulder and positive is outward

◆ HooksSetPosition() [2/2]

void ClimberSubsystem::HooksSetPosition ( units::inch_t  extension,
units::inches_per_second_t  cruiseVelocity,
units::inches_per_second_squared_t  acceleration 
)

Set hooks to a given position under closed-loop control using motion magic.

Parameters
extensionHook position where 0 is at the shoulder and positive is outward
cruiseVelocityMax movement velocity
accelerationMax movement acceleration

◆ InThreshold()

template<typename T >
static constexpr bool ClimberSubsystem::InThreshold ( const T  value,
const T  target,
const T  threshold 
)
inlinestaticconstexpr

Detect if a value is within a threshold of a target value.

Template Parameters
TType that implements operator+(), operator-(), operator<=() and operator>=()
Parameters
valueValue to check
targetCenter of range
thresholdAllowable error from target
Returns
true when value is within threshold of target, false otherwise

◆ IsArmHomed()

bool ClimberSubsystem::IsArmHomed ( )

Detect if arm homing is complete.

Returns
True when arm is homed

◆ IsArmMoving()

bool ClimberSubsystem::IsArmMoving ( )

Detect if arm is in motion.

Returns
True when arm is in motion

◆ IsHookHomed()

bool ClimberSubsystem::IsHookHomed ( )

Detect if hook homing is complete.

Returns
True when hook is homed

◆ IsHookMoving()

bool ClimberSubsystem::IsHookMoving ( )

Detect if hook is in motion.

Returns
True when hook is moving

◆ IsManualOverride()

bool ClimberSubsystem::IsManualOverride ( )

Detect if manual control has been enabled.

Returns
True when manual control is active

◆ IsReadySequenceAllowed()

bool ClimberSubsystem::IsReadySequenceAllowed ( )

Publicly exposes m_allowReady.

Returns
true Traversing through the ready sequence is allowed
false Traversing through the ready sequence is not allowed

◆ ManualControl()

void ClimberSubsystem::ManualControl ( double  hookSpeed,
double  armSpeed 
)

manually moves the hook, and/or arm

Parameters
hookSpeedmoves hook up or down based on the climber a full forward input is 1.0 and a backwards input is -1.0
armSpeedmoves arm up or down based on the climber a full up input is 1.0 and a full down input is -1.0

◆ ManualOverride()

void ClimberSubsystem::ManualOverride ( )

Override automatic control.

◆ MoveArm()

void ClimberSubsystem::MoveArm ( double  armSpeed)

Move arm at specified percent speed.

Parameters
armSpeedmoves arm up or down based on the climber a full up input is 1.0 and a full down input is -1.0

◆ MoveHook()

void ClimberSubsystem::MoveHook ( double  hookSpeed)

Move hook at specified percent speed.

Parameters
hookSpeedmoves hook up or down based on the climber a full forward input is 1.0 and a backwards input is -1.0

◆ NextReadyPoint()

void ClimberSubsystem::NextReadyPoint ( )

Go to the next ClimberPoint in the pre-climb sequence.

◆ Periodic()

void ClimberSubsystem::Periodic ( )
override

Will be called periodically whenever the CommandScheduler runs.

◆ PreviousReadyPoint()

void ClimberSubsystem::PreviousReadyPoint ( )

Go to the previous ClimberPoint in the pre-climb sequence.

◆ SetClimbMotorsPID()

void ClimberSubsystem::SetClimbMotorsPID ( char  slot)

Set Climb Motors PID slot to change power.

Parameters
slotMotor PID slot (see CTRE Falcon 500 docs)

◆ SetClimbReady()

void ClimberSubsystem::SetClimbReady ( )

Readies the climber for climb sequence.

◆ SetHookSoftLimits()

void ClimberSubsystem::SetHookSoftLimits ( )

Enables the hook soft limits.

◆ UpdateArmHome()

void ClimberSubsystem::UpdateArmHome ( )

Update arm home position.

◆ UpdateHookHome()

void ClimberSubsystem::UpdateHookHome ( )

Update hook home position.

Member Data Documentation

◆ m_allowReady

bool ClimberSubsystem::m_allowReady
private

True if the climber can go through ready sequence.

◆ m_armHomed

bool ClimberSubsystem::m_armHomed
private

True if the arms are homed.

◆ m_armPIDTuner

argos_lib::NTMotorPIDTuner ClimberSubsystem::m_armPIDTuner
private

Member for tuning arm PID controls.

◆ m_hookHomed

bool ClimberSubsystem::m_hookHomed
private

True if the hooks are homed.

◆ m_hookPIDTuner

argos_lib::NTMotorPIDTuner ClimberSubsystem::m_hookPIDTuner
private

Member for tuning hook controls.

◆ m_itClimberPoint

std::vector<ClimberPoint>::const_iterator ClimberSubsystem::m_itClimberPoint
private

Random-Access iterator that points to a specific ClimberPoint in the readySequence (used as bi-directional)

◆ m_manualOverride

bool ClimberSubsystem::m_manualOverride
private

True if the operator has manually overriden while closed-loop is running.

◆ m_motorLiftLeft

WPI_TalonFX ClimberSubsystem::m_motorLiftLeft
private

Left ball-screw driver motor for raising arms.

◆ m_motorLiftLeftAddr

const argos_lib::CANAddress ClimberSubsystem::m_motorLiftLeftAddr
private

◆ m_motorLiftRight

WPI_TalonFX ClimberSubsystem::m_motorLiftRight
private

Right ball-screw driver motor for raising arms.

◆ m_motorLiftRightAddr

const argos_lib::CANAddress ClimberSubsystem::m_motorLiftRightAddr
private

◆ m_motorMoveHook

WPI_TalonFX ClimberSubsystem::m_motorMoveHook
private

Hook chain drive motor.

◆ m_motorMoveHookAddr

const argos_lib::CANAddress ClimberSubsystem::m_motorMoveHookAddr
private

◆ m_pPreClimbPoints

const std::vector<ClimberPoint>* ClimberSubsystem::m_pPreClimbPoints
private

std::vector containing ClimberPoints in the ready sequence


The documentation for this class was generated from the following files: