grupo motor#
Inicializando la clase motor_group#
Un objeto EXP motor_group se crea utilizando el siguiente constructor:
The motor_group
constructor creates a motor_group object.
Puedes crear un motor_group con cualquier número de motores.
// Create 2 Motors, Motor1 and Motor2 in
// Ports 1 and 2 respectively.
Motor1 = motor(PORT1);
Motor1 = motor(PORT2);
// Using the two previously created Motors, create a
// motor_group named MotorGroup1.
motor_group MotorGroup1 = motor_group(Motor1, Motor2);
This MotorGroup1
object will be used in all subsequent examples throughout this API documentation when referring to MotorGroup class methods.
Métodos de clase#
spin()#
Esta es una función sin espera y permite que el siguiente comando se ejecute sin demora.
Este método se llama de las siguientes maneras:
The spin(dir)
command is used to spin the Motors in the specified direction forever at the default velocity set by the setVelocity()
command, until a spin or stop command is used, or the project is stopped.
Parámetros |
Descripción |
---|---|
director |
Un directionType válido. |
Devoluciones: Ninguna.
// Spin MotorGroup1 forward.
MotorGroup1.spin(forward);
The spin(dir, velocity, units)
command is used to spin the Motors in the specified direction forever at a specified velocity, until a spin or stop command is used, or the project is stopped.
Parámetros |
Descripción |
---|---|
director |
Un directionType válido. |
velocidad |
La velocidad a la que girarán los motores. |
unidades |
A valid velocityUnit or |
Devoluciones: Ninguna.
// Spin MotorGroup1 forward at 100 rpm.
MotorGroup1.spin(forward, 100, rpm);
The spin(dir, voltage, units)
command is used to spin the Motors in the specified direction forever at a specified voltage until a spin or stop command is used, or the project is stopped.
Parámetros |
Descripción |
---|---|
director |
Un directionType válido. |
Voltaje |
El voltaje al que girarán los motores. |
unidades |
Una voltageUnit válida. |
Devoluciones: Ninguna.
// Spin MotorGroup1 forward at 100 millivolts.
MotorGroup1.spin(forward, 100, voltageUnits::mV);
spinToPosition()#
This function can be a waiting or non-waiting command depending on if the waitForCompletion
parameter is used.
Este método se llama de las siguientes maneras:
The spinToPosition(rotation, units, waitForCompletion)
command is used to spin the Motors to an absolute rotation in the specified units.
Parámetros |
Descripción |
---|---|
rotación |
La posición para hacer girar los motores. |
unidades |
Una rotationUnit válida. |
esperar a que se complete |
Determines whether the command will block subsequent commands ( |
Devuelve: un valor booleano que indica cuándo los motores han alcanzado la rotación objetivo.
// Spin MotorGroup1 to the absolute position 1080 degrees.
MotorGroup1.spinToPosition(1080, degrees);
The spinToPosition(rotation, units, velocity, units_v, waitForCompletion)
command is used to spin the Motors to an absolute rotation in the specified units.
Parámetros |
Descripción |
---|---|
rotación |
La posición para hacer girar los motores. |
unidades |
Una rotationUnit válida. |
velocidad |
La velocidad con la que girarán los motores. |
unidades_v |
Una velocityUnit válida. |
esperar a que se complete |
Determines whether the command will block subsequent commands ( |
Devuelve: un valor booleano que indica cuándo los motores han alcanzado la rotación objetivo.
// Spin MotorGroup1 to the absolute position 1080 degrees
// at 100 percent velocity.
MotorGroup1.spinToPosition(1080, degrees, 100, velocityUnits::pct);
spinFor()#
This can be a waiting or non-waiting command depending on if the waitForCompletion
parameter is used.
Este método se llama de las siguientes maneras:
The spinFor(time, units)
command is used to spin the Motors for a specified duration.
Parámetros |
Descripción |
---|---|
tiempo |
La cantidad de tiempo durante el cual se deben girar los motores. |
unidades |
Una unidad de tiempo válida. |
Devuelve: un valor booleano que indica cuándo los motores han alcanzado la rotación objetivo.
// Spin MotorGroup1 for 10 seconds
MotorGroup1.spinFor(10, seconds);
The spinFor(dir, time, units)
command is used to spin the Motors for a specified duration in a specified direction.
Parámetros |
Descripción |
---|---|
director |
Un directionType válido. |
tiempo |
La cantidad de tiempo durante el cual se deben girar los motores. |
unidades |
Una unidad de tiempo válida. |
Devuelve: un valor booleano que indica cuándo los motores han alcanzado la rotación objetivo.
// Spin MotorGroup1 forward for 10 seconds
MotorGroup1.spinFor(forward, 10, seconds);
The spinFor(time, units, velocity, units_v)
command is used to spin the Motors for a specified duration at a specified velocity.
Parámetros |
Descripción |
---|---|
tiempo |
La cantidad de tiempo durante el cual se deben girar los motores. |
unidades |
Una unidad de tiempo válida. |
velocidad |
La velocidad con la que girarán los motores. |
unidades_v |
Una velocityUnit válida. |
Devuelve: un valor booleano que indica cuándo los motores han alcanzado la rotación objetivo.
// Spin MotorGroup1 for 10 seconds at 100 rpm.
MotorGroup1.spinFor(10, seconds, 100, rpm);
The spinFor(dir, time, units, velocity, units_v)
command is used to spin the Motors for a specified duration at a specified velocity in a specified direction.
Parámetros |
Descripción |
---|---|
director |
Un directionType válido. |
tiempo |
La cantidad de tiempo durante el cual se deben girar los motores. |
unidades |
Una unidad de tiempo válida. |
velocidad |
La velocidad con la que girarán los motores. |
unidades_v |
Una velocityUnit válida. |
Devuelve: un valor booleano que indica cuándo los motores han alcanzado la rotación objetivo.
// Spin MotorGroup1 forward for 10 seconds at 100 rpm.
MotorGroup1.spinFor(forward, 10, seconds, 100, rpm);
The spinFor(rotation, units, waitForCompletion)
command is used to spin the Motors for a specific rotation. The rotation is relative to the current rotation of the Motor.
Parámetros |
Descripción |
---|---|
rotación |
El valor de rotación para que giren los motores. |
unidades |
Una rotationUnit válida. |
esperar a que se complete |
Determines whether the command will block subsequent commands ( |
Devuelve: un valor booleano que indica cuándo los motores han alcanzado la rotación objetivo.
// Spin MotorGroup1 for 1000 degrees.
MotorGroup1.spinFor(1000, degrees);
The spinFor(dir, rotation, units, waitForCompletion)
command is used to spin the Motors for a specific rotation in a specific direction. The rotation is relative to the current rotation of the Motor.
Parámetros |
Descripción |
---|---|
director |
Un directionType válido. |
rotación |
El valor de rotación para que giren los motores. |
unidades |
Una rotationUnit válida. |
esperar a que se complete |
Determines whether the command will block subsequent commands ( |
Devuelve: un valor booleano que indica cuándo los motores han alcanzado la rotación objetivo.
// Spin MotorGroup1 forward for 1000 degrees.
MotorGroup1.spinFor(forward, 1000, degrees);
The spinFor(rotation, units, velocity, units_v, waitForCompletion)
command is used to spin the Motors for a specific rotation. The rotation is relative to the current rotation of the Motor.
Parámetros |
Descripción |
---|---|
rotación |
El valor de rotación para que giren los motores. |
unidades |
Una rotationUnit válida. |
velocidad |
La velocidad con la que girarán los motores. |
unidades_v |
Una velocityUnit válida. |
esperar a que se complete |
Determines whether the command will block subsequent commands ( |
Devuelve: un valor booleano que indica cuándo los motores han alcanzado la rotación objetivo.
// Spin MotorGroup1 for 1000 degrees at 25 rpm.
MotorGroup1.spinFor(1000, degrees, 25, rpm);
The spinFor(dir, rotation, units, velocity, units_v, waitForCompletion)
command is used to spin the Motors for a specific rotation in a specific direction. The rotation is relative to the current rotation of the Motor.
Parámetros |
Descripción |
---|---|
director |
Un directionType válido. |
rotación |
El valor de rotación para que giren los motores. |
unidades |
Una rotationUnit válida. |
velocidad |
La velocidad con la que girarán los motores. |
unidades_v |
Una velocityUnit válida. |
esperar a que se complete |
Determines whether the command will block subsequent commands ( |
Devuelve: Un valor booleano que indica cuándo el motor ha alcanzado la rotación objetivo.
// Spin MotorGroup1 forard for 1000 degrees at 25 rpm.
MotorGroup1.spinFor(forward, 1000, degrees, 25, rpm);
stop()#
Este es un comando sin espera y permite que el siguiente comando se ejecute sin demora.
Este método se llama de las siguientes maneras:
The stop()
command is used to stop the Motors, setting them to 0 velocity and configuring the current stopping mode. The default Brake Type is coast
, unless previously changed using the setStopping()
command.
Devoluciones: Ninguna.
// Spin MotorGroup1 for 2.5 seconds.
MotorGroup1.spin(forward);
wait(2.5 seconds);
// Stop MotorGroup1.
MotorGroup1.stop();
The stop(mode)
command is used to stop the Motors using a specific Brake Type.
Parámetros |
Descripción |
---|---|
modo |
Un brakeType válido. |
Devoluciones: Ninguna.
// Spin MotorGroup1 for 2.5 seconds.
MotorGroup1.spin(forward);
wait(2.5 seconds);
// Stop MotorGroup1 using the hold Brake Type.
MotorGroup1.stop(hold);
count()#
The count()
command returns the number of Motors in a Motor Group.
Devuelve: El número de motores en el grupo de motores.
setVelocity()#
The setVelocity(velocity, units)
command is used to set the default velocity for the Motors. This velocity setting will be used for subsequent calls to any motion functions if a specific velocity is not provided.
Parámetros |
Descripción |
---|---|
velocidad |
La nueva velocidad a establecer para los motores. |
unidades |
A valid velocityUnit or |
Devoluciones: Ninguna.
setStopping()#
The setStopping(mode)
command is used to set the stopping mode for the Motors. This will be the stopping mode used when the stop()
command is called without specifying a brakeType.
Parámetros |
Descripción |
---|---|
modo |
Un brakeType válido. |
Devoluciones: Ninguna.
resetPosition()#
The resetPosition()
command resets the value of all Motor encoders to 0.
Devoluciones: Ninguna.
setPosition()#
The setPosition(value, units)
command is used to set the value of all Motor encoders to a specified value. The position that is returned by the position()
command will be updated to this new value.
Parámetros |
Descripción |
---|---|
valor |
El nuevo valor a establecer para todos los codificadores del motor. |
unidades |
Una rotationUnit válida. |
Devoluciones: Ninguna.
setTimeout()#
The setTimeout(value, units)
command is used to set the timeout for Motor Group commands. If a Motor does not reach its’ commanded position prior to the completion of the timeout, the Motors will stop.
Parámetros |
Descripción |
---|---|
valor |
El nuevo tiempo de espera a establecer para los motores. |
unidades |
Una unidad de tiempo válida. |
Devoluciones: Ninguna.
isSpinning()#
The isSpinning()
command returns if any Motor is currently rotating to a specific target.
Returns: true
if any Motor is on and is rotating to a target. false
if all Motors are done rotating to a target.
isDone()#
The isDone()
command returns if all Motors are done rotating to a specific target.
Returns: true
if all Motors are done rotating to a target. false
if any Motor is on and rotating to a target.
setMaxTorque()#
Este método se llama de las siguientes maneras:
The setMaxTorque(value, units)
command is used to set the maximum torque for the Motors in torqueUnits.
Parámetros |
Descripción |
---|---|
valor |
El nuevo par máximo para los motores. |
unidades |
Una torqueUnit válida. |
Devoluciones: Ninguna.
// Set maximum torque to 2 Newton Meters.
MotorGroup1.set_max_torque(2, Nm);
The setMaxTorque(value, units)
command is used to set the maximum torque for the Motors in currentUnits.
Parámetros |
Descripción |
---|---|
valor |
El nuevo par máximo para los motores. |
unidades |
The only valid unit is |
Devoluciones: Ninguna.
// Set maximum torque to ,05 amps.
MotorGroup1.set_max_torque(.05, amp);
The setMaxTorque(value, units)
command is used to set the maximum torque for a Motor as a percentage.
Parámetros |
Descripción |
---|---|
valor |
El nuevo par máximo para los motores. |
unidades |
The only valid unit is |
Devoluciones: Ninguna.
// Set maximum torque to 75 percent.
MotorGroup1.set_max_torque(75, percent);
convertVelocity()#
The convertVelocity(velocity, units, unitsout)
command converts the velocity in the given units to the given output units based on the Motor gearing of the first Motor in the Group.
Parámetros |
Descripción |
---|---|
velocidad |
La velocidad a convertir. |
unidades |
Una velocityUnit válida para la velocidad de entrada. |
unidades fuera |
Una velocityUnit válida para la velocidad de salida. |
Devuelve: Un doble que representa la velocidad convertida a las unidades de salida especificadas.
getMotorCartridge()#
The getMotorCartridge()
command returns the gear cartridge setting for the first Motor in the Group.
Devoluciones: La configuración del cartucho de engranaje del motor.
direction()#
The direction()
command returns the current direction the first Motor in the Group is spinning in as a directionType.
Devuelve: Un valor directionType que representa la dirección actual en la que está girando el primer motor del grupo.
position()#
The position(units)
command returns the current rotation of the first Motor in the Group.
Parámetros |
Descripción |
---|---|
unidades |
Una rotationUnit válida. |
Devuelve: Un doble que representa la rotación actual del primer motor del grupo en las unidades especificadas.
velocity()#
The velocity(units)
command returns the current velocity of the first Motor in the Group.
Parámetros |
Descripción |
---|---|
unidades |
A valid velocityUnit or |
Devuelve: Un doble que representa la velocidad actual del primer motor del grupo en las unidades especificadas.
current()#
The current(units)
command returns the current being used by the first Motor in the Group.
Parámetros |
Descripción |
---|---|
unidades |
The only valid units for current are |
Devuelve: Un doble que representa la corriente consumida por el primer motor del grupo en las unidades especificadas.
voltage()#
The voltage(units)
command returns the voltage of the first Motor in the Group.
Parámetros |
Descripción |
---|---|
unidades |
A valid voltageUnit. The default is |
Devuelve: Un doble que representa el voltaje del primer motor del grupo en las unidades especificadas.
power()#
The power(units)
command returns the power being consumed by the first Motor in the Group.
Parámetros |
Descripción |
---|---|
unidades |
The only valid unit for power is |
Devuelve: Un doble que representa la potencia actual del primer motor del grupo en las unidades especificadas.
torque()#
The torque(units)
command returns the torque of the first Motor in the Group.
Parámetros |
Descripción |
---|---|
unidades |
Una torqueUnit válida. |
Devuelve: El torque del primer motor del grupo en las unidades especificadas.
efficiency()#
The efficiency(units)
command returns the efficiency of the first Motor in the Group.
Parámetros |
Descripción |
---|---|
unidades |
The only valid unit for efficiency is |
Devuelve: La eficiencia del primer motor del grupo como porcentaje.
temperature()#
The temperature(units)
command returns the current temperature of the first Motor in the Group.
Parámetros |
Descripción |
---|---|
unidades |
A valid temperatureUnit or |
Devuelve: La temperatura actual del primer motor del grupo en las unidades especificadas.