public class LynxDcMotorController extends LynxController implements DcMotorController, DcMotorControllerEx
| Modifier and Type | Class and Description |
|---|---|
protected class |
LynxDcMotorController.MotorProperties |
LynxController.PretendLynxModuleHardwareDevice.ManufacturerHardwareDeviceHealth.HealthStatusRobotArmingStateNotifier.ARMINGSTATE, RobotArmingStateNotifier.Callback| Modifier and Type | Field and Description |
|---|---|
static int |
apiMotorFirst |
static int |
apiMotorLast |
static double |
apiPowerFirst |
static double |
apiPowerLast |
protected static boolean |
DEBUG |
protected LynxDcMotorController.MotorProperties[] |
motors |
static java.lang.String |
TAG |
context, hardwareDeviceHealth, isEngaged, isHardwareInitialized, isHooked, registeredCallbackstag| Constructor and Description |
|---|
LynxDcMotorController(Context context,
LynxModule module) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
doHook() |
protected void |
doUnhook() |
void |
floatHardware() |
void |
forgetLastKnown() |
protected int |
getDefaultMaxMotorSpeed(int motorZ) |
java.lang.String |
getDeviceName()
Returns a string suitable for display to the user as to the type of device.
|
protected int |
getModuleAddress() |
double |
getMotorCurrent(int motor,
CurrentUnit unit)
Returns the current consumed by the indicated motor.
|
double |
getMotorCurrentAlert(int motor,
CurrentUnit unit)
Returns the current alert for the indicated motor.
|
int |
getMotorCurrentPosition(int motor)
Get the current motor position
|
DcMotor.RunMode |
getMotorMode(int motor)
Get the current motor mode.
|
double |
getMotorPower(int motor)
Get the current motor power
|
boolean |
getMotorPowerFloat(int motor)
Is motor power set to float?
|
int |
getMotorTargetPosition(int motor)
Get the current motor target position
|
MotorConfigurationType |
getMotorType(int motor)
Retrieves the motor type configured for this motor
|
double |
getMotorVelocity(int motor)
Returns the velocity of the indicated motor in ticks per second.
|
double |
getMotorVelocity(int motor,
AngleUnit unit)
Returns the velocity of the indicated motor.
|
DcMotor.ZeroPowerBehavior |
getMotorZeroPowerBehavior(int motor)
Returns the current zero power behavior of the motor.
|
PIDCoefficients |
getPIDCoefficients(int motor,
DcMotor.RunMode mode)
Returns the coefficients used for PID control on the indicated motor when in the indicated mode
|
PIDFCoefficients |
getPIDFCoefficients(int motor,
DcMotor.RunMode mode)
Returns the coefficients used for PIDF control on the indicated motor when in the indicated mode
|
protected java.lang.String |
getTag() |
void |
initializeHardware() |
protected DcMotor.RunMode |
internalGetMotorChannelMode(int motorZ)
like
internalGetPublicMotorMode(int), but ALWAYS returns a value that can be set
with LynxSetMotorChannelModeCommand. |
protected DcMotor.RunMode |
internalGetPublicMotorMode(int motorZ) |
protected boolean |
internalSetPIDFCoefficients(int motorZ,
DcMotor.RunMode mode,
PIDFCoefficients pidfCoefficients) |
boolean |
isBusy(int motor)
Is the motor busy?
|
boolean |
isMotorEnabled(int motor)
Returns whether a particular motor on the controller is energized
|
boolean |
isMotorOverCurrent(int motor)
Returns whether the indicated motor current consumption has exceeded the alert threshold.
|
protected void |
rememberPIDParams(int motorZ,
ExpansionHubMotorControllerParamsState params) |
void |
resetDeviceConfigurationForOpMode(int motor)
Reset the state we hold for the given motor so that it's clean at the start of an opmode
|
void |
setMotorCurrentAlert(int motor,
double current,
CurrentUnit unit)
Sets the current alert for the indicated motor
|
void |
setMotorDisable(int motor)
Individually denergizes a particular motor
|
void |
setMotorEnable(int motor)
Individually energizes a particular motor
|
void |
setMotorMode(int motor,
DcMotor.RunMode mode)
Set the current motor mode.
|
void |
setMotorPower(int motor,
double apiMotorPower)
Set the current motor power
|
protected void |
setMotorPowerFloat(int motor) |
void |
setMotorTargetPosition(int motor,
int position)
Set the motor target position.
|
void |
setMotorTargetPosition(int motor,
int position,
int tolerance)
Sets the target position and tolerance for a 'run to position' operation.
|
void |
setMotorType(int motor,
MotorConfigurationType motorType)
Informs the motor controller of the type of a particular motor.
|
void |
setMotorVelocity(int motor,
double ticksPerSecond)
Sets the target velocity of the indicated motor.
|
void |
setMotorVelocity(int motor,
double angularRate,
AngleUnit unit)
Sets the target velocity of the indicated motor.
|
void |
setMotorZeroPowerBehavior(int motor,
DcMotor.ZeroPowerBehavior zeroPowerBehavior)
Sets the behavior of the motor when zero power is applied.
|
void |
setPIDCoefficients(int motor,
DcMotor.RunMode mode,
PIDCoefficients pidCoefficients)
Sets the coefficients used for PID control on the indicated motor when in the indicated mode
|
void |
setPIDFCoefficients(int motor,
DcMotor.RunMode mode,
PIDFCoefficients pidfCoefficients)
Sets the coefficients used for PIDF control on the indicated motor when in the indicated mode
|
protected void |
updateMotorParams(int motorZ) |
adjustHookingToMatchEngagement, close, disengage, engage, finishConstruction, getArmingState, getConnectionInfo, getHealthStatus, getHealthStatusOverride, getManufacturer, getModule, getSerialNumber, getVersion, hook, isArmed, isEngaged, moduleNowArmedOrPretending, moduleNowDisarmed, onModuleStateChange, registerCallback, resetDeviceConfigurationForOpMode, setHealthStatus, setHealthyIfArmed, unhook, unregisterCallbackhandleException, handleSpecificException, handleSpecificException, handleSpecificException, handleSpecificExceptionclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitclose, getConnectionInfo, getManufacturer, getVersion, resetDeviceConfigurationForOpModepublic static final int apiMotorFirst
public static final int apiMotorLast
public static final double apiPowerFirst
public static final double apiPowerLast
public static final java.lang.String TAG
protected static boolean DEBUG
protected final LynxDcMotorController.MotorProperties[] motors
public LynxDcMotorController(Context context,
LynxModule module)
throws RobotCoreException,
java.lang.InterruptedException
RobotCoreExceptionjava.lang.InterruptedExceptionprotected java.lang.String getTag()
getTag in class LynxControllerpublic void initializeHardware()
throws RobotCoreException,
java.lang.InterruptedException
initializeHardware in class LynxControllerRobotCoreExceptionjava.lang.InterruptedExceptionprotected void doHook()
doHook in class LynxControllerprotected void doUnhook()
doUnhook in class LynxControllerpublic void forgetLastKnown()
forgetLastKnown in class LynxControllerpublic java.lang.String getDeviceName()
HardwareDevicegetDeviceName in interface HardwareDevicegetDeviceName in class LynxControllerpublic void setMotorEnable(int motor)
DcMotorControllerExsetMotorEnable in interface DcMotorControllerExmotor - the port number of the motor on this controllerDcMotorControllerEx.setMotorDisable(int),
DcMotorControllerEx.isMotorEnabled(int)public void setMotorDisable(int motor)
DcMotorControllerExsetMotorDisable in interface DcMotorControllerExmotor - the port number of the motor on this controllerDcMotorControllerEx.setMotorEnable(int),
DcMotorControllerEx.isMotorEnabled(int)public boolean isMotorEnabled(int motor)
DcMotorControllerExisMotorEnabled in interface DcMotorControllerExmotor - the port number of the motor on this controllerDcMotorControllerEx.setMotorEnable(int),
DcMotorControllerEx.setMotorDisable(int)public void resetDeviceConfigurationForOpMode(int motor)
DcMotorControllerresetDeviceConfigurationForOpMode in interface DcMotorControllerpublic MotorConfigurationType getMotorType(int motor)
DcMotorControllergetMotorType in interface DcMotorControllermotor - the motor in questionMotorConfigurationType.getUnspecifiedMotorType()
if no type has been configuredpublic void setMotorType(int motor,
MotorConfigurationType motorType)
DcMotorControllersetMotorType in interface DcMotorControllermotor - port of the motor in questionmotorType - the motor type.protected void rememberPIDParams(int motorZ,
ExpansionHubMotorControllerParamsState params)
protected void updateMotorParams(int motorZ)
protected int getDefaultMaxMotorSpeed(int motorZ)
public void setMotorMode(int motor,
DcMotor.RunMode mode)
DcMotorControllerDcMotor.RunModesetMotorMode in interface DcMotorControllermotor - port of motormode - run modepublic DcMotor.RunMode getMotorMode(int motor)
DcMotorControllergetMotorMode in interface DcMotorControllermotor - port of motorprotected DcMotor.RunMode internalGetPublicMotorMode(int motorZ)
internalGetMotorChannelMode(int)protected DcMotor.RunMode internalGetMotorChannelMode(int motorZ)
internalGetPublicMotorMode(int), but ALWAYS returns a value that can be set
with LynxSetMotorChannelModeCommand. We also don't here update lastKnownMode.internalGetPublicMotorMode(int)public void setMotorPower(int motor,
double apiMotorPower)
DcMotorControllersetMotorPower in interface DcMotorControllermotor - port of motorapiMotorPower - from -1.0 to 1.0public double getMotorPower(int motor)
DcMotorControllergetMotorPower in interface DcMotorControllermotor - port of motorpublic boolean isBusy(int motor)
DcMotorControllerisBusy in interface DcMotorControllermotor - port of motorpublic void setMotorZeroPowerBehavior(int motor,
DcMotor.ZeroPowerBehavior zeroPowerBehavior)
DcMotorControllersetMotorZeroPowerBehavior in interface DcMotorControllerzeroPowerBehavior - the behavior of the motor when zero power is applied.public DcMotor.ZeroPowerBehavior getMotorZeroPowerBehavior(int motor)
DcMotorControllergetMotorZeroPowerBehavior in interface DcMotorControllerprotected void setMotorPowerFloat(int motor)
public boolean getMotorPowerFloat(int motor)
DcMotorControllergetMotorPowerFloat in interface DcMotorControllermotor - port of motorpublic void setMotorTargetPosition(int motor,
int position)
DcMotorControllersetMotorTargetPosition in interface DcMotorControllermotor - port of motorposition - range from Integer.MIN_VALUE to Integer.MAX_VALUEpublic void setMotorTargetPosition(int motor,
int position,
int tolerance)
DcMotorControllerExsetMotorTargetPosition in interface DcMotorControllerExmotor - the motor number to be affectedposition - the desired target position, in encoder tickstolerance - the tolerance of the desired target position, in encoder tickspublic int getMotorTargetPosition(int motor)
DcMotorControllergetMotorTargetPosition in interface DcMotorControllermotor - port of motorpublic int getMotorCurrentPosition(int motor)
DcMotorControllergetMotorCurrentPosition in interface DcMotorControllermotor - port of motorpublic void setMotorVelocity(int motor,
double ticksPerSecond)
DcMotorControllerExsetMotorVelocity in interface DcMotorControllerExmotor - the port number of the motor on this controllerticksPerSecond - the new target rate for that motor, in ticks per secondpublic void setMotorVelocity(int motor,
double angularRate,
AngleUnit unit)
DcMotorControllerExsetMotorVelocity in interface DcMotorControllerExmotor - motor whose velocity is to be adjustedangularRate - the new target rate for that motor, in 'unit's per secondunit - the unit inw which angularRate is expressed.DcMotorEx.setVelocity(double, AngleUnit)public double getMotorVelocity(int motor)
DcMotorControllerExgetMotorVelocity in interface DcMotorControllerExmotor - the motor whose velocity is desiredpublic double getMotorVelocity(int motor,
AngleUnit unit)
DcMotorControllerExgetMotorVelocity in interface DcMotorControllerExmotor - the motor whose velocity is desiredunit - the angular unit in which the velocity is to be expressedDcMotorEx.getVelocity(AngleUnit)public void setPIDCoefficients(int motor,
DcMotor.RunMode mode,
PIDCoefficients pidCoefficients)
DcMotorControllerExsetPIDCoefficients in interface DcMotorControllerExmotor - the motor whose PID coefficients are to be setmode - the mode on that motor whose coefficients are to be setpidCoefficients - the new coefficients to setDcMotorEx.setPIDCoefficients(DcMotor.RunMode, PIDCoefficients),
DcMotorControllerEx.getPIDCoefficients(int, DcMotor.RunMode)public void setPIDFCoefficients(int motor,
DcMotor.RunMode mode,
PIDFCoefficients pidfCoefficients)
DcMotorControllerExsetPIDFCoefficients in interface DcMotorControllerExmotor - the motor whose PIDF coefficients are to be setmode - the mode on that motor whose coefficients are to be setpidfCoefficients - the new coefficients to setDcMotorEx.setPIDFCoefficients(DcMotor.RunMode, PIDFCoefficients),
DcMotorControllerEx.getPIDFCoefficients(int, DcMotor.RunMode)protected boolean internalSetPIDFCoefficients(int motorZ,
DcMotor.RunMode mode,
PIDFCoefficients pidfCoefficients)
public PIDCoefficients getPIDCoefficients(int motor, DcMotor.RunMode mode)
DcMotorControllerExgetPIDCoefficients in interface DcMotorControllerExmotor - the motor whose PID coefficients are desiredmode - the mode on that motor whose coefficients are to be queriedDcMotorEx.getPIDCoefficients(DcMotor.RunMode),
DcMotorControllerEx.setPIDCoefficients(int, DcMotor.RunMode, PIDCoefficients)public PIDFCoefficients getPIDFCoefficients(int motor, DcMotor.RunMode mode)
DcMotorControllerExgetPIDFCoefficients in interface DcMotorControllerExmotor - the motor whose PIDF coefficients are desiredmode - the mode on that motor whose coefficients are to be queriedDcMotorEx.getPIDCoefficients(DcMotor.RunMode),
DcMotorControllerEx.setPIDFCoefficients(int, DcMotor.RunMode, PIDFCoefficients)public double getMotorCurrent(int motor,
CurrentUnit unit)
DcMotorControllerExgetMotorCurrent in interface DcMotorControllerExmotor - motor whose current consumption is desiredunit - current unitsDcMotorEx.getCurrent(CurrentUnit)public double getMotorCurrentAlert(int motor,
CurrentUnit unit)
DcMotorControllerExgetMotorCurrentAlert in interface DcMotorControllerExmotor - motor whose alert is desiredunit - current unitsDcMotorControllerEx.setMotorCurrentAlert(int, double, CurrentUnit),
DcMotorEx.setCurrentAlert(double, CurrentUnit),
DcMotorControllerEx.isMotorOverCurrent(int)public void setMotorCurrentAlert(int motor,
double current,
CurrentUnit unit)
DcMotorControllerExsetMotorCurrentAlert in interface DcMotorControllerExmotor - motor whose alert is to be setcurrent - current alertunit - current unitsDcMotorControllerEx.getMotorCurrentAlert(int, CurrentUnit),
DcMotorEx.getCurrentAlert(CurrentUnit),
DcMotorControllerEx.isMotorOverCurrent(int)public boolean isMotorOverCurrent(int motor)
DcMotorControllerExisMotorOverCurrent in interface DcMotorControllerExmotor - desired motorDcMotorEx.isOverCurrent(),
DcMotorControllerEx.getMotorCurrentAlert(int, CurrentUnit),
DcMotorControllerEx.setMotorCurrentAlert(int, double, CurrentUnit)public void floatHardware()
floatHardware in class LynxControllerprotected int getModuleAddress()