2025-Robot
Robot code for 2025 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/trajectory/Trajectory.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 <optional>
17#include <string>
18
19#include "constants/position.h"
21
22class DriveChoreo : public frc2::CommandHelper<frc2::Command, DriveChoreo> {
23 public:
25 const std::string& trajectoryName,
26 const bool initializeOdometry = false,
27 std::optional<std::function<void(ArmPosition)>> armPositionCallback = std::nullopt,
28 const int split = -1);
29
30 void Initialize() override;
31
32 void Execute() override;
33
34 void End(bool interrupted) override;
35
36 bool IsFinished() override;
37
38 [[nodiscard]] static bool IsAtEndPoint(SwerveDriveSubsystem& drive,
39 const std::string& trajectoryName,
40 const units::inch_t translationalTolerance = 6_in,
41 const units::degree_t rotationalTolerance = 1.0_deg);
42
43 private:
45 std::optional<choreo::Trajectory<choreo::SwerveSample>> m_trajectory;
47 std::chrono::time_point<std::chrono::steady_clock> m_startTime;
48 wpi::log::StructLogEntry<frc::Pose2d> m_desiredAutoPositionLogger;
49 wpi::log::StructArrayLogEntry<frc::Pose2d> m_autoTrajectoryLogger;
51 std::optional<std::function<void(ArmPosition)>> m_armPositionCallback;
52 std::vector<choreo::EventMarker> m_events;
54};
Definition drive_choreo.h:22
wpi::log::StructLogEntry< frc::Pose2d > m_desiredAutoPositionLogger
Definition drive_choreo.h:48
DriveChoreo(SwerveDriveSubsystem &drive, const std::string &trajectoryName, const bool initializeOdometry=false, std::optional< std::function< void(ArmPosition)> > armPositionCallback=std::nullopt, const int split=-1)
Definition drive_choreo.cpp:16
bool IsFinished() override
Definition drive_choreo.cpp:109
bool m_isRedAlliance
Definition drive_choreo.h:50
void End(bool interrupted) override
Definition drive_choreo.cpp:100
std::optional< choreo::Trajectory< choreo::SwerveSample > > m_trajectory
Definition drive_choreo.h:45
std::chrono::time_point< std::chrono::steady_clock > m_startTime
Definition drive_choreo.h:47
size_t m_nextEventIndex
Definition drive_choreo.h:53
std::vector< choreo::EventMarker > m_events
Definition drive_choreo.h:52
void Execute() override
Definition drive_choreo.cpp:83
SwerveDriveSubsystem & m_Drive
Definition drive_choreo.h:44
const bool m_initializeOdometry
Definition drive_choreo.h:46
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:113
wpi::log::StructArrayLogEntry< frc::Pose2d > m_autoTrajectoryLogger
Definition drive_choreo.h:49
void Initialize() override
Definition drive_choreo.cpp:46
std::optional< std::function< void(ArmPosition)> > m_armPositionCallback
Definition drive_choreo.h:51
Subsystem for controlling the swerve drivetrain of the robot.
Definition swerve_drive_subsystem.h:75
ArmPosition
Definition position.h:72