grupo motor#

Para que los comandos motor_group aparezcan en VEXcode V5, se debe configurar un motor en la ventana Dispositivos.

Para obtener más información, consulte estos artículos:

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.

GrupoMotor.spin()#

The MotorGroup.spin(direction, velocity, units) command is used to spin a motor group in the specified direction forever, until another motion command is used, or the project is stopped.

To use this command, replace MotorGroup with the desired motor group, for example: ArmMotorGroup.spin(direction, velocity, units).

Esta es una función sin espera y permite que el siguiente comando se ejecute sin demora.

Parámetros

Descripción

dirección

Un directionType válido.

velocidad

Optional. The velocity at which the motor group will spin. If unspecified, the default velocity set by the MotorGroup.setVelocity() command will be used.

unidades

Optional. A valid velocityUnit. The default is rpm.

Devoluciones: Ninguna.

// Spin motor group forward.
MotorGroup1.spin(forward);

MotorGroup.spinToPosition()#

The MotorGroup.spinToPosition(rotation, units, velocity, units_v, wait) command is used to spin a motor group to an absolute position using the provided arguments.

To use this command, replace MotorGroup with the desired motor group, for example: ArmMotorGroup.spinToPosition(rotation, units, velocity, units_v, wait).

This function can be a waiting or non-waiting command depending on if the wait parameter is used.

Parámetros

Descripción

rotación

La posición para girar el grupo motor.

unidades

Optional. A valid rotationUnit. The default is degrees.

velocidad

Optional. The velocity at which the motor group will spin. If unspecified, the default velocity set by the MotorGroup.setVelocity() command will be used.

unidades_v

Optional. A valid velocityUnit. The default is rpm.

esperar

Optional. Determines whether the command will block subsequent commands (wait=true) or allow immediate execution (wait=false). If unspecified, the default for the wait parameter is wait=true.

Devoluciones: Ninguna.

// Spin motor group to 180 degrees.
MotorGroup1.spinToPosition(180);

GrupoMotor.spinFor()#

The MotorGroup.spinFor(direction, value, units, velocity, units_v, wait) command is used to spin the motor group for a specific duration, rotations, or until a specific encoder value is reached. The position is relative to the current position of the motor group.

To use this command, replace MotorGroup with the desired motor group, for example: ArmMotorGroup.spinFor(direction, value, units, velocity, units_v, wait).

This can be a waiting or non-waiting command depending on if the wait parameter is used.

Parámetros

Descripción

dirección

Un directionType válido.

valor

El valor al que debe girar el grupo motor.

unidades

Optional. A valid rotationUnit. The default is degrees.

velocidad

Optional. The velocity at which the motor group will spin. If unspecified, the default velocity set by the MotorGroup.setVelocity() command will be used.

unidades_v

Optional. A valid velocityUnit. The default is rpm.

esperar

Optional. Determines whether the command will block subsequent commands (wait=true) or allow immediate execution (wait=false). If unspecified, the default for the wait parameter is wait=true.

Devoluciones: Ninguna.

// Spin 180 degrees from the current position.
MotorGroup1.spinFor(forward, 180);

MotorGroup.stop()#

The MotorGroup.stop(mode) command is used to stop a motor group, setting them to 0 velocity and configuring the current stopping mode.

To use this command, replace MotorGroup with the desired motor group, for example: ArmMotorGroup.stop(mode).

Este es un comando sin espera y permite que el siguiente comando se ejecute sin demora.

Parámetros

Descripción

modo

A valid brakeType. The default is coast, unless previously changed using the MotorGroup.setStopping() command.

Devoluciones: Ninguna.

// Stop the motor group.
MotorGroup1.stop()

Grupo de motores.count()#

The MotorGroup.count() command returns the number of motors in the group.

Este es un comando sin espera y permite que el siguiente comando se ejecute sin demora.

Devuelve: El número de motores en el grupo.

GrupoMotor.setVelocity()#

The MotorGroup.setVelocity(velocity, units) command is used to set the default velocity for a motor group. This velocity setting will be used for subsequent calls to any motion functions if a specific velocity is not provided.

To use this command, replace MotorGroup with the desired motor group, for example: ArmMotorGroup.setVelocity(velocity, units).

Este es un comando sin espera y permite que el siguiente comando se ejecute sin demora.

Parámetros

Descripción

velocidad

La nueva velocidad a establecer para el grupo motor.

unidades

Optional. A valid velocityUnit. The default is rpm, unless previously changed using the MotorGroup.setVelocity() command.

Devoluciones: Ninguna.

GrupoMotor.setStopping()#

The MotorGroup.setStopping(mode) command is used to set the stopping mode for a motor group.

To use this command, replace MotorGroup with the desired motor group, for example: ArmMotorGroup.setStopping(mode).

Este es un comando sin espera y permite que el siguiente comando se ejecute sin demora.

Parámetros

Descripción

modo

A valid brakeType. The default is coast, unless previously changed using the MotorGroup.setStopping() command.

Devoluciones: Ninguna.

MotorGroup.resetPosition()#

The MotorGroup.resetPosition() command resets the motor group position to 0.

