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 poseMeters The pose at the current point in the trajectory. 018 * @param curvatureRadPerMeter The curvature at the current point in the trajectory. 019 * @param velocityMetersPerSecond The velocity at the current point in the trajectory before 020 * constraints are applied. 021 * @return The absolute maximum velocity. 022 */ 023 double getMaxVelocityMetersPerSecond( 024 Pose2d poseMeters, double curvatureRadPerMeter, double velocityMetersPerSecond); 025 026 /** 027 * Returns the minimum and maximum allowable acceleration for the trajectory given pose, 028 * curvature, and speed. 029 * 030 * @param poseMeters The pose at the current point in the trajectory. 031 * @param curvatureRadPerMeter The curvature at the current point in the trajectory. 032 * @param velocityMetersPerSecond The speed at the current point in the trajectory. 033 * @return The min and max acceleration bounds. 034 */ 035 MinMax getMinMaxAccelerationMetersPerSecondSq( 036 Pose2d poseMeters, double curvatureRadPerMeter, double velocityMetersPerSecond); 037 038 /** Represents a minimum and maximum acceleration. */ 039 @SuppressWarnings("MemberName") 040 class MinMax { 041 public double minAccelerationMetersPerSecondSq = -Double.MAX_VALUE; 042 public double maxAccelerationMetersPerSecondSq = +Double.MAX_VALUE; 043 044 /** 045 * Constructs a MinMax. 046 * 047 * @param minAccelerationMetersPerSecondSq The minimum acceleration. 048 * @param maxAccelerationMetersPerSecondSq The maximum acceleration. 049 */ 050 public MinMax( 051 double minAccelerationMetersPerSecondSq, double maxAccelerationMetersPerSecondSq) { 052 this.minAccelerationMetersPerSecondSq = minAccelerationMetersPerSecondSq; 053 this.maxAccelerationMetersPerSecondSq = maxAccelerationMetersPerSecondSq; 054 } 055 056 /** Constructs a MinMax with default values. */ 057 public MinMax() {} 058 } 059}