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 * Represents a constraint that enforces a max velocity. This can be composed with the {@link
011 * EllipticalRegionConstraint} or {@link RectangularRegionConstraint} to enforce a max velocity in a
012 * region.
013 */
014public class MaxVelocityConstraint implements TrajectoryConstraint {
015  private final double m_maxVelocity;
016
017  /**
018   * Constructs a new MaxVelocityConstraint.
019   *
020   * @param maxVelocityMetersPerSecond The max velocity.
021   */
022  public MaxVelocityConstraint(double maxVelocityMetersPerSecond) {
023    m_maxVelocity = maxVelocityMetersPerSecond;
024  }
025
026  @Override
027  public double getMaxVelocityMetersPerSecond(
028      Pose2d poseMeters, double curvatureRadPerMeter, double velocityMetersPerSecond) {
029    return m_maxVelocity;
030  }
031
032  @Override
033  public TrajectoryConstraint.MinMax getMinMaxAccelerationMetersPerSecondSq(
034      Pose2d poseMeters, double curvatureRadPerMeter, double velocityMetersPerSecond) {
035    return new MinMax();
036  }
037}