14#ifndef VEX_MOTOR_CLASS_H
15#define VEX_MOTOR_CLASS_H
22#define VEXIQ_MOTOR_OVERTEMP_FLAG 0x02
23#define VEXIQ_MOTOR_CURLIMIT_FLAG 0x04
24#define VEXIQ_MOTOR_ZEROVEL_FLAG 0x08
25#define VEXIQ_MOTOR_ZEROPOS_FLAG 0x10
51 motor( int32_t index,
bool reverse );
58 motor( int32_t index,
double gearRatio );
66 motor( int32_t index,
double gearRatio,
bool reverse );
91 void setBrake( brakeType mode );
124 void spin( directionType dir );
134 void spin( directionType dir,
double velocity, percentUnits units ){
135 spin( dir,
velocity,
static_cast<velocityUnits
>(units) );
144 void spin( directionType dir,
double voltage, voltageUnits units );
155 bool spinTo(
double rotation, rotationUnits units,
double velocity, velocityUnits units_v,
bool waitForCompletion=
true );
157 bool spinToPosition(
double rotation, rotationUnits units,
double velocity, velocityUnits units_v,
bool waitForCompletion=
true );
166 bool spinTo(
double rotation, rotationUnits units,
bool waitForCompletion=
true );
168 bool spinToPosition(
double rotation, rotationUnits units,
bool waitForCompletion=
true );
179 bool spinFor(
double rotation, rotationUnits units,
double velocity, velocityUnits units_v,
bool waitForCompletion=
true );
181 bool spinFor( directionType dir,
double rotation, rotationUnits units,
double velocity, velocityUnits units_v,
bool waitForCompletion=
true );
190 bool spinFor(
double rotation, rotationUnits units,
bool waitForCompletion=
true );
192 bool spinFor( directionType dir,
double rotation, rotationUnits units,
bool waitForCompletion=
true );
204 bool spinFor( directionType dir,
double time, timeUnits units,
double velocity, velocityUnits units_v );
214 bool spinFor( directionType dir,
double time, timeUnits units );
228 bool isSpinningMode(
void );
284 double velocity( percentUnits units ) {
285 return velocity(
static_cast<velocityUnits
>(units) );
293 double current( currentUnits units = currentUnits::amp );
310 double voltage( voltageUnits units = voltageUnits::volt );
317 double power( powerUnits units = powerUnits::watt );
324 double torque( torqueUnits units = torqueUnits::Nm );
349 int32_t getTimeout();
350 double getVelocity( velocityUnits units );
355 int16_t _last_velocity;
358 brakeType _brakeMode;
364 void defaultStopping( brakeType mode );
366 bool zeroPositionFlag(
void );
367 uint8_t modeGet(
void );
369 double velocityToScaled( int32_t
velocity, velocityUnits units );
370 int32_t scaledToVelocity(
double value, velocityUnits units );
371 double encoderToScaled( int32_t counts, rotationUnits units );
372 int32_t scaledToEncoder(
double position, rotationUnits units );
373 double torqueToCurrent(
double torque );
Use the motor class to control motor devices.
void setVelocity(double velocity, velocityUnits units)
Sets the velocity of the motor based on the parameters set in the command. This command will not run ...
bool spinFor(double rotation, rotationUnits units, bool waitForCompletion=true)
Turns on the motor and spins it to a relative target rotation value.
motor(int32_t index)
Creates a new motor object on the port specified.
bool spinTo(double rotation, rotationUnits units, bool waitForCompletion=true)
Turns on the motor and spins it to an absolute target rotation value.
double position(rotationUnits units)
Gets the current position of the motor's encoder.
bool isSpinning(void)
Checks to see if the motor is rotating to a specific target.
motor(int32_t index, bool reverse)
Creates a new motor object on the port specified and sets the reversed flag.
void setMaxTorque(double value, percentUnits units)
Sets the max torque of the motor.
void setStopping(brakeType mode)
Sets the stopping mode of the motor by passing a brake mode as a parameter.
directionType direction(void)
Gets which direction the motor is spinning.
void setTimeout(int32_t time, timeUnits units)
Sets the timeout for the motor. If the motor does not reach its' commanded position prior to the comp...
double torque(torqueUnits units=torqueUnits::Nm)
Gets the torque of the motor.
bool spinFor(double rotation, rotationUnits units, double velocity, velocityUnits units_v, bool waitForCompletion=true)
Turns on the motor and spins it to a relative target rotation value at a specified velocity.
void setReversed(bool value)
Sets the motor mode to "reverse", which will make motor commands spin the motor in the opposite direc...
void stop(brakeType mode)
Stops the motor using a specified brake mode.
double voltage(voltageUnits units=voltageUnits::volt)
Gets the electrical voltage of the motor.
motor(int32_t index, double gearRatio)
Creates a new motor object on the port specified and sets the output gear ratio.
void spin(directionType dir, double voltage, voltageUnits units)
Turns on the motor and spins it in a specified direction and a specified voltage.
motor(int32_t index, double gearRatio, bool reverse)
Creates a new motor object on the port specified and sets the output gear ratio and reverse flag.
bool isDone(void)
Checks to see if the motor is done rotating to a specific target.
void setMaxTorque(double value, torqueUnits units)
Sets the max torque of the motor.
double temperature(percentUnits units=percentUnits::pct)
Gets the temperature of the motor.
void spin(directionType dir)
Turns the motor on, and spins it in the specified direction.
bool spinTo(double rotation, rotationUnits units, double velocity, velocityUnits units_v, bool waitForCompletion=true)
Turns on the motor and spins it to an absolute target rotation value at a specified velocity.
double current(percentUnits units)
Gets the electrical current of the motor in percentage of maximum.
double efficiency(percentUnits units=percentUnits::pct)
Gets the efficiency of the motor.
void spin(directionType dir, double velocity, velocityUnits units)
Turns on the motor and spins it in a specified direction and a specified velocity.
void setMaxTorque(double value, currentUnits units)
Sets the max torque of the motor.
void resetPosition(void)
Resets the motor's encoder to the value of zero.
double power(powerUnits units=powerUnits::watt)
Gets the power of the motor.
void setPosition(double value, rotationUnits units)
Sets the value of the motor's encoder to the value specified in the parameter.
bool spinFor(double time, timeUnits units, double velocity, velocityUnits units_v)
Turns on the motor and spins it to a relative target time value at a specified velocity.
double temperature(temperatureUnits units)
Gets the temperature of the motor.
void setVelocity(double velocity, percentUnits units)
Sets the velocity of the motor based on the parameters set in the command. This command will not run ...
bool spinFor(double time, timeUnits units)
Turns on the motor and spins it to a relative target time value.
void stop(void)
Stops the motor using the default brake mode.
double current(currentUnits units=currentUnits::amp)
Gets the electrical current of the motor.
double velocity(velocityUnits units)
Gets the current velocity of the motor.
Bumper switch device class