2023-Robot
Robot code for 2023 FRC season by Argos, FRC team #1756
Loading...
Searching...
No Matches
drive_until_pitch_rate.h
Go to the documentation of this file.
1
4
5#pragma once
6
7#include <frc/filter/SlewRateLimiter.h>
8#include <frc2/command/CommandBase.h>
9#include <frc2/command/CommandHelper.h>
10#include <units/angle.h>
11#include <units/angular_velocity.h>
12#include <units/time.h>
13
14#include <chrono>
15
16#include "Constants.h"
18
19class DriveUntilPitchRate : public frc2::CommandHelper<frc2::CommandBase, DriveUntilPitchRate> {
20 public:
22 units::degree_t velAngle,
23 double power,
24 double initialPower,
25 units::degrees_per_second_t pitchRateGoal,
26 ApproachDirection approachDirection,
27 units::time::second_t timeout);
28
29 void Initialize() override;
30
31 void Execute() override;
32
33 void End(bool interrupted) override;
34
35 bool IsFinished() override;
36
37 private:
39 const units::degree_t m_velAngle;
40 const double m_power;
41 const double m_initialPower;
42 std::chrono::time_point<std::chrono::high_resolution_clock> m_startTime;
43 const units::degrees_per_second_t m_pitchRateGoal;
45 const units::time::second_t m_timeout;
46 frc::SlewRateLimiter<units::scalar> m_velocityRamper;
47};
ApproachDirection
Designate the threshold approach direction.
Definition Constants.h:84
Definition drive_until_pitch_rate.h:19
void Execute() override
Definition drive_until_pitch_rate.cpp:35
frc::SlewRateLimiter< units::scalar > m_velocityRamper
Limit acceleration.
Definition drive_until_pitch_rate.h:46
SwerveDriveSubsystem * m_pDrive
Raw pointer to swerve drive subsystem object.
Definition drive_until_pitch_rate.h:38
const double m_initialPower
Power prior to command start [-1,1].
Definition drive_until_pitch_rate.h:41
const units::time::second_t m_timeout
The amount of time allowed to pass before the command times out.
Definition drive_until_pitch_rate.h:45
const units::degrees_per_second_t m_pitchRateGoal
The pitch rate the robot has to be at to complete the command.
Definition drive_until_pitch_rate.h:43
const double m_power
Power to apply in m_velAngle direction as percent output ([0, 1])
Definition drive_until_pitch_rate.h:40
void Initialize() override
Definition drive_until_pitch_rate.cpp:28
std::chrono::time_point< std::chrono::high_resolution_clock > m_startTime
Start time as a time point.
Definition drive_until_pitch_rate.h:42
const units::degree_t m_velAngle
Angle of drive direction relative to field-centric.
Definition drive_until_pitch_rate.h:39
bool IsFinished() override
Definition drive_until_pitch_rate.cpp:60
const ApproachDirection m_approachDirection
Threshold approach direction for pitch goal.
Definition drive_until_pitch_rate.h:44
void End(bool interrupted) override
Definition drive_until_pitch_rate.cpp:53
Subsystem for controlling the swerve drivetrain of the robot.
Definition swerve_drive_subsystem.h:56