001// Copyright (c) FIRST and other WPILib contributors. 002// Open Source Software; you can modify and/or share it under the terms of 003// the WPILib BSD license file in the root directory of this project. 004 005package edu.wpi.first.math.trajectory.constraint; 006 007import edu.wpi.first.math.geometry.Pose2d; 008 009/** 010 * An interface for defining user-defined velocity and acceleration constraints while generating 011 * trajectories. 012 */ 013public interface TrajectoryConstraint { 014 /** 015 * Returns the max velocity given the current pose and curvature. 016 * 017 * @param pose The pose at the current point in the trajectory. 018 * @param curvature The curvature at the current point in the trajectory rad/m. 019 * @param velocity The velocity at the current point in the trajectory before constraints are 020 * applied in m/s. 021 * @return The absolute maximum velocity. 022 */ 023 double getMaxVelocity(Pose2d pose, double curvature, double velocity); 024 025 /** 026 * Returns the minimum and maximum allowable acceleration for the trajectory given pose, 027 * curvature, and speed. 028 * 029 * @param pose The pose at the current point in the trajectory. 030 * @param curvature The curvature at the current point in the trajectory rad/m. 031 * @param velocity The speed at the current point in the trajectory in m/s. 032 * @return The min and max acceleration bounds. 033 */ 034 MinMax getMinMaxAcceleration(Pose2d pose, double curvature, double velocity); 035 036 /** Represents a minimum and maximum acceleration. */ 037 class MinMax { 038 /** The minimum acceleration. */ 039 public double minAcceleration = -Double.MAX_VALUE; 040 041 /** The maximum acceleration. */ 042 public double maxAcceleration = Double.MAX_VALUE; 043 044 /** 045 * Constructs a MinMax. 046 * 047 * @param minAcceleration The minimum acceleration in m/s². 048 * @param maxAcceleration The maximum acceleration in m/s². 049 */ 050 public MinMax(double minAcceleration, double maxAcceleration) { 051 this.minAcceleration = minAcceleration; 052 this.maxAcceleration = maxAcceleration; 053 } 054 055 /** Constructs a MinMax with default values. */ 056 public MinMax() {} 057 } 058}