10#include "wpi/units/math.hpp"
11#include "wpi/units/velocity.hpp"
32 wpi::units::meters_per_second_t
rearLeft = 0_mps;
56 wpi::units::meters_per_second_t attainableMaxVelocity)
const {
57 std::array<wpi::units::meters_per_second_t, 4> wheelVelocities{
59 wpi::units::meters_per_second_t realMaxVelocity =
60 wpi::units::math::abs(*std::max_element(
61 wheelVelocities.begin(), wheelVelocities.end(),
62 [](
const auto& a,
const auto& b) {
63 return wpi::units::math::abs(a) < wpi::units::math::abs(b);
66 if (realMaxVelocity > attainableMaxVelocity) {
67 for (
int i = 0; i < 4; ++i) {
69 wheelVelocities[i] / realMaxVelocity * attainableMaxVelocity;
108 return *
this + -other;
#define WPILIB_DLLEXPORT
Definition SymbolExports.hpp:36
Definition LinearSystem.hpp:20
Represents the wheel velocities for a mecanum drive drivetrain.
Definition MecanumDriveWheelVelocities.hpp:18
wpi::units::meters_per_second_t frontRight
Velocity of the front-right wheel.
Definition MecanumDriveWheelVelocities.hpp:27
constexpr MecanumDriveWheelVelocities operator+(const MecanumDriveWheelVelocities &other) const
Adds two MecanumDriveWheelVelocities and returns the sum.
Definition MecanumDriveWheelVelocities.hpp:89
constexpr MecanumDriveWheelVelocities operator-(const MecanumDriveWheelVelocities &other) const
Subtracts the other MecanumDriveWheelVelocities from the current MecanumDriveWheelVelocities and retu...
Definition MecanumDriveWheelVelocities.hpp:106
wpi::units::meters_per_second_t rearLeft
Velocity of the rear-left wheel.
Definition MecanumDriveWheelVelocities.hpp:32
constexpr MecanumDriveWheelVelocities Desaturate(wpi::units::meters_per_second_t attainableMaxVelocity) const
Renormalizes the wheel velocities if any individual velocity is above the specified maximum.
Definition MecanumDriveWheelVelocities.hpp:55
constexpr MecanumDriveWheelVelocities operator/(double scalar) const
Divides the MecanumDriveWheelVelocities by a scalar and returns the new MecanumDriveWheelVelocities.
Definition MecanumDriveWheelVelocities.hpp:147
wpi::units::meters_per_second_t frontLeft
Velocity of the front-left wheel.
Definition MecanumDriveWheelVelocities.hpp:22
constexpr MecanumDriveWheelVelocities operator*(double scalar) const
Multiplies the MecanumDriveWheelVelocities by a scalar and returns the new MecanumDriveWheelVelocitie...
Definition MecanumDriveWheelVelocities.hpp:132
wpi::units::meters_per_second_t rearRight
Velocity of the rear-right wheel.
Definition MecanumDriveWheelVelocities.hpp:37
constexpr MecanumDriveWheelVelocities operator-() const
Returns the inverse of the current MecanumDriveWheelVelocities.
Definition MecanumDriveWheelVelocities.hpp:118