2022-Robot
Robot code for 2022 FRC Season by Argos, FRC team #1756
Loading...
Searching...
No Matches
climber_subsystem.h
Go to the documentation of this file.
1
4
5#pragma once
6
7#include <frc2/command/SubsystemBase.h>
8
9#include <vector>
10
11#include "Constants.h"
14#include "ctre/Phoenix.h"
15#include "units/length.h"
17
22class ClimberSubsystem : public frc2::SubsystemBase {
23 public:
24 explicit ClimberSubsystem(const argos_lib::RobotInstance instance, const std::vector<ClimberPoint>* preClimbPoints);
25
29 void Periodic() override;
30
38 void ManualControl(double hookSpeed, double armSpeed);
39
46 void MoveHook(double hookSpeed);
47
53 void MoveArm(double armSpeed);
54
59 void UpdateHookHome();
60
65 void UpdateArmHome();
66
72 void ArmSetPosition(units::inch_t extension);
73
81 void ArmSetPosition(units::inch_t extension,
82 units::inches_per_second_t cruiseVelocity,
83 units::inches_per_second_squared_t acceleration);
84
90 void HooksSetPosition(units::inch_t extension);
91
99 void HooksSetPosition(units::inch_t extension,
100 units::inches_per_second_t cruiseVelocity,
101 units::inches_per_second_squared_t acceleration);
102
108 bool IsHookHomed();
109
115 bool IsArmHomed();
116
122 bool IsHookMoving();
123
129 bool IsArmMoving();
130
136 bool IsManualOverride();
137
141 void Disable();
142
146 void ManualOverride();
147
152 void SetHookSoftLimits();
153
159
165
175 template <typename T>
176 constexpr static bool InThreshold(const T value, const T target, const T threshold) {
177 return value >= target - threshold && value <= target + threshold;
178 }
179
185 void ClimberToSetpoint(ClimberPoint setPoint);
186
192 void SetClimbMotorsPID(char slot);
193
201 bool ClimberAtPoint(ClimberPoint target);
202
203 // NEW STUFF EVALUATE WHAT NEEDS TO BE REMOVED
204
209 void NextReadyPoint();
210
215 void PreviousReadyPoint();
216
221 void AllowReady();
222
227 void DisallowReady();
228
236
243 bool ClimberReadyToClimb();
244
245 private:
249 // Components (e.g. motor controllers and sensors) should generally be
250 // declared private and exposed only through public methods.
251 WPI_TalonFX m_motorLiftRight;
252 WPI_TalonFX m_motorLiftLeft;
253 WPI_TalonFX m_motorMoveHook;
254
257
259
261 const std::vector<ClimberPoint>* m_pPreClimbPoints;
262 std::vector<ClimberPoint>::const_iterator
264
267
275 bool HooksAtPosition(units::inch_t target);
276
284 bool ArmsAtPosition(units::inch_t target);
285};
Controls the climber of the robot.
Definition: climber_subsystem.h:22
void DisallowReady()
Disable ability to go through ready sequence. Publicly exposes m_allowReady.
Definition: climber_subsystem.cpp:264
WPI_TalonFX m_motorLiftLeft
Left ball-screw driver motor for raising arms.
Definition: climber_subsystem.h:252
void MoveArm(double armSpeed)
Move arm at specified percent speed.
Definition: climber_subsystem.cpp:72
bool m_allowReady
True if the climber can go through ready sequence.
Definition: climber_subsystem.h:258
std::vector< ClimberPoint >::const_iterator m_itClimberPoint
Random-Access iterator that points to a specific ClimberPoint in the readySequence (used as bi-direct...
Definition: climber_subsystem.h:263
bool m_manualOverride
True if the operator has manually overriden while closed-loop is running.
Definition: climber_subsystem.h:260
const std::vector< ClimberPoint > * m_pPreClimbPoints
std::vector containing ClimberPoints in the ready sequence
Definition: climber_subsystem.h:261
void SetHookSoftLimits()
Enables the hook soft limits.
Definition: climber_subsystem.cpp:178
void ArmSetPosition(units::inch_t extension)
Sets arm linear actuator positions under closed loop control.
Definition: climber_subsystem.cpp:94
bool IsArmHomed()
Detect if arm homing is complete.
Definition: climber_subsystem.cpp:149
bool m_armHomed
True if the arms are homed.
Definition: climber_subsystem.h:256
argos_lib::NTMotorPIDTuner m_armPIDTuner
Member for tuning arm PID controls.
Definition: climber_subsystem.h:265
void NextReadyPoint()
Go to the next ClimberPoint in the pre-climb sequence.
Definition: climber_subsystem.cpp:233
void ManualOverride()
Override automatic control.
Definition: climber_subsystem.cpp:174
bool IsReadySequenceAllowed()
Publicly exposes m_allowReady.
Definition: climber_subsystem.cpp:268
bool IsManualOverride()
Detect if manual control has been enabled.
Definition: climber_subsystem.cpp:162
WPI_TalonFX m_motorLiftRight
Right ball-screw driver motor for raising arms.
Definition: climber_subsystem.h:251
bool IsArmMoving()
Detect if arm is in motion.
Definition: climber_subsystem.cpp:157
const argos_lib::CANAddress m_motorLiftLeftAddr
Definition: climber_subsystem.h:247
void ClimberToSetpoint(ClimberPoint setPoint)
Closed-loop climber to set-point.
Definition: climber_subsystem.cpp:196
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.
Definition: climber_subsystem.h:176
WPI_TalonFX m_motorMoveHook
Hook chain drive motor.
Definition: climber_subsystem.h:253
const argos_lib::CANAddress m_motorLiftRightAddr
Definition: climber_subsystem.h:246
const argos_lib::CANAddress m_motorMoveHookAddr
Definition: climber_subsystem.h:248
bool ClimberAtPoint(ClimberPoint target)
Determing if the climber is at a setpoint.
Definition: climber_subsystem.cpp:227
void HooksSetPosition(units::inch_t extension)
Set hooks to a given position under closed-loop control.
Definition: climber_subsystem.cpp:122
bool HooksAtPosition(units::inch_t target)
Detects if the hooks are at a particular target.
Definition: climber_subsystem.cpp:209
void MoveHook(double hookSpeed)
Move hook at specified percent speed.
Definition: climber_subsystem.cpp:68
void UpdateArmHome()
Update arm home position.
Definition: climber_subsystem.cpp:85
void Periodic() override
Definition: climber_subsystem.cpp:55
bool IsHookMoving()
Detect if hook is in motion.
Definition: climber_subsystem.cpp:153
void UpdateHookHome()
Update hook home position.
Definition: climber_subsystem.cpp:77
void DisableHookSoftLimits()
Disables hook soft limit.
Definition: climber_subsystem.cpp:190
void PreviousReadyPoint()
Go to the previous ClimberPoint in the pre-climb sequence.
Definition: climber_subsystem.cpp:244
void ManualControl(double hookSpeed, double armSpeed)
manually moves the hook, and/or arm
Definition: climber_subsystem.cpp:57
void AllowReady()
Allow climber to go through the ready sequence freely. Publicly exposes m_allowReady.
Definition: climber_subsystem.cpp:260
void Disable()
Runs on robot disable to reset manual control.
Definition: climber_subsystem.cpp:166
bool m_hookHomed
True if the hooks are homed.
Definition: climber_subsystem.h:255
argos_lib::NTMotorPIDTuner m_hookPIDTuner
Member for tuning hook controls.
Definition: climber_subsystem.h:266
bool ArmsAtPosition(units::inch_t target)
Detects if the arms are at a particular target.
Definition: climber_subsystem.cpp:221
bool ClimberReadyToClimb()
Determines if climber is able to climb current position.
Definition: climber_subsystem.cpp:255
void SetClimbReady()
Readies the climber for climb sequence.
void SetClimbMotorsPID(char slot)
Set Climb Motors PID slot to change power.
Definition: climber_subsystem.cpp:202
bool IsHookHomed()
Detect if hook homing is complete.
Definition: climber_subsystem.cpp:145
Allows user to set PID parameters from network tables and update the motor configurations on updates....
Definition: nt_motor_pid_tuner.h:48
RobotInstance
Differentiates between practice robot and competition robot.
Definition: config_types.h:13
Definition: climber_setpoints.h:15
Definition: config_types.h:25