Motor y Grupo Motor#
Introducción#
Motors and motor groups control how parts of a robot move. A motor object controls one configured IQ Smart Motor, while a motor_group object controls multiple configured IQ Smart Motors together so they move in tandem. Motors and motor groups can be used to raise an arm, turn a claw, spin a wheel, or move another part of a build. Two motors can work together as a drivetrain to move and turn the whole robot.
Each motor or motor group is configured in the Devices window. Depending on the build, motor and motor group names can change. This page uses Motor1 and MotorGroup1 as example names. Replace them with your own configured names as needed.
By default, forward spins a motor counterclockwise, and reverse spins a motor clockwise. If a motor is set to reverse, those directions will be switched.
Motor#
Class Constructors#
1 — Creates a
motorobject for the IQ Smart Motor connected to the specified Smart Port. The motor automatically uses the detected internalgearSetting.motor( int32_t index );
2 — Creates a
motorobject on the specified Smart Port and optionally reverses its direction. The motor automatically uses the detected internalgearSetting.motor( int32_t index, bool reverse );
3 — Creates a
motorobject on the specified Smart Port with the specifiedgearSetting.motor( int32_t index, gearSetting gears );
4 — Creates a
motorobject on the specified Smart Port with the specifiedgearSettingand optional reversed direction.motor( int32_t index, gearSetting gears, bool reverse );
Class Destructor#
Destroys the motor object and releases associated resources.
~motor();
Parameters#
Parámetro |
Tipo |
Descripción |
|---|---|---|
|
|
The Smart Port that the motor is connected to, written as |
|
|
Sets whether the motor’s spin direction is reversed:
|
|
|
Specifies the internal gear cartridge ratio.
|
Notes#
La configuración de la transmisión debe coincidir con el cartucho físico instalado en el motor.
Example#
// Create the motor instance in Smart Port 1
motor LeftMotor = motor(PORT1);
// Creates the motor instance with different settings
motor RightMotor = motor(
PORT2, // Smart Port 2
ratio2_1, // Gear ratio is 2:1
true);
Grupo Motor#
Class Constructors#
motor_group( motor &m1, Args&... m2 );
Class Destructor#
Destroys the motor_group object and releases associated resources.
~motor_group();
Parameters#
Parámetro |
Tipo |
Descripción |
|---|---|---|
|
|
El primer motor añadido al grupo. |
|
|
Se han añadido motores adicionales al grupo. El máximo es de cuatro motores por grupo. |
Example#
// Create individual motor instances
motor LeftMotor = motor(PORT1);
motor RightMotor = motor(PORT2);
// Create a motor group with both motors
motor_group DriveMotors = motor_group(LeftMotor, RightMotor);
Funciones de los miembros#
There are many ways to code motors and motor groups. Below is a list of all motor and motor_group member functions:
Acciones: Detener y hacer girar motores y grupos de motores.
spin— Spins a motor or motor group forward or reverse forever.spinFor— Spins a motor or motor group for a specific distance or amount of time.spinToPosition— Spins a motor or motor group to a specific position.stop— Stops a motor or motor group from spinning.
Motadores: ajustan la configuración del motor y del grupo de motores.
setVelocity— Tells a motor or motor group how fast to spin.setMaxTorque— Sets how hard a motor or motor group is allowed to push while spinning.setPosition— Changes the motor or motor group’s current position to a new value.setStopping— Sets how a motor or motor group will stop moving: by braking, coasting, or holding.setTimeout— Sets how much time a motor or motor group will try to finish a movement.
Obtenedores: compruebe el estado del motor y del grupo de motores.
isDone— Returns whether the motor or motor group is finished moving, as a Boolean value.isSpinning— Returns whether the motor or motor group is spinning, as a Boolean value.position— Returns the motor or motor group’s current position.velocity— Returns how fast the motor or motor group is spinning.current— Returns how much electrical current the motor or motor group is using.power— Returns how much power the motor or motor group is using.torque— Returns how much torque the motor or motor group is using.efficiency— Returns how efficiently the motor or motor group is using power.temperature— Returns the temperature of the motor or motor group.voltage— Returns the electrical voltage supplied to the motor or motor group.direction— Returns the direction the motor or motor group is spinning.installed— Returns whether the motor or motor group is connected to the Brain.count— Returns the number of motors in a motor group.
Before calling any motor or motor_group member functions, an instance must be created, as shown below:
/* This constructor is required when using VS Code.
Motor and Motor Group configuration is generated automatically
in VEXcode using the Device Menu. Replace the values
as needed. */
// Create the motor instance in Smart Port 1
motor Motor1 = motor(PORT1);
Comportamiento#
spin#
spin spins a motor or motor group forward or reverse forever. The motor or motor group will continue to spin until it is given another action, like spinning in a different direction or stopping.
1 — Hace girar el motor o grupo de motores utilizando la velocidad del motor configurada actualmente.
void spin( directionType dir );
2 — Hace girar el motor o grupo de motores a la velocidad especificada.
void spin( directionType dir, double velocity, velocityUnits units );
Parameters3 — Hace girar el motor o grupo de motores utilizando el voltaje especificado.
void spin( directionType dir, double voltage, voltageUnits units );
Parámetro |
Tipo |
Descripción |
|---|---|---|
|
|
The direction the motor or motor group spins: |
|
|
The velocity to spin with from 0% to 100% when using |
|
|
The unit used to represent velocity:
|
|
|
The voltage to spin with. A negative value spins opposite the given |
|
|
The unit used to represent voltage:
|
Esta función no devuelve ningún valor.
NotesEsta función no requiere espera y el proyecto continuará ejecutándose inmediatamente después de la llamada.
The motor or motor group will continue spinning until
stopis called or another movement function is executed.Functions such as
isDoneandisSpinningare not applicable tospin, since it does not use target-based movement (doesn’t have arotationortimeparameter).
// Spin forward, then stop
Motor1.spin(forward);
wait(1, seconds);
Motor1.stop();
spinFor#
spinFor spins a motor or motor group for a specific distance or amount of time. A rotation-based spin is relative to the current position of the motor or motor group. By default, the project will wait until the motor or motor group is done spinning before the next line of code runs.
1 — Gira una distancia específica a la velocidad proporcionada en la llamada a la función.
bool spinFor( double rotation, rotationUnits units, double velocity, velocityUnits units_v, bool waitForCompletion = true );
2 — Acepta un parámetro de dirección y gira una distancia específica a la velocidad proporcionada en la llamada a la función.
bool spinFor( directionType dir, double rotation, rotationUnits units, double velocity, velocityUnits units_v, bool waitForCompletion = true );
3 — Gira una distancia específica utilizando la velocidad del motor configurada actualmente.
bool spinFor( double rotation, rotationUnits units, bool waitForCompletion = true );
4 — Acepta un parámetro de dirección y gira una distancia específica utilizando la velocidad del motor configurada actualmente.
bool spinFor( directionType dir, double rotation, rotationUnits units, bool waitForCompletion = true );
5 — Gira durante una cantidad de tiempo específica a la velocidad proporcionada en la llamada a la función.
bool spinFor( double time, timeUnits units, double velocity, velocityUnits units_v );
6 — Acepta un parámetro de dirección y gira durante una cantidad de tiempo específica a la velocidad proporcionada en la llamada a la función.
bool spinFor( directionType dir, double time, timeUnits units, double velocity, velocityUnits units_v );
7 — Gira durante una cantidad de tiempo específica utilizando la velocidad del motor configurada actualmente.
bool spinFor( double time, timeUnits units );
Parameters8 — Acepta un parámetro de dirección y gira durante una cantidad de tiempo específica utilizando la velocidad del motor configurada actualmente.
bool spinFor( directionType dir, double time, timeUnits units );
Parámetro |
Tipo |
Descripción |
|---|---|---|
|
|
The direction the motor or motor group spins: |
|
|
La distancia que gira el motor o el grupo de motores. |
|
|
The rotation unit:
|
|
|
El tiempo que gira el motor o el grupo de motores. |
|
|
The unit of time:
|
|
|
The velocity to spin with from 0% to 100% when using |
|
|
The unit used to represent
|
|
|
|
Devuelve un valor booleano que indica si el motor o el grupo de motores alcanzó el valor objetivo.
true— The motor or motor group reached the target value.false— The motor or motor group was not able to reach the target value orwaitForCompletionis set tofalse.
Executing another motor movement function (such as
spinorstop) whilespinForis in progress will interrupt the current movement.Because
spinForis target-based (uses arotationortimeparameter), functions such asisDoneandisSpinningwork withspinFor.
// Spin 1 turn fast, then 1 turn slow
Motor1.spinFor(forward, 1, turns, true);
Motor1.spinFor(reverse, 1, turns, 20, velocityUnits::pct, true);
spinToPosition#
spinToPosition spins a motor or motor group to a specific position.
A motor or motor group’s position is how far it has spun, measured in degrees or turns. One turn is equal to 360 degrees. At the beginning of a project, the motor or motor group position is set to 0 degrees. The motor or motor group position can also be set using the setPosition function.
Los valores de posición son absolutos. Esto significa que la dirección del giro depende de la posición actual del motor o grupo de motores.
Por ejemplo, si el motor o grupo de motores parte de 0 grados y gira hasta una posición de 720 grados, girará dos vueltas hacia adelante. Si luego gira hasta una posición de 360 grados, girará una vuelta hacia atrás, ya que 360 es menor que 720.
Available Functions1 — Gira hasta una posición específica a la velocidad proporcionada en la llamada a la función.
bool spinToPosition( double rotation, rotationUnits units, double velocity, velocityUnits units_v, bool waitForCompletion = true );
Parameters2 — Gira a una posición específica utilizando la velocidad del motor configurada actualmente.
bool spinToPosition( double rotation, rotationUnits units, bool waitForCompletion = true );
Parámetro |
Tipo |
Descripción |
|---|---|---|
|
|
El valor de posición al que girará el motor o grupo de motores. |
|
|
The rotation unit:
|
|
|
The velocity to spin with from 0% to 100% when using |
|
|
The unit used to represent
|
|
|
|
Devuelve un valor booleano que indica si el motor o el grupo de motores inició el movimiento solicitado basado en el objetivo.
true— The motor or motor group begins the requested target-based movement.false— The call fails orwaitForCompletionis set tofalse.
Executing another motor movement function (such as
spinorspinFor) whilespinToPositionis in progress will interrupt the current movement.Because
spinToPositionis target-based (uses arotationparameter), functions such asisDoneandisSpinningwork withspinToPosition.
// Spin forward, then go to 90°
Motor1.spin(forward);
wait(1, seconds);
Motor1.spinToPosition(90, degrees);
stop#
stop stops a motor or motor group from spinning.
1 — Detiene el motor o grupo de motores utilizando el modo de frenado configurado actualmente.
void stop();
Parameters2 — Detiene el motor o grupo de motores utilizando el modo de freno proporcionado en la llamada a la función.
void stop( brakeType mode );
Parámetro |
Tipo |
Descripción |
|---|---|---|
|
|
Optional. How the motor or motor group will stop:
|
Esta función no devuelve ningún valor.
NotesCalling
stopimmediately stops any current motor or motor group movement.Si no se especifica ningún modo de frenado, el motor o grupo de motores utiliza el modo de frenado configurado actualmente.
stopinterrupts any active target-based movement (such asspinFororspinToPosition).
// Spin and coast to a stop
Motor1.setVelocity(100, percent);
Motor1.spin(forward);
wait(1, seconds);
Motor1.stop(coast);
Mutadores#
setVelocity#
setVelocity tells a motor or motor group how fast to spin. A higher percentage makes the motor or motor group spin faster and a lower percentage makes the motor or motor group spin slower.
Cada proyecto comienza con cada motor o grupo de motores girando al 50% de su velocidad por defecto.
Nota: Una mayor velocidad hace que el motor o grupo de motores gire más rápido, pero puede ser menos preciso. Una menor velocidad hace que el motor o grupo de motores gire más lento, pero puede ser más preciso.
Available Functionsvoid setVelocity(
double velocity,
velocityUnits units );
Parámetro |
Tipo |
Descripción |
|---|---|---|
|
|
The velocity to spin with from 0% to 100% when using |
|
|
The unit used to represent
|
Esta función no devuelve ningún valor.
NotesAny subsequent motor movement function (such as
spin,spinFor, orspinToPosition) that does not explicitly specify a velocity will use this value.
// Try default, then slow, then fast
Motor1.spinFor(forward, 180, degrees);
wait(1, seconds);
Motor1.setVelocity(20, percent);
Motor1.spinFor(reverse, 180, degrees);
wait(1, seconds);
Motor1.setVelocity(100, percent);
Motor1.spinFor(forward, 180, degrees);
setMaxTorque#
El par motor indica la fuerza con la que un motor o un grupo de motores puede empujar o tirar mientras gira.
setMaxTorque sets the most torque a motor or motor group is allowed to use.
Un porcentaje mayor permite que el motor o grupo de motores empuje con más fuerza, como al levantar un objeto pesado. Un porcentaje menor limita la fuerza que puede ejercer el motor o grupo de motores. Esto puede ayudar a proteger al robot si el motor o grupo de motores se atasca o alcanza el límite de su recorrido.
Cada proyecto comienza con el par motor de cada motor o grupo de motores al 50% por defecto.
Available Functions1 — Establece el par máximo como un porcentaje del par nominal del motor o grupo de motores.
void setMaxTorque( double value, percentUnits units );
2 — Establece el par máximo utilizando unidades de par físico.
void setMaxTorque( double value, torqueUnits units );
Parameters3 — Establece el par máximo limitando la corriente del motor.
void setMaxTorque( double value, currentUnits units );
Parámetro |
Tipo |
Descripción |
|---|---|---|
|
|
El par máximo que puede utilizar el motor o grupo de motores. |
|
|
Specifies torque as a percentage: |
|
|
Specifies torque in physical units such as:
|
|
|
Specifies torque by limiting motor current:
|
Esta función no devuelve ningún valor.
NotesWhen using
currentUnits, torque is limited by restricting how much electrical current the motor or motor group can use.
setPosition#
A motor or motor group’s position is how far it has spun, measured in degrees or turns. One turn is equal to 360 degrees. setPosition changes the motor or motor group’s current position to a new value.
Por ejemplo, si un motor o grupo de motores ha girado 180 grados, al ajustar la posición a 0 grados, dicha posición volverá a su estado original. A continuación, el motor o grupo de motores podrá girar a posiciones que se ajusten a ese nuevo valor.
Available Functionsvoid setPosition(
double value,
rotationUnits units );
Parámetro |
Tipo |
Descripción |
|---|---|---|
|
|
El valor de posición que se establecerá para el motor o grupo de motores. |
|
|
The position unit:
|
Esta función no devuelve ningún valor.
NotesAfter calling
setPosition, subsequent calls tospinToPositionwill use the updated position as the reference.
setStopping#
setStopping sets how a motor or motor group will stop moving: by braking, coasting, or holding.
void setStopping(
brakeType mode );
Parámetro |
Tipo |
Descripción |
|---|---|---|
|
|
How the motor or motor group will stop:
|
Esta función no devuelve ningún valor.
NotesAny subsequent call to
stopwithout a specified brake mode will use this value.
setTimeout#
setTimeout sets how much time a motor or motor group will try to finish a movement. If the motor or motor group cannot finish in that time, it will stop trying and move on to the next line of code. This keeps the motor or motor group from getting stuck on a movement.
void setTimeout(
int32_t time,
timeUnits units );
Parámetro |
Tipo |
Descripción |
|---|---|---|
|
|
El tiempo que el motor o grupo de motores puede intentar para completar un movimiento. Debe ser un número entero positivo. |
|
|
The unit of time:
|
Valores de retorno
Esta función no devuelve ningún valor.
NotesEl tiempo de espera del motor o grupo de motores se utiliza para evitar que los movimientos que no alcanzan su posición objetivo detengan la ejecución de otros comandos en la pila.
Si el motor o el grupo de motores no alcanza su posición objetivo antes de que expire el tiempo de espera, dejará de intentarlo y pasará a la siguiente línea de código.
The timeout applies to functions that have a target value such as
spinForandspinToPosition.
// Stop a long move after 1 second
Motor1.setTimeout(1, seconds);
Motor1.spinFor(forward, 2, turns);
Motor1.spinToPosition(0, degrees);
Captadores#
isDone#
isDone returns whether the motor or motor group is finished moving, as a Boolean value. This can be used to control the timing of other behaviors based on the motor or motor group’s movement.
true— The motor or motor group is finished moving.false— The motor or motor group is still moving.
This function works together with the following Motion functions that have the waitForCompletion parameter: spinFor and spinToPosition.
bool isDone();
Esta función no acepta ningún parámetro.
Return ValuesDevuelve, como valor booleano, si el motor o el grupo de motores ha terminado de moverse.
true— The motor or motor group is finished moving.false— The motor or motor group is still moving.
isDoneworks together with the following Motion functions that have thewaitForCompletionparameter:spinForandspinToPosition.
// Spin forward until the motor is done spinning
Motor1.spinFor(forward, 200, degrees, false);
while (true) {
if (Motor1.isDone()) {
Drivetrain.stop();
} else {
Drivetrain.drive(forward);
}
}
isSpinning#
isSpinning returns whether the motor or motor group is spinning, as a Boolean value. This can be used to control the timing of other behaviors based on the motor or motor group’s movement.
true— The motor or motor group is spinning.false— The motor or motor group is not spinning.
This function works together with Motion movement functions such as spin, spinFor, and spinToPosition.
bool isSpinning();
Esta función no acepta ningún parámetro.
Return ValuesDevuelve, como valor booleano, si el motor o el grupo de motores está girando.
true— The motor or motor group is spinning.false— The motor or motor group is not spinning.
isSpinningworks with Motion movement functions such asspin,spinFor, andspinToPosition.
// Spin forward until the motor is done spinning
Motor1.spinFor(forward, 200, degrees, false);
while (true) {
if (Motor1.isSpinning()) {
Drivetrain.drive(forward);
} else {
Drivetrain.stop();
}
}
position#
A motor or motor group’s position is how far it has spun, measured in degrees or turns. One turn is equal to 360 degrees. position returns the motor or motor group’s current position.
Al inicio del proyecto, la posición del motor o grupo de motores se establece en 0 grados. Si el motor o grupo de motores gira una vuelta hacia adelante, la posición será de 360 grados o 1 vuelta. Si el motor o grupo de motores gira en sentido contrario, la posición será negativa.
Available Functionsdouble position(
rotationUnits units );
Parámetro |
Tipo |
Descripción |
|---|---|---|
|
|
The unit to return the motor or motor group position in:
|
Returns a double representing the motor or motor group’s current position in the specified units.
Calling
setPositionchanges the reference point for this value.El valor devuelto refleja la lectura actual del codificador y no indica si el motor o el grupo de motores se está moviendo activamente.
When called on a
motor_group, this function returns the position of the first motor in the group.
// Spin, then show the final position
Motor1.spin(forward);
wait(1, seconds);
Motor1.stop();
Brain.Screen.print("Pos: %f", Motor1.position(degrees));
velocity#
velocity returns how fast the motor or motor group is spinning.
Un valor positivo indica que el motor o el grupo de motores gira hacia adelante. Un valor negativo indica que gira en sentido inverso.
Available Functionsdouble velocity(
velocityUnits units );
Parámetro |
Tipo |
Descripción |
|---|---|---|
|
|
The unit used to represent velocity:
|
Returns a double representing how fast the motor or motor group is spinning in the specified units.
Notas
When called on a
motor_group, this function returns the velocity of the first motor in the group.
current#
current returns how much electrical current the motor or motor group is using. Current is the amount of electricity flowing through the motor or motor group. When returned in amps, current is reported from 0.0 to 1.2 A.
Un valor de corriente más alto significa que el motor o grupo de motores está consumiendo más corriente eléctrica. Esto puede ocurrir cuando el motor o grupo de motores levanta algo pesado, empuja contra un objeto o intenta moverse cuando está atascado.
Esto permite comprobar si el motor o el grupo de motores presenta dificultades durante el movimiento. Si la corriente se mantiene alta, el motor podría calentarse o consumir menos energía.
Available Functions1 — Devuelve la corriente eléctrica del motor o grupo de motores en amperios.
double current( currentUnits units = amp );
Parameters2 — Devuelve la corriente eléctrica del motor o grupo de motores como un porcentaje de la corriente nominal máxima.
double current( percentUnits units );
Parámetro |
Tipo |
Descripción |
|---|---|---|
|
|
The unit used to represent current: |
|
|
Represents the current as a percentage of the motor’s maximum rated current: |
Returns a double representing how much electrical current the motor or motor group is drawing in the specified units.
Notas
When called on a
motor_group, this function returns the total electrical current for all motors in the group.
power#
power returns how much power the motor or motor group is using in watts. Power shows how quickly the motor or motor group is using energy.
Un valor de potencia más alto significa que el motor o grupo de motores consume energía más rápidamente. Esto puede ocurrir cuando el motor o grupo de motores levanta algo pesado, empuja contra un objeto o intenta moverse cuando está atascado.
Esto puede utilizarse para comparar movimientos o comprobar si el motor o el grupo de motores presenta dificultades. Si la potencia se mantiene alta, el motor podría calentarse o consumir energía de forma menos eficiente.
Available Functionsdouble power(
powerUnits units = watt );
Parámetros
Parámetro |
Tipo |
Descripción |
|---|---|---|
|
|
The unit used to represent the motor power:
|
Valores de retorno
Returns a double representing how much power the motor or motor group is using in watts.
Notas
When called on a
motor_group, this function returns the electrical power of the first motor in the group.
torque#
El par motor indica la fuerza con la que un motor o un grupo de motores gira, empuja o tira mientras gira.
torque returns how much torque the motor or motor group is using.
Un valor de par motor más elevado indica que el motor o el grupo de motores ejerce mayor fuerza de empuje o tracción. Esto puede ocurrir cuando el motor o el grupo de motores levanta un objeto pesado, empuja contra él o intenta moverse cuando está atascado.
Esto puede utilizarse para comprobar si el motor o el grupo de motores tiene dificultades o para comparar la cantidad de impulso que necesitan los diferentes movimientos.
To set the torque of a motor or motor group, use setMaxTorque.
double torque(
torqueUnits units = Nm );
Parámetros
Parámetro |
Tipo |
Descripción |
|---|---|---|
|
|
The unit used to represent the motor torque:
|
Valores de retorno
Returns a double representing how much torque the motor or motor group is using in the specified units.
Notas
When called on a
motor_group, this function returns the mechanical output torque of the first motor in the group.
efficiency#
efficiency returns how efficiently the motor or motor group is using power, as a percentage from 0% to 100%.
La eficiencia indica cuánta potencia del motor o grupo de motores se utiliza para el movimiento. Un valor de eficiencia más alto significa que se utiliza más potencia del motor o grupo de motores para moverse. Un valor de eficiencia más bajo puede ocurrir cuando el motor o grupo de motores trabaja intensamente pero no se mueve mucho, como cuando está atascado o empujando contra un objeto.
Esto puede utilizarse para comparar movimientos o comprobar si el motor o el grupo de motores está desperdiciando energía en lugar de utilizarla para el movimiento.
Available Functionsdouble efficiency(
percentUnits units = percent );
Parámetros
Parámetro |
Tipo |
Descripción |
|---|---|---|
|
|
The unit used to represent motor efficiency:
|
Valores de retorno
Returns a double representing how efficiently the motor or motor group is using power as a percentage.
Notas
When called on a
motor_group, this function returns the efficiency of the first motor in the group.
temperature#
temperature returns the temperature of the motor or motor group.
Motor temperature shows how warm the motor or motor group is. A higher temperature means the motor or motor group is getting warmer while it works. The motor should stay below 55°C to keep working at full performance.
If the motor or motor group gets too hot, it will lower its maximum current to protect itself. At 70°C, a motor will stop running until it cools down.
Esto puede utilizarse para comprobar si el motor o el grupo de motores se calienta demasiado durante movimientos repetitivos, funcionamientos prolongados o cuando ejerce presión contra un objeto.
Available Functions1 — Devuelve la temperatura del motor o grupo de motores como un porcentaje de la temperatura máxima de funcionamiento.
double temperature( percentUnits units = percent );
2 — Devuelve la temperatura del motor o grupo de motores en unidades de temperatura física.
double temperature( temperatureUnits units );
Parámetros
Parámetro |
Tipo |
Descripción |
|---|---|---|
|
|
The unit used to represent motor or motor group temperature as a percentage:
|
|
|
The unit used to represent motor or motor group temperature in degrees:
|
Valores de retorno
Returns a double representing the temperature of the motor or motor group in the specified units.
Notas
The operating temperature range for the motor is approximately
20°C(68°F) to70°C(158°F).When called on a
motor_group, this function returns the temperature of the first motor in the group.
voltage#
voltage returns the electrical voltage supplied to the motor or motor group.
double voltage(
voltageUnits units = volt );
Parámetros
Parámetro |
Tipo |
Descripción |
|---|---|---|
|
|
The unit to represent the voltage:
|
Valores de retorno
Returns a double representing the electrical voltage supplied to the motor or motor group in the specified units.
Notas
When called on a
motor_group, this function returns the electrical voltage of the first motor in the group.
direction#
direction returns the direction that the motor or motor group is spinning.
directionType direction();
Parámetros
Esta función no requiere ningún parámetro.
Valores de retorno
Returns a directionType indicating the motor’s or motor group’s current direction:
forward— The motor or motor group is spinning forward.reverse— The motor or motor group is spinning in reverse.
installed#
installed returns whether the motor or motor group is connected to the IQ (2nd gen) Brain.
bool installed();
Parámetros
Esta función no requiere ningún parámetro.
Valores de retorno
Returns a bool indicating whether the motor or motor group is connected.
true— The motor or motor group is connected.false— The motor or motor group is not connected.
count#
count returns the number of motors in a motor group.
int32_t count();
Parámetros
Esta función no requiere ningún parámetro.
Valores de retorno
Returns an int32_t representing the number of motors in the motor group.