grupo motor#
Inicializando la clase motor_group#
Un objeto motor_group IQ (1.ª generación) 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.
motor Motor1 = motor(PORT1);
motor 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 método se ejecute sin demora.
Este método se llama de las siguientes maneras:
The spin(dir)
method is used to spin the Motors in the specified direction forever at the default velocity set by the setVelocity()
method, until a spin or stop method 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)
method is used to spin the Motors in the specified direction forever at a specified velocity, until a spin or stop method 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)
method is used to spin the Motors in the specified direction forever at a specified voltage until a spin or stop method 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 volts.
MotorGroup1.spin(forward, 100, volt);
spinToPosition()#
This function can be a waiting or non-waiting method depending on if the wait
parameter is used.
Este método se llama de las siguientes maneras:
The spinToPosition(rotation, units, waitForCompletion)
method 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 method will block subsequent methods ( |
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)
method 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 method will block subsequent methods ( |
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,::pct);
spinFor()#
This can be a waiting or non-waiting method depending on if the wait
parameter is used.
Este método se llama de las siguientes maneras:
The spinFor(time, units)
method 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)
method 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)
method 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)
method 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)
method 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 method will block subsequent methods ( |
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)
method 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 method will block subsequent methods ( |
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)
method 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 method will block subsequent methods ( |
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)
method 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 method will block subsequent methods ( |
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 método sin espera y permite que el siguiente método se ejecute sin demora.
Este método se llama de las siguientes maneras:
The stop()
method 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()
method.
Devoluciones: Ninguna.
// Spin MotorGroup1 for 2.5 seconds.
MotorGroup1.spin(forward);
wait(2.5 seconds);
// Stop MotorGroup1.
MotorGroup1.stop();
The stop(mode)
method 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()
method 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)
method 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)
method is used to set the stopping mode for the Motors. This will be the stopping mode used when the stop()
method is called without specifying a brakeType.
Parámetros |
Descripción |
---|---|
modo |
Un brakeType válido. |
Devoluciones: Ninguna.
resetPosition()#
The resetPosition()
method resets the value of all Motor encoders to 0.
Devoluciones: Ninguna.
setPosition()#
The setPosition(value, units)
method is used to set the value of all Motor encoders to a specified value. The position that is returned by the position()
method 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)
method is used to set the timeout for Motor Group methods. If a Motor does not reach its’ methoded 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()
method 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()
method 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)
method 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)
method 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)
method 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);
direction()#
The direction()
method 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)
method 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)
method 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)
method 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 being used by the first Motor in the Group.
Parámetros |
Descripción |
---|---|
unidades |
The only valid unit for voltage is |
Devuelve: Un doble que representa el voltaje eléctrico del primer motor del grupo.
power()#
The power(units)
method 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)
method 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)
method 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 temperature of the first Motor in the Group.
Parámetros |
Descripción |
---|---|
unidades |
A valid temperatureUnit or |
Devuelve: La temperatura del primer motor del grupo.