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 class MinMax { 040 /** The minimum acceleration. */ 041 public double minAccelerationMetersPerSecondSq = -Double.MAX_VALUE; 042 043 /** The maximum acceleration. */ 044 public double maxAccelerationMetersPerSecondSq = Double.MAX_VALUE; 045 046 /** 047 * Constructs a MinMax. 048 * 049 * @param minAccelerationMetersPerSecondSq The minimum acceleration. 050 * @param maxAccelerationMetersPerSecondSq The maximum acceleration. 051 */ 052 public MinMax( 053 double minAccelerationMetersPerSecondSq, double maxAccelerationMetersPerSecondSq) { 054 this.minAccelerationMetersPerSecondSq = minAccelerationMetersPerSecondSq; 055 this.maxAccelerationMetersPerSecondSq = maxAccelerationMetersPerSecondSq; 056 } 057 058 /** Constructs a MinMax with default values. */ 059 public MinMax() {} 060 } 061}