2024-Robot
Robot code for 2024 FRC season by Argos, FRC team #1756
Loading...
Searching...
No Matches
drive_choreo.h
Go to the documentation of this file.
1
4
5#pragma once
6
7#include <choreo/lib/ChoreoSwerveCommand.h>
8#include <frc/geometry/Pose2d.h>
9#include <frc2/command/Command.h>
10#include <frc2/command/CommandHelper.h>
11#include <units/angle.h>
12#include <units/length.h>
13#include <wpi/DataLog.h>
14
15#include <chrono>
16#include <string>
17
19
20class DriveChoreo : public frc2::CommandHelper<frc2::Command, DriveChoreo> {
21 public:
22 DriveChoreo(SwerveDriveSubsystem& drive, const std::string& trajectoryName, const bool initializeOdometry = false);
23
24 void Initialize() override;
25
26 void Execute() override;
27
28 void End(bool interrupted) override;
29
30 bool IsFinished() override;
31
32 [[nodiscard]] static bool IsAtEndPoint(SwerveDriveSubsystem& drive,
33 const std::string& trajectoryName,
34 const units::inch_t translationalTolerance = 6_in,
35 const units::degree_t rotationalTolerance = 1.0_deg);
36
37 [[nodiscard]] static units::inch_t EndpointShotDistance(const std::string& trajectoryName);
38
39 private:
41 const choreolib::ChoreoTrajectory m_trajectory;
42 choreolib::ChoreoTrajectory m_orientedTrajectory;
43 choreolib::ChoreoSwerveCommand m_ChoreoCommand;
45 std::chrono::time_point<std::chrono::steady_clock> m_startTime;
46 wpi::log::StructLogEntry<frc::Pose2d> m_desiredAutoPositionLogger;
47 wpi::log::StructArrayLogEntry<frc::Pose2d> m_autoTrajectoryLogger;
48};
Definition drive_choreo.h:20
wpi::log::StructLogEntry< frc::Pose2d > m_desiredAutoPositionLogger
Definition drive_choreo.h:46
bool IsFinished() override
Definition drive_choreo.cpp:89
const choreolib::ChoreoTrajectory m_trajectory
Definition drive_choreo.h:41
choreolib::ChoreoSwerveCommand m_ChoreoCommand
Definition drive_choreo.h:43
void End(bool interrupted) override
Definition drive_choreo.cpp:83
static units::inch_t EndpointShotDistance(const std::string &trajectoryName)
Definition drive_choreo.cpp:106
std::chrono::time_point< std::chrono::steady_clock > m_startTime
Definition drive_choreo.h:45
void Execute() override
Definition drive_choreo.cpp:74
SwerveDriveSubsystem & m_Drive
Definition drive_choreo.h:40
const bool m_initializeOdometry
Definition drive_choreo.h:44
static bool IsAtEndPoint(SwerveDriveSubsystem &drive, const std::string &trajectoryName, const units::inch_t translationalTolerance=6_in, const units::degree_t rotationalTolerance=1.0_deg)
Definition drive_choreo.cpp:93
choreolib::ChoreoTrajectory m_orientedTrajectory
Definition drive_choreo.h:42
wpi::log::StructArrayLogEntry< frc::Pose2d > m_autoTrajectoryLogger
Definition drive_choreo.h:47
void Initialize() override
Definition drive_choreo.cpp:34
Subsystem for controlling the swerve drivetrain of the robot.
Definition swerve_drive_subsystem.h:67