public class LynxDcMotorController extends LynxController implements DcMotorController, DcMotorControllerEx
Modifier and Type | Class and Description |
---|---|
protected class |
LynxDcMotorController.MotorProperties |
LynxController.PretendLynxModule
HardwareDevice.Manufacturer
HardwareDeviceHealth.HealthStatus
RobotArmingStateNotifier.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, registeredCallbacks
tag
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, unregisterCallback
handleException, handleSpecificException, handleSpecificException, handleSpecificException, handleSpecificException
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
close, getConnectionInfo, getManufacturer, getVersion, resetDeviceConfigurationForOpMode
public 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
RobotCoreException
java.lang.InterruptedException
protected java.lang.String getTag()
getTag
in class LynxController
public void initializeHardware() throws RobotCoreException, java.lang.InterruptedException
initializeHardware
in class LynxController
RobotCoreException
java.lang.InterruptedException
protected void doHook()
doHook
in class LynxController
protected void doUnhook()
doUnhook
in class LynxController
public void forgetLastKnown()
forgetLastKnown
in class LynxController
public java.lang.String getDeviceName()
HardwareDevice
getDeviceName
in interface HardwareDevice
getDeviceName
in class LynxController
public void setMotorEnable(int motor)
DcMotorControllerEx
setMotorEnable
in interface DcMotorControllerEx
motor
- the port number of the motor on this controllerDcMotorControllerEx.setMotorDisable(int)
,
DcMotorControllerEx.isMotorEnabled(int)
public void setMotorDisable(int motor)
DcMotorControllerEx
setMotorDisable
in interface DcMotorControllerEx
motor
- the port number of the motor on this controllerDcMotorControllerEx.setMotorEnable(int)
,
DcMotorControllerEx.isMotorEnabled(int)
public boolean isMotorEnabled(int motor)
DcMotorControllerEx
isMotorEnabled
in interface DcMotorControllerEx
motor
- the port number of the motor on this controllerDcMotorControllerEx.setMotorEnable(int)
,
DcMotorControllerEx.setMotorDisable(int)
public void resetDeviceConfigurationForOpMode(int motor)
DcMotorController
resetDeviceConfigurationForOpMode
in interface DcMotorController
public MotorConfigurationType getMotorType(int motor)
DcMotorController
getMotorType
in interface DcMotorController
motor
- the motor in questionMotorConfigurationType.getUnspecifiedMotorType()
if no type has been configuredpublic void setMotorType(int motor, MotorConfigurationType motorType)
DcMotorController
setMotorType
in interface DcMotorController
motor
- 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)
DcMotorController
DcMotor.RunMode
setMotorMode
in interface DcMotorController
motor
- port of motormode
- run modepublic DcMotor.RunMode getMotorMode(int motor)
DcMotorController
getMotorMode
in interface DcMotorController
motor
- 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)
DcMotorController
setMotorPower
in interface DcMotorController
motor
- port of motorapiMotorPower
- from -1.0 to 1.0public double getMotorPower(int motor)
DcMotorController
getMotorPower
in interface DcMotorController
motor
- port of motorpublic boolean isBusy(int motor)
DcMotorController
isBusy
in interface DcMotorController
motor
- port of motorpublic void setMotorZeroPowerBehavior(int motor, DcMotor.ZeroPowerBehavior zeroPowerBehavior)
DcMotorController
setMotorZeroPowerBehavior
in interface DcMotorController
zeroPowerBehavior
- the behavior of the motor when zero power is applied.public DcMotor.ZeroPowerBehavior getMotorZeroPowerBehavior(int motor)
DcMotorController
getMotorZeroPowerBehavior
in interface DcMotorController
protected void setMotorPowerFloat(int motor)
public boolean getMotorPowerFloat(int motor)
DcMotorController
getMotorPowerFloat
in interface DcMotorController
motor
- port of motorpublic void setMotorTargetPosition(int motor, int position)
DcMotorController
setMotorTargetPosition
in interface DcMotorController
motor
- port of motorposition
- range from Integer.MIN_VALUE to Integer.MAX_VALUEpublic void setMotorTargetPosition(int motor, int position, int tolerance)
DcMotorControllerEx
setMotorTargetPosition
in interface DcMotorControllerEx
motor
- 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)
DcMotorController
getMotorTargetPosition
in interface DcMotorController
motor
- port of motorpublic int getMotorCurrentPosition(int motor)
DcMotorController
getMotorCurrentPosition
in interface DcMotorController
motor
- port of motorpublic void setMotorVelocity(int motor, double ticksPerSecond)
DcMotorControllerEx
setMotorVelocity
in interface DcMotorControllerEx
motor
- 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)
DcMotorControllerEx
setMotorVelocity
in interface DcMotorControllerEx
motor
- 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)
DcMotorControllerEx
getMotorVelocity
in interface DcMotorControllerEx
motor
- the motor whose velocity is desiredpublic double getMotorVelocity(int motor, AngleUnit unit)
DcMotorControllerEx
getMotorVelocity
in interface DcMotorControllerEx
motor
- 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)
DcMotorControllerEx
setPIDCoefficients
in interface DcMotorControllerEx
motor
- 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)
DcMotorControllerEx
setPIDFCoefficients
in interface DcMotorControllerEx
motor
- 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)
DcMotorControllerEx
getPIDCoefficients
in interface DcMotorControllerEx
motor
- 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)
DcMotorControllerEx
getPIDFCoefficients
in interface DcMotorControllerEx
motor
- 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)
DcMotorControllerEx
getMotorCurrent
in interface DcMotorControllerEx
motor
- motor whose current consumption is desiredunit
- current unitsDcMotorEx.getCurrent(CurrentUnit)
public double getMotorCurrentAlert(int motor, CurrentUnit unit)
DcMotorControllerEx
getMotorCurrentAlert
in interface DcMotorControllerEx
motor
- 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)
DcMotorControllerEx
setMotorCurrentAlert
in interface DcMotorControllerEx
motor
- 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)
DcMotorControllerEx
isMotorOverCurrent
in interface DcMotorControllerEx
motor
- desired motorDcMotorEx.isOverCurrent()
,
DcMotorControllerEx.getMotorCurrentAlert(int, CurrentUnit)
,
DcMotorControllerEx.setMotorCurrentAlert(int, double, CurrentUnit)
public void floatHardware()
floatHardware
in class LynxController
protected int getModuleAddress()