Grupo Motor#
Inicializando la clase MotorGroup#
Un objeto EXP MotorGroup se crea utilizando el siguiente constructor:
MotorGroup(motor1, motor2, …)
Puedes crear un MotorGroup con cualquier número de motores.
# Create 2 Motors, motor_1 and motor_2 in
# Ports 1 and 2 respectively.
motor_1 = Motor(Ports.PORT1)
motor_2 = Motor(Ports.PORT2)
# Using the two previously created Motors, create a
# MotorGroup named motor_group_1.
motor_group_1 = MotorGroup(motor_1, motor_2)
This motor_group_1 object will be used in all subsequent examples throughout this API documentation when referring to MotorGroup class methods.
Métodos de clase#
spin()#
The spin(direction, velocity, units) method is used to spin all Motors in a MotorGroup in the specified direction until a spin or stop command is used, or the project is stopped.
Esta es una función sin espera y permite que el siguiente comando se ejecute sin demora.
Parámetros |
Descripción |
|---|---|
|
A valid |
|
Optional. The velocity at which the Motors in the MotorGroup will spin. The default velocity set by the |
|
Optional. A valid |
Devoluciones: Ninguna.
# Spin all Motors in motor_group_1 forward.
motor_group_1.spin(FORWARD)
spin_to_position()#
The spin_to_position(rotation, units, velocity, units_v, wait) method is used to spin all Motors in a MotorGroup to an absolute position using the provided arguments.
This function can be a waiting or non-waiting command depending on if the wait parameter is set to True.
Parámetros |
Descripción |
|---|---|
|
La posición para hacer girar los motores en un MotorGroup. |
|
Optional. A valid |
|
Optional. The velocity with which the Motors in a MotorGroup will spin. The default velocity set by the |
|
Optional. A valid |
|
Optional. Determines whether the command will block subsequent commands ( |
Devoluciones: Ninguna.
# Spin the Motors in motor_group_1 to the position 90
# degrees at 100 RPM.
motor_group_1.spin_to_position(90, DEGREES, 100, RPM)
spin_for()#
The spin_for(direction, value, units, velocity, units_v, wait) method is used to spin all Motors in a MotorGroup for a specific duration, rotations, or until a specific encoder value is reached. The position is relative to the current position of the Motors in the MotorGroup.
This can be a waiting or non-waiting command depending on if the wait parameter is used.
Parámetros |
Descripción |
|---|---|
|
A valid |
|
El valor de los motores en un MotorGroup para girar. |
|
Optional. A valid |
|
Optional. The velocity with which the Motors in a MotorGroup will spin. The default velocity set by the |
|
Optional. A valid |
|
Optional. Determines whether the command will block subsequent commands ( |
Devoluciones: Ninguna.
# Spin the Motors in motor_group_1 forward for 10 turns
# at 100% velocity.
motor_group_1.spin_for(FORWARD, 10, TURNS, 100, PERCENT)
stop()#
The stop(mode) method is used to stop all Motors in a MotorGroup, setting them to 0 velocity and configuring the current stopping mode.
Parámetros |
Descripción |
|---|---|
|
Optional. A valid |
Devoluciones: Ninguna.
# Spin all Motors in motor_group_1 forward for 2.5 seconds.
motor_group_1.spin(FORWARD)
wait(2.5, SECONDS)
# Stop all Motos in motor_group_1 using the HOLD brake type.
motor_group_1.stop(HOLD)
count()#
The count() method returns the number of Motors in the MotorGroup.
Devuelve: La cantidad de motores en el MotorGroup.
set_velocity()#
The set_velocity(velocity, units) method is used to set the default velocity for all Motors in a MotorGroup. This velocity setting will be used for subsequent calls to any motion functions if a specific velocity is not provided.
Parámetros |
Descripción |
|---|---|
|
La nueva velocidad que se debe establecer para los motores de un grupo de motores. |
|
A valid |
Devoluciones: Ninguna.
# Spin the Motors in motor_group_1 forward at 75% velocity.
motor_group_1.set_velocity(75, PERCENT)
motor_group_1.spin(FORWARD)
set_stopping()#
The set_stopping(mode) method is used to set the stopping mode for all Motors in a MotorGroup.
Parámetros |
Descripción |
|---|---|
|
A valid |
Devoluciones: Ninguna.
reset_position()#
The reset_position() method resets the position of all Motors in a MotorGroup to 0. The position that is returned by the position() method will be updated to 0.
Devoluciones: Ninguna.
set_position()#
The set_position(value, units) method is used to set the position of all Motors in a MotorGroup. The position that is returned by the position() method will be updated to this new value.
Parámetros |
Descripción |
|---|---|
|
La nueva posición que se debe establecer para todos los motores de un grupo de motores. |
|
A valid |
Devoluciones: Ninguna.
set_timeout()#
The set_timeout(value, units) method is used to set the timeout for all Motors in a MotorGroup. The position that is returned by the get_timeout() method will be updated to this new value.
Parámetros |
Descripción |
|---|---|
|
El nuevo tiempo de espera que se debe establecer para todos los motores en un MotorGroup. |
|
Optional. A valid |
Devoluciones: Ninguna.
is_spinning()#
The is_spinning() method returns the current status of the spin_to_position() or spin_for() methods. This function is used when False has been passed as the wait parameter in either command.
Returns: True if any Motor in the MotorGroup is still spinning. False if the Motors in the MotorGroup have completed the move or a timeout has occurred.
is_done()#
The is_done() method returns the current status of the spin_to_position() or spin_for() method. This function is used when False has been passed as the wait parameter in either command.
Returns: True if any Motor in the MotorGroup is still spinning. False if the Motors in the MotorGroup have completed the move or a timeout has occurred.
set_max_torque()#
The set_max_torque(value, units) method is used to set the maximum torque for all Motors in a MotorGroup. The torque can be set as torque units, current units, or a percent of maximum torque.
Parámetros |
Descripción |
|---|---|
|
El nuevo par máximo para todos los motores de un grupo de motores. |
|
A valid |
Devoluciones: Ninguna.
direction()#
The direction() method returns the current direction the first Motor in a MotorGroup is spinning.
Returns: The current DirectionType the first Motor in a MotorGroup is spinning.
position()#
The position(units) method returns the current position of the first Motor in a MotorGroup.
Parámetros |
Descripción |
|---|---|
|
Optional. A valid |
Devuelve: La posición actual del primer motor en un grupo de motores en las unidades especificadas.
velocity()#
The velocity(units) method returns the current velocity of the first Motor in a MotorGroup.
Parámetros |
Descripción |
|---|---|
|
Optional. A valid |
Devuelve: La velocidad actual del primer motor en un grupo de motores en las unidades especificadas.
current()#
The current(units) method returns the total current being used by the Motors in a MotorGroup.
Parámetros |
Descripción |
|---|---|
|
Optional. The only valid units for current are |
Devuelve: La corriente total consumida por los motores de un grupo de motores en las unidades especificadas.
power()#
The power(units) method returns the power the first Motor in a MotorGroup is providing.
Parámetros |
Descripción |
|---|---|
|
Optional. The only valid units for power are |
Devuelve: La potencia que proporciona el primer motor de un grupo de motores en las unidades especificadas.
torque()#
The torque(units) method returns the torque the first Motor in a MotorGroup is providing.
Parámetros |
Descripción |
|---|---|
|
Optional. A valid |
Devuelve: El torque que proporciona el primer motor de un grupo de motores en las unidades especificadas.
efficiency()#
The efficiency(units) method returns the efficiency of the first Motor in a MotorGroup.
Parámetros |
Descripción |
|---|---|
|
Optional. The only valid unit for efficiency is |
Devuelve: La eficiencia del primer motor de un grupo de motores como porcentaje.
temperature()#
The temperature(units) method returns the temperature of the first Motor in a MotorGroup.
Parámetros |
Descripción |
|---|---|
|
Optional. A valid |
Devuelve: La temperatura del primer motor de un grupo de motores en las unidades especificadas.