本文整理汇总了Java中com.qualcomm.robotcore.hardware.DcMotor.getController方法的典型用法代码示例。如果您正苦于以下问题:Java DcMotor.getController方法的具体用法?Java DcMotor.getController怎么用?Java DcMotor.getController使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.qualcomm.robotcore.hardware.DcMotor
的用法示例。
在下文中一共展示了DcMotor.getController方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findMotor
import com.qualcomm.robotcore.hardware.DcMotor; //导入方法依赖的package包/类
DcMotor findMotor(String motorName)
{
try {
DcMotor motor = hardwareMap.dcMotor.get(motorName);
// Find which device is the USB device
RobotArmingStateNotifier usbDevice = null;
if (motor.getController() instanceof RobotArmingStateNotifier)
{
usbDevice = (RobotArmingStateNotifier) motor.getController();
}
else if (motor.getController() instanceof I2cControllerPortDevice)
{
I2cControllerPortDevice i2cControllerPortDevice = (I2cControllerPortDevice)motor.getController();
if (i2cControllerPortDevice.getI2cController() instanceof RobotArmingStateNotifier)
{
usbDevice = (RobotArmingStateNotifier) i2cControllerPortDevice.getI2cController();
}
}
// Weed out controllers that aren't actually physically there (and so in pretend state)
if (usbDevice != null)
{
if (usbDevice.getArmingState() != RobotArmingStateNotifier.ARMINGSTATE.ARMED)
{
return null;
}
}
return motor;
}
catch (Throwable ignored)
{
}
return null;
}