10#include "wpi/units/math.hpp"
11#include "wpi/units/velocity.hpp"
32 wpi::units::meters_per_second_t
rearLeft = 0_mps;
55 wpi::units::meters_per_second_t attainableMaxVelocity)
const {
56 std::array<wpi::units::meters_per_second_t, 4> wheelVelocities{
58 wpi::units::meters_per_second_t realMaxVelocity =
59 wpi::units::math::abs(*std::max_element(
60 wheelVelocities.begin(), wheelVelocities.end(),
61 [](
const auto& a,
const auto& b) {
62 return wpi::units::math::abs(a) < wpi::units::math::abs(b);
65 if (realMaxVelocity > attainableMaxVelocity) {
66 for (
int i = 0; i < 4; ++i) {
68 wheelVelocities[i] / realMaxVelocity * attainableMaxVelocity;
107 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:88
constexpr MecanumDriveWheelVelocities operator-(const MecanumDriveWheelVelocities &other) const
Subtracts the other MecanumDriveWheelVelocities from the current MecanumDriveWheelVelocities and retu...
Definition MecanumDriveWheelVelocities.hpp:105
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:54
constexpr MecanumDriveWheelVelocities operator/(double scalar) const
Divides the MecanumDriveWheelVelocities by a scalar and returns the new MecanumDriveWheelVelocities.
Definition MecanumDriveWheelVelocities.hpp:146
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:131
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:117