WPILibC++ 2027.0.0-alpha-5
Loading...
Searching...
No Matches
wpi::math::SwerveModuleVelocity Struct Reference

Represents the velocity of one swerve module. More...

#include <wpi/math/kinematics/SwerveModuleVelocity.hpp>

Public Member Functions

constexpr bool operator== (const SwerveModuleVelocity &other) const
 Checks equality between this SwerveModuleVelocity and another object.
constexpr SwerveModuleVelocity Optimize (const Rotation2d &currentAngle)
 Minimize the change in the heading this swerve module velocity would require by potentially reversing the direction the wheel spins.
constexpr SwerveModuleVelocity CosineScale (const Rotation2d &currentAngle)
 Scales velocity by cosine of angle error.

Public Attributes

wpi::units::meters_per_second_t velocity = 0_mps
 Velocity of the wheel of the module.
Rotation2d angle
 Angle of the module.

Detailed Description

Represents the velocity of one swerve module.

Member Function Documentation

◆ CosineScale()

SwerveModuleVelocity wpi::math::SwerveModuleVelocity::CosineScale ( const Rotation2d & currentAngle)
inlinenodiscardconstexpr

Scales velocity by cosine of angle error.

This scales down movement perpendicular to the desired direction of travel that can occur when modules change directions. This results in smoother driving.

Parameters
currentAngleThe current module angle.
Returns
The scaled SwerveModuleVelocity.

◆ operator==()

bool wpi::math::SwerveModuleVelocity::operator== ( const SwerveModuleVelocity & other) const
inlineconstexpr

Checks equality between this SwerveModuleVelocity and another object.

Parameters
otherThe other object.
Returns
Whether the two objects are equal.

◆ Optimize()

SwerveModuleVelocity wpi::math::SwerveModuleVelocity::Optimize ( const Rotation2d & currentAngle)
inlinenodiscardconstexpr

Minimize the change in the heading this swerve module velocity would require by potentially reversing the direction the wheel spins.

If this is used with the PIDController class's continuous input functionality, the furthest a wheel will ever rotate is 90 degrees.

Parameters
currentAngleThe current module angle.
Returns
The optimized SwerveModuleVelocity.

Member Data Documentation

◆ angle

Rotation2d wpi::math::SwerveModuleVelocity::angle

Angle of the module.

◆ velocity

wpi::units::meters_per_second_t wpi::math::SwerveModuleVelocity::velocity = 0_mps

Velocity of the wheel of the module.


The documentation for this struct was generated from the following file: