54 constexpr DCMotor(units::volt_t nominalVoltage,
55 units::newton_meter_t stallTorque,
56 units::ampere_t stallCurrent, units::ampere_t freeCurrent,
57 units::radians_per_second_t freeSpeed,
int numMotors = 1)
58 : nominalVoltage(nominalVoltage),
59 stallTorque(stallTorque * numMotors),
60 stallCurrent(stallCurrent * numMotors),
61 freeCurrent(freeCurrent * numMotors),
63 R(nominalVoltage / this->stallCurrent),
64 Kv(freeSpeed / (nominalVoltage -
R * this->freeCurrent)),
65 Kt(this->stallTorque / this->stallCurrent) {}
73 constexpr units::ampere_t
Current(units::radians_per_second_t speed,
74 units::volt_t inputVoltage)
const {
75 return -1.0 / Kv /
R * speed + 1.0 /
R * inputVoltage;
83 constexpr units::newton_meter_t
Torque(units::ampere_t current)
const {
94 constexpr units::volt_t
Voltage(units::newton_meter_t torque,
95 units::radians_per_second_t speed)
const {
96 return 1.0 / Kv * speed + 1.0 / Kt *
R * torque;
106 constexpr units::radians_per_second_t
Speed(
107 units::newton_meter_t torque, units::volt_t inputVoltage)
const {
108 return inputVoltage * Kv - 1.0 / Kt * torque *
R * Kv;
117 return DCMotor(nominalVoltage, stallTorque * gearboxReduction, stallCurrent,
118 freeCurrent, freeSpeed / gearboxReduction);
125 return DCMotor(12_V, 2.42_Nm, 133_A, 2.7_A, 5310_rpm, numMotors);
132 return DCMotor(12_V, 1.41_Nm, 89_A, 3_A, 5840_rpm, numMotors);
139 return DCMotor(12_V, 0.43_Nm, 53_A, 1.8_A, 13180_rpm, numMotors);
146 return DCMotor(12_V, 0.71_Nm, 134_A, 0.7_A, 18730_rpm, numMotors);
153 return DCMotor(12_V, 0.28_Nm, 18_A, 1.6_A, 5800_rpm, numMotors);
160 return DCMotor(12_V, 0.72_Nm, 97_A, 2.7_A, 13050_rpm, numMotors);
167 return DCMotor(12_V, 0.36_Nm, 71_A, 3.7_A, 14270_rpm, numMotors);
174 return DCMotor(12_V, 0.38_Nm, 84_A, 0.4_A, 19000_rpm, numMotors);
181 return DCMotor(12_V, 2.6_Nm, 105_A, 1.8_A, 5676_rpm, numMotors);
188 return DCMotor(12_V, 0.97_Nm, 100_A, 1.4_A, 11000_rpm, numMotors);
195 return DCMotor(12_V, 4.69_Nm, 257_A, 1.5_A, 6380_rpm, numMotors);
203 return DCMotor(4.5_V, 0.1765_Nm, 1.25_A, 0.13_A, 150_rpm, numMotors);
#define WPILIB_DLLEXPORT
Definition: SymbolExports.h:36
Holds the constants for a DC motor.
Definition: DCMotor.h:20
static constexpr DCMotor Falcon500(int numMotors=1)
Returns instance of Falcon 500 brushless motor.
Definition: DCMotor.h:194
constexpr units::newton_meter_t Torque(units::ampere_t current) const
Returns torque produced by the motor with a given current.
Definition: DCMotor.h:83
units::radians_per_second_t freeSpeed
Definition: DCMotor.h:33
constexpr units::volt_t Voltage(units::newton_meter_t torque, units::radians_per_second_t speed) const
Returns the voltage provided to the motor for a given torque and angular velocity.
Definition: DCMotor.h:94
static constexpr DCMotor Bag(int numMotors=1)
Returns instance of Bag motor.
Definition: DCMotor.h:138
static constexpr DCMotor Andymark9015(int numMotors=1)
Returns instance of Andymark 9015.
Definition: DCMotor.h:166
static constexpr DCMotor BanebotsRS775(int numMotors=1)
Returns instance of Banebots RS 775.
Definition: DCMotor.h:159
units::ampere_t freeCurrent
Definition: DCMotor.h:32
static constexpr DCMotor Vex775Pro(int numMotors=1)
Returns instance of Vex 775 Pro.
Definition: DCMotor.h:145
constexpr DCMotor(units::volt_t nominalVoltage, units::newton_meter_t stallTorque, units::ampere_t stallCurrent, units::ampere_t freeCurrent, units::radians_per_second_t freeSpeed, int numMotors=1)
Constructs a DC motor.
Definition: DCMotor.h:54
static constexpr DCMotor CIM(int numMotors=1)
Returns instance of CIM.
Definition: DCMotor.h:124
constexpr DCMotor WithReduction(double gearboxReduction)
Returns a copy of this motor with the given gearbox reduction applied.
Definition: DCMotor.h:116
static constexpr DCMotor NEO(int numMotors=1)
Returns instance of NEO brushless motor.
Definition: DCMotor.h:180
units::ampere_t stallCurrent
Definition: DCMotor.h:31
static constexpr DCMotor RS775_125(int numMotors=1)
Returns instance of Andymark RS 775-125.
Definition: DCMotor.h:152
units::newton_meter_t stallTorque
Definition: DCMotor.h:30
radians_per_second_per_volt_t Kv
Definition: DCMotor.h:39
constexpr units::radians_per_second_t Speed(units::newton_meter_t torque, units::volt_t inputVoltage) const
Returns the speed produced by the motor at a given torque and input voltage.
Definition: DCMotor.h:106
static constexpr DCMotor RomiBuiltIn(int numMotors=1)
Return a gearbox of Romi/TI_RSLK MAX motors.
Definition: DCMotor.h:201
constexpr units::ampere_t Current(units::radians_per_second_t speed, units::volt_t inputVoltage) const
Returns current drawn by motor with given speed and input voltage.
Definition: DCMotor.h:73
static constexpr DCMotor NEO550(int numMotors=1)
Returns instance of NEO 550 brushless motor.
Definition: DCMotor.h:187
units::volt_t nominalVoltage
Definition: DCMotor.h:29
units::ohm_t R
Definition: DCMotor.h:36
static constexpr DCMotor MiniCIM(int numMotors=1)
Returns instance of MiniCIM.
Definition: DCMotor.h:131
static constexpr DCMotor BanebotsRS550(int numMotors=1)
Returns instance of Banebots RS 550.
Definition: DCMotor.h:173
newton_meters_per_ampere_t Kt
Definition: DCMotor.h:42
typename units::detail::inverse_impl< U >::type inverse
represents the inverse unit type of class U.
Definition: base.h:1145
typename units::detail::compound_impl< U, Us... >::type compound_unit
Represents a unit type made up from other units.
Definition: base.h:1445
Definition: AprilTagPoseEstimator.h:15
static constexpr const unit_t< compound_unit< energy::joules, inverse< temperature::kelvin >, inverse< substance::moles > > > R(8.3144598)
Gas constant.