9#include "wpi/units/math.hpp"
10#include "wpi/units/velocity.hpp"
19template <
size_t NumModules>
24 wpi::units::meters_per_second_t maxVelocity)
25 : m_kinematics(kinematics), m_maxVelocity(maxVelocity) {}
28 const Pose2d& pose, wpi::units::curvature_t curvature,
29 wpi::units::meters_per_second_t velocity)
const override {
32 auto wheelVelocities = m_kinematics.ToSwerveModuleVelocities(
33 {xVelocity, yVelocity, velocity * curvature});
34 m_kinematics.DesaturateWheelVelocities(&wheelVelocities, m_maxVelocity);
36 auto normVelocities = m_kinematics.ToChassisVelocities(wheelVelocities);
38 return wpi::units::math::hypot(normVelocities.vx, normVelocities.vy);
42 const Pose2d& pose, wpi::units::curvature_t curvature,
43 wpi::units::meters_per_second_t velocity)
const override {
49 wpi::units::meters_per_second_t m_maxVelocity;
Represents a 2D pose containing translational and rotational elements.
Definition Pose2d.hpp:27
constexpr const Rotation2d & Rotation() const
Returns the underlying rotation.
Definition Pose2d.hpp:128
constexpr double Cos() const
Returns the cosine of the rotation.
Definition Rotation2d.hpp:235
constexpr double Sin() const
Returns the sine of the rotation.
Definition Rotation2d.hpp:242
wpi::units::meters_per_second_t MaxVelocity(const Pose2d &pose, wpi::units::curvature_t curvature, wpi::units::meters_per_second_t velocity) const override
Returns the max velocity given the current pose and curvature.
Definition SwerveDriveKinematicsConstraint.hpp:27
SwerveDriveKinematicsConstraint(const wpi::math::SwerveDriveKinematics< NumModules > &kinematics, wpi::units::meters_per_second_t maxVelocity)
Definition SwerveDriveKinematicsConstraint.hpp:22
MinMax MinMaxAcceleration(const Pose2d &pose, wpi::units::curvature_t curvature, wpi::units::meters_per_second_t velocity) const override
Returns the minimum and maximum allowable acceleration for the trajectory given pose,...
Definition SwerveDriveKinematicsConstraint.hpp:41
Helper class that converts a chassis velocity (dx, dy, and dtheta components) into individual module ...
Definition SwerveDriveKinematics.hpp:59
constexpr TrajectoryConstraint()=default
Definition LinearSystem.hpp:20
Represents a minimum and maximum acceleration.
Definition TrajectoryConstraint.hpp:36