public class MotorSet
extends java.lang.Object
MotorSet
is a collection of motors that should move in unison. The most common
use for this functionality is in a drive system, because all the motors of a drive system
move together.
It is not required that all of the motors in a motor set move exactly in usison. In some cases, this would be catastrophic. In the case of a drive system, the robot would only be able to spin clockwise or counterclockwise. Instead, a motor set comprises motors that should be controlled together, even if they should be given different individual powers.
Modifier and Type | Field and Description |
---|---|
private Motor[] |
motors
The array of motors that this
MotorSet comprises. |
Constructor and Description |
---|
MotorSet(Motor[] motors)
Constructs a new
MotorSet using the given motor array. |
MotorSet(java.lang.String[] names)
Constructs a new
MotorSet using the motors with the given names. |
Modifier and Type | Method and Description |
---|---|
int |
getAverageEncoderValue()
Gets the average encoder reading for all the motors in this motor set.
|
double |
getAveragePower()
Gets the average power of all the motors in this motor set.
|
Motor[] |
getMotorArray()
Gets the array of motors that this
MotorSet comprises. |
void |
setMotorPower(double power)
Sets the power of all the motors in this set to the given power.
|
void |
setMotorPowers(double[] powers)
Sets the power of the motors in this motor set from the corresponding power values in
the given double array.
|
void |
stopAllMotors()
Stops all the motors in this motor set
|
private Motor[] motors
MotorSet
comprises.public MotorSet(java.lang.String[] names)
MotorSet
using the motors with the given names.names
- the names of all the motors to use in this motor set.public MotorSet(Motor[] motors)
MotorSet
using the given motor array.motors
- an array of motors to use in this motor set.public Motor[] getMotorArray()
MotorSet
comprises.public void setMotorPower(double power)
power
- the power to send to all the motors in this motor set.public void setMotorPowers(double[] powers)
motors[n]
will be assigned
the power value at powers[n]
. If the lengths of motors
and
powers
are mismatched, then all the available pairs will be matched, and the
extra values in either array will be discarded.powers
- the power values to assign to the corresponding motors.public void stopAllMotors()
public double getAveragePower()
public int getAverageEncoderValue()