WPILibC++ 2025.2.1
Loading...
Searching...
No Matches
TrajectoryConstraint.h
Go to the documentation of this file.
1// Copyright (c) FIRST and other WPILib contributors.
2// Open Source Software; you can modify and/or share it under the terms of
3// the WPILib BSD license file in the root directory of this project.
4
5#pragma once
6
7#include <limits>
8
9#include <wpi/SymbolExports.h>
10
11#include "frc/geometry/Pose2d.h"
12#include "units/acceleration.h"
13#include "units/curvature.h"
14#include "units/velocity.h"
15
16namespace frc {
17/**
18 * An interface for defining user-defined velocity and acceleration constraints
19 * while generating trajectories.
20 */
22 public:
23 constexpr TrajectoryConstraint() = default;
24
25 constexpr TrajectoryConstraint(const TrajectoryConstraint&) = default;
27 default;
28
31
32 constexpr virtual ~TrajectoryConstraint() = default;
33
34 /**
35 * Represents a minimum and maximum acceleration.
36 */
37 struct MinMax {
38 /**
39 * The minimum acceleration.
40 */
41 units::meters_per_second_squared_t minAcceleration{
42 -std::numeric_limits<double>::max()};
43
44 /**
45 * The maximum acceleration.
46 */
47 units::meters_per_second_squared_t maxAcceleration{
48 std::numeric_limits<double>::max()};
49 };
50
51 /**
52 * Returns the max velocity given the current pose and curvature.
53 *
54 * @param pose The pose at the current point in the trajectory.
55 * @param curvature The curvature at the current point in the trajectory.
56 * @param velocity The velocity at the current point in the trajectory before
57 * constraints are applied.
58 *
59 * @return The absolute maximum velocity.
60 */
61 constexpr virtual units::meters_per_second_t MaxVelocity(
62 const Pose2d& pose, units::curvature_t curvature,
63 units::meters_per_second_t velocity) const = 0;
64
65 /**
66 * Returns the minimum and maximum allowable acceleration for the trajectory
67 * given pose, curvature, and speed.
68 *
69 * @param pose The pose at the current point in the trajectory.
70 * @param curvature The curvature at the current point in the trajectory.
71 * @param speed The speed at the current point in the trajectory.
72 *
73 * @return The min and max acceleration bounds.
74 */
75 constexpr virtual MinMax MinMaxAcceleration(
76 const Pose2d& pose, units::curvature_t curvature,
77 units::meters_per_second_t speed) const = 0;
78};
79} // namespace frc
#define WPILIB_DLLEXPORT
Definition SymbolExports.h:36
Represents a 2D pose containing translational and rotational elements.
Definition Pose2d.h:28
An interface for defining user-defined velocity and acceleration constraints while generating traject...
Definition TrajectoryConstraint.h:21
constexpr TrajectoryConstraint & operator=(TrajectoryConstraint &&)=default
constexpr TrajectoryConstraint(const TrajectoryConstraint &)=default
virtual constexpr units::meters_per_second_t MaxVelocity(const Pose2d &pose, units::curvature_t curvature, units::meters_per_second_t velocity) const =0
Returns the max velocity given the current pose and curvature.
virtual constexpr MinMax MinMaxAcceleration(const Pose2d &pose, units::curvature_t curvature, units::meters_per_second_t speed) const =0
Returns the minimum and maximum allowable acceleration for the trajectory given pose,...
virtual constexpr ~TrajectoryConstraint()=default
constexpr TrajectoryConstraint()=default
constexpr TrajectoryConstraint(TrajectoryConstraint &&)=default
constexpr TrajectoryConstraint & operator=(const TrajectoryConstraint &)=default
Definition CAN.h:11
Represents a minimum and maximum acceleration.
Definition TrajectoryConstraint.h:37