Este es un comando sin espera y permite que el siguiente comando se ejecute sin demora.

Devoluciones: Ninguna.

GrupoMotor.setPosition()#

The MotorGroup.setPosition(value, units) command is used to set the position of a motor group. The position that is returned by the MotorGroup.position() function will be updated to this new value.

To use this command, replace MotorGroup with the desired motor group, for example: ArmMotorGroup.setPosition(value, units).

Este es un comando sin espera y permite que el siguiente comando se ejecute sin demora.

Parámetros

Descripción

valor

La nueva posición a fijar para el grupo motor.

unidades

Optional. A valid rotationUnit. The default is degrees.

Devoluciones: Ninguna.

Grupo de motores.setTimeout()#

The MotorGroup.setTimeout(value, units) command is used to set the timeout for a motor group.

To use this command, replace MotorGroup with the desired motor group, for example: ArmMotorGroup.setTimeout(value, units).

Este es un comando sin espera y permite que el siguiente comando se ejecute sin demora.

Parámetros

Descripción

valor

El nuevo tiempo de espera que se debe establecer para el grupo de motores.

unidades

Optional. A valid timeUnit. The default is msec.

Devoluciones: Ninguna.

MotorGroup.isSpinning()#

The MotorGroup.isSpinning() command returns if the motor group is currently spinning.

Este es un comando sin espera y permite que el siguiente comando se ejecute sin demora.

Devuelve: Verdadero si el grupo de motores está girando. Falso si no lo está.

MotorGroup.isDone()#

The MotorGroup.isDone() command returns if the motor group has completed its movement.

Este es un comando sin espera y permite que el siguiente comando se ejecute sin demora.

Devuelve: Verdadero si el grupo motor ha completado su movimiento. Falso si no lo ha hecho.

GrupoMotor.setMaxTorque()#

The MotorGroup.setMaxTorque(value, units) command is used to set the maximum torque for a motor group. The torque can be set as torque, current, or a percent of maximum torque.

To use this command, replace MotorGroup with the desired motor group, for example: ArmMotorGroup.setMaxTorque(value, units).

Este es un comando sin espera y permite que el siguiente comando se ejecute sin demora.

Parámetros

Descripción

valor

El nuevo par máximo para un grupo de motores.

unidades

A valid torqueUnit, amp, or percent.

Devoluciones: Ninguna.

// Set maximum torque to 2 Newton Meters.
MotorGroup1.setMaxTorque(2, Nm);

MotorGroup.direccion()#

The MotorGroup.direction() command returns the current direction the motor group is spinning in.

Este es un comando sin espera y permite que el siguiente comando se ejecute sin demora.

Devuelve: El directionType actual en el que está girando el grupo de motores.

MotorGroup.posición()#

The MotorGroup.position(units) command returns the current position of the motor group.

Este es un comando sin espera y permite que el siguiente comando se ejecute sin demora.

Parámetros

Descripción

unidades

Optional. A valid rotationUnit. The default is dergees.

Devuelve: La posición actual del grupo de motores en las unidades especificadas.

MotorGroup.velocidad()#

The MotorGroup.velocity(units) command returns the current velocity of the motor group.

Este es un comando sin espera y permite que el siguiente comando se ejecute sin demora.

Parámetros

Descripción

unidades

Optional. A valid velocityUnit. The default is rpm.

Devuelve: La velocidad actual del grupo de motores en las unidades especificadas.

GrupoMotor.current()#

The MotorGroup.current(units) command returns the current being used by the motor group.

Este es un comando sin espera y permite que el siguiente comando se ejecute sin demora.

Parámetros

Descripción

unidades

Optional. The only valid unit for current is amp.

Devuelve: La corriente consumida por el grupo de motores en las unidades especificadas.

GrupoMotor.potencia()#

The MotorGroup.power(units) command returns the power being consumed by the motor group.

Este es un comando sin espera y permite que el siguiente comando se ejecute sin demora.

Parámetros

Descripción

unidades

Optional. The only valid unit for power is watt.

Devuelve: La potencia consumida por el grupo de motores en las unidades especificadas.

GrupoMotor.torque()#

The MotorGroup.torque(units) command returns the torque being generated by the motor group.

Este es un comando sin espera y permite que el siguiente comando se ejecute sin demora.

Parámetros

Descripción

unidades

Optional. A valid torqueUnit. The default is Nm.

Devuelve: El torque generado por el grupo de motores en las unidades especificadas.

MotorGroup.eficiencia()#

The MotorGroup.efficiency(units) command returns the efficiency of the motor group.

Este es un comando sin espera y permite que el siguiente comando se ejecute sin demora.

Parámetros

Descripción

unidades

Optional. The only valid unit for efficiency is percent.

Devuelve: La eficiencia del grupo motor como porcentaje.

MotorGroup.temperatura()#

The MotorGroup.temperature(units) command returns the temperature of the motor group.

Este es un comando sin espera y permite que el siguiente comando se ejecute sin demora.

Parámetros

Descripción

unidades

Optional. A valid temperatureUnit. The default is celsius.

Devuelve: La temperatura del grupo de motores en las unidades especificadas.