4#include <units/length.h>
5#include <units/velocity.h>
6#include <units/acceleration.h>
7#include <units/angular_velocity.h>
8#include <units/curvature.h>
9#include <frc/geometry/Translation2d.h>
10#include <frc/geometry/Rotation2d.h>
11#include <frc/geometry/Pose2d.h>
12#include <frc/kinematics/ChassisSpeeds.h>
13#include <frc/kinematics/SwerveModuleState.h>
14#include <frc/MathUtil.h>
15#include <frc2/command/Command.h>
19#include "pathplanner/lib/trajectory/PathPlannerTrajectoryState.h"
20#include "pathplanner/lib/path/PathConstraints.h"
21#include "pathplanner/lib/util/GeometryUtil.h"
22#include "pathplanner/lib/config/RobotConfig.h"
23#include "pathplanner/lib/events/Event.h"
25namespace pathplanner {
41 std::vector<std::shared_ptr<Event>> events) : m_states(states), m_events(
63 const frc::ChassisSpeeds &startingSpeeds,
64 const frc::Rotation2d &startingRotation,
const RobotConfig &config);
71 inline std::vector<std::shared_ptr<Event>>
getEvents() {
80 constexpr std::vector<PathPlannerTrajectoryState>&
getStates() {
91 return m_states[index];
109 return m_states[m_states.size() - 1];
144 std::vector < PathPlannerTrajectoryState > mirroredStates;
145 for (
auto state : m_states) {
146 mirroredStates.emplace_back(state.flip());
151 std::vector<PathPlannerTrajectoryState> m_states;
152 std::vector<std::shared_ptr<Event>> m_events;
154 static void generateStates(std::vector<PathPlannerTrajectoryState> &states,
155 std::shared_ptr<PathPlannerPath> path,
156 const frc::Rotation2d &startingRotation,
const RobotConfig &config);
158 static void forwardAccelPass(
159 std::vector<PathPlannerTrajectoryState> &states,
162 static void reverseAccelPass(
163 std::vector<PathPlannerTrajectoryState> &states,
166 static void desaturateWheelSpeeds(
167 std::vector<SwerveModuleTrajectoryState> &moduleStates,
168 const frc::ChassisSpeeds &desiredSpeeds,
169 units::meters_per_second_t maxModuleSpeed,
170 units::meters_per_second_t maxTranslationSpeed,
171 units::radians_per_second_t maxRotationSpeed);
173 static size_t getNextRotationTargetIdx(
174 std::shared_ptr<PathPlannerPath> path,
const size_t startingIndex);
176 static inline frc::Rotation2d cosineInterpolate(
const frc::Rotation2d start,
177 const frc::Rotation2d end,
const double t) {
178 double t2 = (1.0 - std::cos(t * M_PI)) / 2.0;
179 return GeometryUtil::rotationLerp(start, end, t2);
Definition: PathPlannerTrajectoryState.h:17
Definition: PathPlannerTrajectory.h:29
frc::Pose2d getInitialPose()
Definition: PathPlannerTrajectory.h:126
units::second_t getTotalTime()
Definition: PathPlannerTrajectory.h:117
PathPlannerTrajectory flip()
Definition: PathPlannerTrajectory.h:143
PathPlannerTrajectoryState sample(const units::second_t time)
Definition: PathPlannerTrajectory.cpp:210
PathPlannerTrajectory(std::vector< PathPlannerTrajectoryState > states)
Definition: PathPlannerTrajectory.h:50
constexpr std::vector< PathPlannerTrajectoryState > & getStates()
Definition: PathPlannerTrajectory.h:80
std::vector< std::shared_ptr< Event > > getEvents()
Definition: PathPlannerTrajectory.h:71
PathPlannerTrajectoryState getState(size_t index)
Definition: PathPlannerTrajectory.h:90
PathPlannerTrajectoryState getInitialState()
Definition: PathPlannerTrajectory.h:99
PathPlannerTrajectoryState getEndState()
Definition: PathPlannerTrajectory.h:108
PathPlannerTrajectory(std::vector< PathPlannerTrajectoryState > states, std::vector< std::shared_ptr< Event > > events)
Definition: PathPlannerTrajectory.h:40
Definition: RobotConfig.h:17