use of com.qualcomm.hardware.lynx.LynxDcMotorController in project robotcode by OutoftheBoxFTC.
the class HardwareFactory method mapLynxModuleComponents.
private void mapLynxModuleComponents(HardwareMap map, DeviceManager deviceMgr, LynxUsbDeviceConfiguration lynxUsbDeviceConfiguration, LynxUsbDevice lynxUsbDevice, Map<Integer, LynxModule> connectedModules) throws LynxNackException, RobotCoreException, InterruptedException {
// Hook up the pieces to each module
for (DeviceConfiguration moduleConfiguration : lynxUsbDeviceConfiguration.getModules()) {
LynxModule module = connectedModules.get(moduleConfiguration.getPort());
// Ignore modules that ultimately didn't connect
if (module == null) {
continue;
}
LynxModuleConfiguration lynxModuleConfiguration = (LynxModuleConfiguration) moduleConfiguration;
// For each module, hook up motor controller and motors
LynxDcMotorController mc = new LynxDcMotorController(context, module);
map.dcMotorController.put(moduleConfiguration.getName(), mc);
for (MotorConfiguration motorConf : lynxModuleConfiguration.getMotors()) {
if (motorConf.isEnabled()) {
DcMotor m = deviceMgr.createDcMotorEx(mc, motorConf.getPort(), motorConf.getMotorType(), motorConf.getName());
map.dcMotor.put(motorConf.getName(), m);
}
}
// And hook up servo controller and servos
LynxServoController sc = new LynxServoController(context, module);
map.servoController.put(moduleConfiguration.getName(), sc);
for (DeviceConfiguration servoConf : lynxModuleConfiguration.getServos()) {
mapServoEx(map, deviceMgr, servoConf, sc);
}
// And a voltage sensor
LynxVoltageSensor voltageSensor = new LynxVoltageSensor(context, module);
map.voltageSensor.put(moduleConfiguration.getName(), voltageSensor);
// Also a PWM Output Controller
LynxPwmOutputController pwmOutputController = new LynxPwmOutputController(context, module);
map.put(moduleConfiguration.getName(), pwmOutputController);
buildLynxDevices(lynxModuleConfiguration.getPwmOutputs(), map, deviceMgr, pwmOutputController);
// Also an AnalogInputController
LynxAnalogInputController analogInputController = new LynxAnalogInputController(context, module);
map.put(moduleConfiguration.getName(), analogInputController);
buildLynxDevices(lynxModuleConfiguration.getAnalogInputs(), map, deviceMgr, analogInputController);
// And a digital channel controller
LynxDigitalChannelController digitalChannelController = new LynxDigitalChannelController(context, module);
map.put(moduleConfiguration.getName(), digitalChannelController);
buildLynxDevices(lynxModuleConfiguration.getDigitalDevices(), map, deviceMgr, digitalChannelController);
// And I2c devices
buildLynxI2cDevices(lynxModuleConfiguration.getI2cDevices(), map, deviceMgr, module);
}
}
Aggregations