![]() |
2022-Robot
Robot code for 2022 FRC Season by Argos, FRC team #1756
|
Controls the climber of the robot. More...
#include <climber_subsystem.h>
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... | |
Controls the climber of the robot.
|
explicit |
void ClimberSubsystem::AllowReady | ( | ) |
Allow climber to go through the ready sequence freely. Publicly exposes m_allowReady.
|
private |
Detects if the arms are at a particular target.
target | Target (height in inches) the arms should be at |
void ClimberSubsystem::ArmSetPosition | ( | units::inch_t | extension | ) |
Sets arm linear actuator positions under closed loop control.
extension | Arm position where positive is upward |
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.
extension | Arm position where positive is upward |
cruiseVelocity | Max movement velocity |
acceleration | Max movement acceleration |
bool ClimberSubsystem::ClimberAtPoint | ( | ClimberPoint | target | ) |
Determing if the climber is at a setpoint.
target | Target point |
bool ClimberSubsystem::ClimberReadyToClimb | ( | ) |
Determines if climber is able to climb current position.
void ClimberSubsystem::ClimberToSetpoint | ( | ClimberPoint | setPoint | ) |
Closed-loop climber to set-point.
setPoint | Point to send the climber to |
void ClimberSubsystem::Disable | ( | ) |
Runs on robot disable to reset manual control.
void ClimberSubsystem::DisableHookSoftLimits | ( | ) |
Disables hook soft limit.
void ClimberSubsystem::DisallowReady | ( | ) |
Disable ability to go through ready sequence. Publicly exposes m_allowReady.
|
private |
Detects if the hooks are at a particular target.
target | Target (in inches) the hooks should be at along their rails |
void ClimberSubsystem::HooksSetPosition | ( | units::inch_t | extension | ) |
Set hooks to a given position under closed-loop control.
extension | Hook position where 0 is at the shoulder and positive is outward |
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.
extension | Hook position where 0 is at the shoulder and positive is outward |
cruiseVelocity | Max movement velocity |
acceleration | Max movement acceleration |
|
inlinestaticconstexpr |
Detect if a value is within a threshold of a target value.
T | Type that implements operator+(), operator-(), operator<=() and operator>=() |
value | Value to check |
target | Center of range |
threshold | Allowable error from target |
bool ClimberSubsystem::IsArmHomed | ( | ) |
Detect if arm homing is complete.
bool ClimberSubsystem::IsArmMoving | ( | ) |
Detect if arm is in motion.
bool ClimberSubsystem::IsHookHomed | ( | ) |
Detect if hook homing is complete.
bool ClimberSubsystem::IsHookMoving | ( | ) |
Detect if hook is in motion.
bool ClimberSubsystem::IsManualOverride | ( | ) |
Detect if manual control has been enabled.
bool ClimberSubsystem::IsReadySequenceAllowed | ( | ) |
Publicly exposes m_allowReady.
void ClimberSubsystem::ManualControl | ( | double | hookSpeed, |
double | armSpeed | ||
) |
manually moves the hook, and/or arm
hookSpeed | moves hook up or down based on the climber a full forward input is 1.0 and a backwards input is -1.0 |
armSpeed | moves arm up or down based on the climber a full up input is 1.0 and a full down input is -1.0 |
void ClimberSubsystem::ManualOverride | ( | ) |
Override automatic control.
void ClimberSubsystem::MoveArm | ( | double | armSpeed | ) |
Move arm at specified percent speed.
armSpeed | moves arm up or down based on the climber a full up input is 1.0 and a full down input is -1.0 |
void ClimberSubsystem::MoveHook | ( | double | hookSpeed | ) |
Move hook at specified percent speed.
hookSpeed | moves hook up or down based on the climber a full forward input is 1.0 and a backwards input is -1.0 |
void ClimberSubsystem::NextReadyPoint | ( | ) |
Go to the next ClimberPoint in the pre-climb sequence.
|
override |
Will be called periodically whenever the CommandScheduler runs.
void ClimberSubsystem::PreviousReadyPoint | ( | ) |
Go to the previous ClimberPoint in the pre-climb sequence.
void ClimberSubsystem::SetClimbMotorsPID | ( | char | slot | ) |
Set Climb Motors PID slot to change power.
slot | Motor PID slot (see CTRE Falcon 500 docs) |
void ClimberSubsystem::SetClimbReady | ( | ) |
Readies the climber for climb sequence.
void ClimberSubsystem::SetHookSoftLimits | ( | ) |
Enables the hook soft limits.
void ClimberSubsystem::UpdateArmHome | ( | ) |
Update arm home position.
void ClimberSubsystem::UpdateHookHome | ( | ) |
Update hook home position.
|
private |
True if the climber can go through ready sequence.
|
private |
True if the arms are homed.
|
private |
Member for tuning arm PID controls.
|
private |
True if the hooks are homed.
|
private |
Member for tuning hook controls.
|
private |
Random-Access iterator that points to a specific ClimberPoint in the readySequence (used as bi-directional)
|
private |
True if the operator has manually overriden while closed-loop is running.
|
private |
Left ball-screw driver motor for raising arms.
|
private |
|
private |
Right ball-screw driver motor for raising arms.
|
private |
|
private |
Hook chain drive motor.
|
private |
|
private |
std::vector containing ClimberPoints in the ready sequence