7#include "wpi/units/math.hpp"
8#include "wpi/units/velocity.hpp"
19 wpi::units::meters_per_second_t
left = 0_mps;
24 wpi::units::meters_per_second_t
right = 0_mps;
41 wpi::units::meters_per_second_t attainableMaxVelocity) {
42 auto realMaxVelocity = wpi::units::math::max(wpi::units::math::abs(
left),
43 wpi::units::math::abs(
right));
45 if (realMaxVelocity > attainableMaxVelocity) {
46 left =
left / realMaxVelocity * attainableMaxVelocity;
47 right =
right / realMaxVelocity * attainableMaxVelocity;
79 return *
this + -other;
#define WPILIB_DLLEXPORT
Definition SymbolExports.hpp:36
Definition LinearSystem.hpp:20
Represents the wheel velocities for a differential drive drivetrain.
Definition DifferentialDriveWheelVelocities.hpp:15
constexpr void Desaturate(wpi::units::meters_per_second_t attainableMaxVelocity)
Renormalizes the wheel velocities if either side is above the specified maximum.
Definition DifferentialDriveWheelVelocities.hpp:40
constexpr DifferentialDriveWheelVelocities operator-(const DifferentialDriveWheelVelocities &other) const
Subtracts the other DifferentialDriveWheelVelocities from the current DifferentialDriveWheelVelocitie...
Definition DifferentialDriveWheelVelocities.hpp:77
constexpr DifferentialDriveWheelVelocities operator+(const DifferentialDriveWheelVelocities &other) const
Adds two DifferentialDriveWheelVelocities and returns the sum.
Definition DifferentialDriveWheelVelocities.hpp:61
constexpr DifferentialDriveWheelVelocities operator-() const
Returns the inverse of the current DifferentialDriveWheelVelocities.
Definition DifferentialDriveWheelVelocities.hpp:89
constexpr DifferentialDriveWheelVelocities operator*(double scalar) const
Multiplies the DifferentialDriveWheelVelocities by a scalar and returns the new DifferentialDriveWhee...
Definition DifferentialDriveWheelVelocities.hpp:103
wpi::units::meters_per_second_t right
Velocity of the right side of the robot.
Definition DifferentialDriveWheelVelocities.hpp:24
wpi::units::meters_per_second_t left
Velocity of the left side of the robot.
Definition DifferentialDriveWheelVelocities.hpp:19
constexpr DifferentialDriveWheelVelocities operator/(double scalar) const
Divides the DifferentialDriveWheelVelocities by a scalar and returns the new DifferentialDriveWheelVe...
Definition DifferentialDriveWheelVelocities.hpp:117