WPILibC++ 2024.3.2
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 "frc/spline/Spline.h"
13#include "units/acceleration.h"
14#include "units/curvature.h"
15#include "units/velocity.h"
16
17namespace frc {
18/**
19 * An interface for defining user-defined velocity and acceleration constraints
20 * while generating trajectories.
21 */
23 public:
25
28
31
32 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{
43
44 /**
45 * The maximum acceleration.
46 */
47 units::meters_per_second_squared_t maxAcceleration{
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 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 virtual MinMax MinMaxAcceleration(const Pose2d& pose,
76 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:23
An interface for defining user-defined velocity and acceleration constraints while generating traject...
Definition: TrajectoryConstraint.h:22
TrajectoryConstraint & operator=(TrajectoryConstraint &&)=default
virtual 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.
TrajectoryConstraint(TrajectoryConstraint &&)=default
virtual 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,...
TrajectoryConstraint & operator=(const TrajectoryConstraint &)=default
virtual ~TrajectoryConstraint()=default
TrajectoryConstraint(const TrajectoryConstraint &)=default
Definition: AprilTagPoseEstimator.h:15
UnitTypeLhs() max(const UnitTypeLhs &lhs, const UnitTypeRhs &rhs)
Definition: base.h:3417
Represents a minimum and maximum acceleration.
Definition: TrajectoryConstraint.h:37