ChoreoLib
Loading...
Searching...
No Matches
ChoreoSwerveCommand.h
1// Copyright (c) Choreo contributors
2
3#pragma once
4
5#include <frc/Timer.h>
6#include <frc2/command/Command.h>
7#include <frc2/command/CommandHelper.h>
8
9#include <functional>
10
11#include "choreo/lib/ChoreoTrajectory.h"
12
13namespace choreolib {
14
16using ChoreoControllerFunction =
17 std::function<frc::ChassisSpeeds(frc::Pose2d, ChoreoTrajectoryState)>;
18
23 : public frc2::CommandHelper<frc2::Command, ChoreoSwerveCommand> {
24 public:
40 ChoreoTrajectory trajectory, std::function<frc::Pose2d()> poseSupplier,
41 ChoreoControllerFunction controller,
42 std::function<void(frc::ChassisSpeeds)> outputChassisSpeeds,
43 std::function<bool(void)> mirrorTrajectory,
44 frc2::Requirements requirements = {});
45
47 void Initialize() override;
48
50 void Execute() override;
51
53 void End(bool interrupted) override;
54
56 bool IsFinished() override;
57
58 private:
59 frc::Timer m_timer;
60 ChoreoTrajectory m_traj;
61 std::function<frc::Pose2d()> m_pose;
62 ChoreoControllerFunction m_controller;
63 std::function<void(frc::ChassisSpeeds)> m_outputChassisSpeeds;
64 std::function<bool(void)> m_mirrorTrajectory;
65};
66} // namespace choreolib
Definition ChoreoSwerveCommand.h:23
void Execute() override
Runs every robot periodic loop while the command is running.
Definition ChoreoSwerveCommand.cpp:28
void End(bool interrupted) override
Runs once after IsFinished() returns true.
Definition ChoreoSwerveCommand.cpp:36
bool IsFinished() override
Command will end once this returns true.
Definition ChoreoSwerveCommand.cpp:41
ChoreoSwerveCommand(ChoreoTrajectory trajectory, std::function< frc::Pose2d()> poseSupplier, ChoreoControllerFunction controller, std::function< void(frc::ChassisSpeeds)> outputChassisSpeeds, std::function< bool(void)> mirrorTrajectory, frc2::Requirements requirements={})
Definition ChoreoSwerveCommand.cpp:9
void Initialize() override
Runs once before the first call to Execute()
Definition ChoreoSwerveCommand.cpp:23
Definition ChoreoTrajectory.h:13