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