PathPlannerLib
Loading...
Searching...
No Matches
PathfindingCommand.h
1#pragma once
2
3#include <frc2/command/Command.h>
4#include <frc2/command/CommandHelper.h>
5#include <frc2/command/Requirements.h>
6#include <memory>
7#include <functional>
8#include <frc/geometry/Pose2d.h>
9#include <frc/kinematics/ChassisSpeeds.h>
10#include <frc/Timer.h>
11#include <units/velocity.h>
12#include <units/length.h>
13#include <units/time.h>
14#include "pathplanner/lib/path/PathPlannerPath.h"
15#include "pathplanner/lib/trajectory/PathPlannerTrajectory.h"
16#include "pathplanner/lib/controllers/PathFollowingController.h"
17#include "pathplanner/lib/config/RobotConfig.h"
18#include "pathplanner/lib/util/PathPlannerLogging.h"
19#include "pathplanner/lib/util/PPLibTelemetry.h"
20#include "pathplanner/lib/util/DriveFeedforwards.h"
21
22namespace pathplanner {
23class PathfindingCommand: public frc2::CommandHelper<frc2::Command,
24 PathfindingCommand> {
25public:
44 PathfindingCommand(std::shared_ptr<PathPlannerPath> targetPath,
45 PathConstraints constraints,
46 std::function<frc::Pose2d()> poseSupplier,
47 std::function<frc::ChassisSpeeds()> speedsSupplier,
48 std::function<
49 void(const frc::ChassisSpeeds&, const DriveFeedforwards&)> output,
50 std::shared_ptr<PathFollowingController> controller,
51 RobotConfig robotConfig, std::function<bool()> shouldFlipPath,
52 frc2::Requirements requirements);
53
72 PathfindingCommand(frc::Pose2d targetPose, PathConstraints constraints,
73 units::meters_per_second_t goalEndVel,
74 std::function<frc::Pose2d()> poseSupplier,
75 std::function<frc::ChassisSpeeds()> speedsSupplier,
76 std::function<
77 void(const frc::ChassisSpeeds&, const DriveFeedforwards&)> output,
78 std::shared_ptr<PathFollowingController> controller,
79 RobotConfig robotConfig, frc2::Requirements requirements);
80
81 void Initialize() override;
82
83 void Execute() override;
84
85 bool IsFinished() override;
86
87 void End(bool interrupted) override;
88
89private:
90 frc::Timer m_timer;
91 std::shared_ptr<PathPlannerPath> m_targetPath;
92 frc::Pose2d m_targetPose;
93 frc::Pose2d m_originalTargetPose;
94 GoalEndState m_goalEndState;
95 PathConstraints m_constraints;
96 std::function<frc::Pose2d()> m_poseSupplier;
97 std::function<frc::ChassisSpeeds()> m_speedsSupplier;
98 std::function<void(const frc::ChassisSpeeds&, const DriveFeedforwards&)> m_output;
99 std::shared_ptr<PathFollowingController> m_controller;
100 RobotConfig m_robotConfig;
101 std::function<bool()> m_shouldFlipPath;
102
103 std::shared_ptr<PathPlannerPath> m_currentPath;
104 PathPlannerTrajectory m_currentTrajectory;
105
106 units::second_t m_timeOffset;
107
108 static int m_instances;
109};
110}
Definition: GoalEndState.h:9
Definition: PathConstraints.h:12
Definition: PathPlannerTrajectory.h:29
Definition: PathfindingCommand.h:24
Definition: RobotConfig.h:17
Definition: DriveFeedforwards.h:12