PathPlannerLib
Loading...
Searching...
No Matches
PathPoint.h
1#pragma once
2
3#include <frc/geometry/Translation2d.h>
4#include <limits>
5#include <optional>
6#include <units/length.h>
7#include <units/velocity.h>
8#include "pathplanner/lib/path/PathConstraints.h"
9#include "pathplanner/lib/path/RotationTarget.h"
10#include "pathplanner/lib/util/FlippingUtil.h"
11
12namespace pathplanner {
13class PathPoint {
14public:
15 frc::Translation2d position;
16 units::meter_t distanceAlongPath = 0_m;
17 units::meters_per_second_t maxV = units::meters_per_second_t {
18 std::numeric_limits<double>::infinity() };
19 std::optional<RotationTarget> rotationTarget = std::nullopt;
20 std::optional<PathConstraints> constraints = std::nullopt;
21 double waypointRelativePos = 0.0;
22
23 constexpr PathPoint(frc::Translation2d pos,
24 std::optional<RotationTarget> rot,
25 std::optional<PathConstraints> pathCostriaints) : position(pos), rotationTarget(
26 rot), constraints(pathCostriaints) {
27 }
28
29 constexpr PathPoint(frc::Translation2d pos) : position(pos) {
30 }
31
32 inline PathPoint flip() const {
34 flipped.distanceAlongPath = distanceAlongPath;
35 flipped.maxV = maxV;
36 if (rotationTarget.has_value()) {
37 flipped.rotationTarget = RotationTarget(
38 rotationTarget.value().getPosition(),
40 rotationTarget.value().getTarget()));
41 }
42 flipped.constraints = constraints;
43 flipped.waypointRelativePos = waypointRelativePos;
44 return flipped;
45 }
46};
47}
static frc::Rotation2d flipFieldRotation(const frc::Rotation2d &rotation)
Definition: FlippingUtil.h:44
static frc::Translation2d flipFieldPosition(const frc::Translation2d &pos)
Definition: FlippingUtil.h:26
Definition: PathPoint.h:13
Definition: RotationTarget.h:7