motor_group#

To make motor_group commands appear in VEXcode V5, a Motor must be configured in the Devices window.

For more information, refer to these articles:

Initializing the motor_group Class#

An EXP motor_group object is created by using the following constructor:

The motor_group constructor creates a motor_group object.

You can create a motor_group with any number of Motors.

// 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.

MotorGroup.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).

This is a non-waiting function and allows the next command to run without delay.

Parameters

Description

direction

A valid directionType.

velocity

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

units

Optional. A valid velocityUnit. The default is rpm.

Returns: None.

// 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.

Parameters

Description

rotation

The position to spin the motor group to.

units

Optional. A valid rotationUnit. The default is degrees.

velocity

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

units_v

Optional. A valid velocityUnit. The default is rpm.

wait

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.

Returns: None.

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

MotorGroup.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.

Parameters

Description

direction

A valid directionType.

value

The value for the motor group to spin to.

units

Optional. A valid rotationUnit. The default is degrees.

velocity

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

units_v

Optional. A valid velocityUnit. The default is rpm.

wait

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.

Returns: None.

// 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).

This is a non-waiting command and allows the next command to run without delay.

Parameters

Description

mode

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

Returns: None.

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

MotorGroup.count()#

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

This is a non-waiting command and allows the next command to run without delay.

Returns: The number of motors in the group.

MotorGroup.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).

This is a non-waiting command and allows the next command to run without delay.

Parameters

Description

velocity

The new velocity to set for the motor group.

units

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

Returns: None.

MotorGroup.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).

This is a non-waiting command and allows the next command to run without delay.

Parameters

Description

mode

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

Returns: None.

MotorGroup.resetPosition()#

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

This is a non-waiting command and allows the next command to run without delay.

Returns: None.

MotorGroup.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).

This is a non-waiting command and allows the next command to run without delay.

Parameters

Description

value

The new position to set for the motor group.

units

Optional. A valid rotationUnit. The default is degrees.

Returns: None.

MotorGroup.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).

This is a non-waiting command and allows the next command to run without delay.

Parameters

Description

value

The new timeout to set for the motor group.

units

Optional. A valid timeUnit. The default is msec.

Returns: None.

MotorGroup.isSpinning()#

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

This is a non-waiting command and allows the next command to run without delay.

Returns: True if the motor group is currently spinning. False if it is not.

MotorGroup.isDone()#

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

This is a non-waiting command and allows the next command to run without delay.

Returns: True if the motor group has completed its movement. False if it has not.

MotorGroup.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).

This is a non-waiting command and allows the next command to run without delay.

Parameters

Description

value

The new maximum torque for a motor group.

units

A valid torqueUnit, amp, or percent.

Returns: None.

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

MotorGroup.direction()#

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

This is a non-waiting command and allows the next command to run without delay.

Returns: The current directionType the motor group is spinning in.

MotorGroup.position()#

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

This is a non-waiting command and allows the next command to run without delay.

Parameters

Description

units

Optional. A valid rotationUnit. The default is dergees.

Returns: The current position of the motor group in the specified units.

MotorGroup.velocity()#

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

This is a non-waiting command and allows the next command to run without delay.

Parameters

Description

units

Optional. A valid velocityUnit. The default is rpm.

Returns: The current velocity of the motor group in the specified units.

MotorGroup.current()#

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

This is a non-waiting command and allows the next command to run without delay.

Parameters

Description

units

Optional. The only valid unit for current is amp.

Returns: The current being drawn by the motor group in the specified units.

MotorGroup.power()#

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

This is a non-waiting command and allows the next command to run without delay.

Parameters

Description

units

Optional. The only valid unit for power is watt.

Returns: The power being consumed by the motor group in the specified units.

MotorGroup.torque()#

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

This is a non-waiting command and allows the next command to run without delay.

Parameters

Description

units

Optional. A valid torqueUnit. The default is Nm.

Returns: The torque being generated by the motor group in the specified units.

MotorGroup.efficiency()#

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

This is a non-waiting command and allows the next command to run without delay.

Parameters

Description

units

Optional. The only valid unit for efficiency is percent.

Returns: The efficiency of the motor group as a percent.

MotorGroup.temperature()#

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

This is a non-waiting command and allows the next command to run without delay.

Parameters

Description

units

Optional. A valid temperatureUnit. The default is celsius.

Returns: The temperature of the motor group in the specified units.