WPILibC++ 2027.0.0-alpha-4
Loading...
Searching...
No Matches
TrajectoryConstraint.hpp
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
10#include "wpi/units/acceleration.hpp"
11#include "wpi/units/curvature.hpp"
12#include "wpi/units/velocity.hpp"
14
15namespace wpi::math {
16/**
17 * An interface for defining user-defined velocity and acceleration constraints
18 * while generating trajectories.
19 */
21 public:
22 constexpr TrajectoryConstraint() = default;
23
24 constexpr TrajectoryConstraint(const TrajectoryConstraint&) = default;
26 default;
27
30
31 constexpr virtual ~TrajectoryConstraint() = default;
32
33 /**
34 * Represents a minimum and maximum acceleration.
35 */
36 struct MinMax {
37 /**
38 * The minimum acceleration.
39 */
40 wpi::units::meters_per_second_squared_t minAcceleration{
41 -std::numeric_limits<double>::max()};
42
43 /**
44 * The maximum acceleration.
45 */
46 wpi::units::meters_per_second_squared_t maxAcceleration{
47 std::numeric_limits<double>::max()};
48 };
49
50 /**
51 * Returns the max velocity given the current pose and curvature.
52 *
53 * @param pose The pose at the current point in the trajectory.
54 * @param curvature The curvature at the current point in the trajectory.
55 * @param velocity The velocity at the current point in the trajectory before
56 * constraints are applied.
57 *
58 * @return The absolute maximum velocity.
59 */
60 constexpr virtual wpi::units::meters_per_second_t MaxVelocity(
61 const Pose2d& pose, wpi::units::curvature_t curvature,
62 wpi::units::meters_per_second_t velocity) const = 0;
63
64 /**
65 * Returns the minimum and maximum allowable acceleration for the trajectory
66 * given pose, curvature, and velocity.
67 *
68 * @param pose The pose at the current point in the trajectory.
69 * @param curvature The curvature at the current point in the trajectory.
70 * @param velocity The velocity at the current point in the trajectory.
71 *
72 * @return The min and max acceleration bounds.
73 */
74 constexpr virtual MinMax MinMaxAcceleration(
75 const Pose2d& pose, wpi::units::curvature_t curvature,
76 wpi::units::meters_per_second_t velocity) const = 0;
77};
78} // namespace wpi::math
#define WPILIB_DLLEXPORT
Definition SymbolExports.hpp:36
Represents a 2D pose containing translational and rotational elements.
Definition Pose2d.hpp:27
constexpr TrajectoryConstraint()=default
virtual constexpr MinMax MinMaxAcceleration(const Pose2d &pose, wpi::units::curvature_t curvature, wpi::units::meters_per_second_t velocity) const =0
Returns the minimum and maximum allowable acceleration for the trajectory given pose,...
constexpr TrajectoryConstraint(TrajectoryConstraint &&)=default
virtual constexpr ~TrajectoryConstraint()=default
constexpr TrajectoryConstraint(const TrajectoryConstraint &)=default
constexpr TrajectoryConstraint & operator=(TrajectoryConstraint &&)=default
virtual constexpr wpi::units::meters_per_second_t MaxVelocity(const Pose2d &pose, wpi::units::curvature_t curvature, wpi::units::meters_per_second_t velocity) const =0
Returns the max velocity given the current pose and curvature.
constexpr TrajectoryConstraint & operator=(const TrajectoryConstraint &)=default
Definition LinearSystem.hpp:20
Represents a minimum and maximum acceleration.
Definition TrajectoryConstraint.hpp:36
wpi::units::meters_per_second_squared_t maxAcceleration
The maximum acceleration.
Definition TrajectoryConstraint.hpp:46
wpi::units::meters_per_second_squared_t minAcceleration
The minimum acceleration.
Definition TrajectoryConstraint.hpp:40