当前位置: 首页>>代码示例>>Java>>正文


Java HardwareMap类代码示例

本文整理汇总了Java中com.qualcomm.robotcore.hardware.HardwareMap的典型用法代码示例。如果您正苦于以下问题:Java HardwareMap类的具体用法?Java HardwareMap怎么用?Java HardwareMap使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


HardwareMap类属于com.qualcomm.robotcore.hardware包,在下文中一共展示了HardwareMap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: init

import com.qualcomm.robotcore.hardware.HardwareMap; //导入依赖的package包/类
public void init(HardwareMap ahwMap) {
    // save reference to HW Map
    hwMap = ahwMap;

    // Define and Initialize Motors
    leftMotor   = hwMap.dcMotor.get("left_drive");
    rightMotor  = hwMap.dcMotor.get("right_drive");
    leftMotor.setDirection(DcMotor.Direction.REVERSE);

    // Set all motors to zero power
    leftMotor.setPower(0);
    rightMotor.setPower(0);

    // Set all motors to run without encoders.
    // May want to use RUN_USING_ENCODERS if encoders are installed.
    leftMotor.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
    rightMotor.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);

    // Define and initialize ALL installed servos.
    arm = hwMap.servo.get("arm");
    claw = hwMap.servo.get("claw");
    arm.setPosition(ARM_HOME);
    claw.setPosition(CLAW_HOME);
}
 
开发者ID:ykarim,项目名称:FTC2016,代码行数:25,代码来源:HardwareK9bot.java

示例2: initTeleOp

import com.qualcomm.robotcore.hardware.HardwareMap; //导入依赖的package包/类
/**
     * Initializes all drive and ball motors in NO ENCODERS mode
     * @param hwMap
     */
    public void initTeleOp(HardwareMap hwMap) {
        this.hwMap = hwMap;
        initDrive();
        initBall();
//        initCap();
//        initServos();

        for(DcMotor driveMotor : driveMotors) {
            driveMotor.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
            driveMotor.setDirection(DcMotorSimple.Direction.FORWARD);
            driveMotor.setPower(0);
        }
        for(DcMotor ballMotor : ballMotors) {
            ballMotor.setMode(DcMotor.RunMode.RUN_USING_ENCODER);
            ballMotor.setDirection(DcMotorSimple.Direction.FORWARD);
            ballMotor.setPower(0);
        }
//        cap.setMode(DcMotor.RunMode.RUN_USING_ENCODER);
//        cap.setDirection(DcMotorSimple.Direction.FORWARD);
//        cap.setPower(0);
    }
 
开发者ID:ykarim,项目名称:FTC2016,代码行数:26,代码来源:Robot.java

示例3: FtcZXDistanceSensor

import com.qualcomm.robotcore.hardware.HardwareMap; //导入依赖的package包/类
/**
 * Constructor: Creates an instance of the object.
 *
 * @param hardwareMap specifies the global hardware map.
 * @param instanceName specifies the instance name.
 * @param i2cAddress specifies the I2C address of the device.
 * @param addressIs7Bit specifies true if the I2C address is a 7-bit address, false if it is 8-bit.
 */
public FtcZXDistanceSensor(HardwareMap hardwareMap, String instanceName, int i2cAddress, boolean addressIs7Bit)
{
    super(hardwareMap, instanceName, i2cAddress, addressIs7Bit);

    if (debugEnabled)
    {
        dbgTrace = new TrcDbgTrace(moduleName + "." + instanceName, tracingEnabled, traceLevel, msgLevel);
    }

    byte[] data;

    data = syncRead(REG_REGVER, 1);
    regMapVersion = TrcUtil.bytesToInt(data[0]);

    data = syncRead(REG_MODEL, 1);
    modelVersion = TrcUtil.bytesToInt(data[0]);

    statusReaderId = addReader(instanceName + "_status", REG_STATUS, 1);
    gestureReaderId = addReader(instanceName + "_gesture", REG_STATUS, 1);
    gspeedReaderId = addReader(instanceName + "_gspeed", REG_GSPEED, 1);
    xposReaderId = addReader(instanceName + "_xpos", REG_XPOS, 1);
    zposReaderId = addReader(instanceName + "_zpos", REG_ZPOS, 1);
    lrngReaderId = addReader(instanceName + "_lrng", REG_LRNG, 1);
    rrngReaderId = addReader(instanceName + "_rrng", REG_RRNG, 1);
}
 
开发者ID:trc492,项目名称:Ftc2018RelicRecovery,代码行数:34,代码来源:FtcZXDistanceSensor.java

示例4: FtcI2cAdaFruitColorSensor

import com.qualcomm.robotcore.hardware.HardwareMap; //导入依赖的package包/类
/**
 * Constructor: Creates an instance of the object.
 *
 * @param hardwareMap specifies the global hardware map.
 * @param instanceName specifies the instance name.
 * @param i2cAddress specifies the I2C address of the device.
 * @param addressIs7Bit specifies true if the I2C address is a 7-bit address, false if it is 8-bit.
 */
public FtcI2cAdaFruitColorSensor(
        HardwareMap hardwareMap, String instanceName, int i2cAddress, boolean addressIs7Bit)
{
    super(hardwareMap, instanceName, i2cAddress, addressIs7Bit);

    if (debugEnabled)
    {
        dbgTrace = new TrcDbgTrace(moduleName + "." + instanceName, tracingEnabled, traceLevel, msgLevel);
    }

    setSensorEnabled(true);
    byte[] data = syncRead(REG_ID, 1);
    deviceID = TrcUtil.bytesToInt(data[0]);
    readerId = addReader(instanceName, READ_START, READ_LENGTH);
}
 
开发者ID:trc492,项目名称:Ftc2018RelicRecovery,代码行数:24,代码来源:FtcI2cAdaFruitColorSensor.java

示例5: FtcDcMotor

import com.qualcomm.robotcore.hardware.HardwareMap; //导入依赖的package包/类
/**
 * Constructor: Create an instance of the object.
 *
 * @param hardwareMap specifies the global hardware map.
 * @param instanceName specifies the instance name.
 * @param lowerLimitSwitch specifies the lower limit switch object.
 * @param upperLimitSwitch specifies the upper limit switch object.
 * @param analogSensor specifies an analog position sensor instead of the motor encoder.
 */
public FtcDcMotor(HardwareMap hardwareMap, String instanceName,
                  TrcDigitalInput lowerLimitSwitch, TrcDigitalInput upperLimitSwitch, TrcAnalogInput analogSensor)
{
    super(instanceName);

    if (debugEnabled)
    {
        dbgTrace = new TrcDbgTrace(moduleName + "." + instanceName, tracingEnabled, traceLevel, msgLevel);
    }

    this.instanceName = instanceName;
    this.lowerLimitSwitch = lowerLimitSwitch;
    this.upperLimitSwitch = upperLimitSwitch;
    this.analogSensor = analogSensor;
    motor = hardwareMap.dcMotor.get(instanceName);
    zeroEncoderValue = motor.getCurrentPosition();
    prevEncPos = zeroEncoderValue;
}
 
开发者ID:trc492,项目名称:Ftc2018RelicRecovery,代码行数:28,代码来源:FtcDcMotor.java

示例6: FtcServo

import com.qualcomm.robotcore.hardware.HardwareMap; //导入依赖的package包/类
/**
 * Constructor: Creates an instance of the object.
 *
 * @param hardwareMap specifies the global hardware map.
 * @param instanceName specifies the instance name.
 */
public FtcServo(HardwareMap hardwareMap, String instanceName)
{
    super(instanceName);

    if (debugEnabled)
    {
        dbgTrace = new TrcDbgTrace(moduleName + "." + instanceName, tracingEnabled, traceLevel, msgLevel);
    }

    this.instanceName = instanceName;
    servo = hardwareMap.servo.get(instanceName);
    prevLogicalPos = servo.getPosition();
    controller = servo.getController();
    timer = new TrcTimer(instanceName);
    event = new TrcEvent(instanceName);
    sm = new TrcStateMachine(instanceName);
}
 
开发者ID:trc492,项目名称:Ftc2018RelicRecovery,代码行数:24,代码来源:FtcServo.java

示例7: init

import com.qualcomm.robotcore.hardware.HardwareMap; //导入依赖的package包/类
public void init(HardwareMap ahwMap) {
    // save reference to HW Map
    hwMap = ahwMap;

    // Define and Initialize Motors
    leftDrive  = hwMap.get(DcMotor.class, "left_drive");
    rightDrive = hwMap.get(DcMotor.class, "right_drive");
    leftDrive.setDirection(DcMotor.Direction.REVERSE);

    // Set all motors to zero power
    leftDrive.setPower(0);
    rightDrive.setPower(0);

    // Set all motors to run without encoders.
    // May want to use RUN_USING_ENCODERS if encoders are installed.
    leftDrive.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
    rightDrive.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);

    // Define and initialize ALL installed servos.
    arm  = hwMap.get(Servo.class, "arm");
    claw = hwMap.get(Servo.class, "claw");
    arm.setPosition(ARM_HOME);
    claw.setPosition(CLAW_HOME);
}
 
开发者ID:trc492,项目名称:Ftc2018RelicRecovery,代码行数:25,代码来源:HardwareK9bot.java

示例8: init

import com.qualcomm.robotcore.hardware.HardwareMap; //导入依赖的package包/类
public void init(HardwareMap ahwMap) {
    // save reference to HW Map
    hwMap = ahwMap;

    // Define and Initialize Motors
    leftMotor   = hwMap.dcMotor.get("left motor");
    rightMotor  = hwMap.dcMotor.get("right motor");
    leftMotor.setDirection(DcMotor.Direction.REVERSE);

    // Set all motors to zero power
    leftMotor.setPower(0);
    rightMotor.setPower(0);

    // Set all motors to run without encoders.
    // May want to use RUN_USING_ENCODERS if encoders are installed.
    leftMotor.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
    rightMotor.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);

    // Define and initialize ALL installed servos.
    arm = hwMap.servo.get("arm");
    claw = hwMap.servo.get("claw");
    arm.setPosition(ARM_HOME);
    claw.setPosition(CLAW_HOME);
}
 
开发者ID:forgod01,项目名称:5094-2016-2017,代码行数:25,代码来源:HardwareK9bot.java

示例9: init

import com.qualcomm.robotcore.hardware.HardwareMap; //导入依赖的package包/类
public void init(HardwareMap ahwMap) {
    // save reference to HW Map
    hwMap = ahwMap;

    // Define and Initialize Motors
    leftMotor = hwMap.dcMotor.get("left_drive");
    rightMotor = hwMap.dcMotor.get("right_drive");
    leftMotor.setDirection(DcMotor.Direction.REVERSE);

    // Set all motors to zero power
    leftMotor.setPower(0);
    rightMotor.setPower(0);

    // Set all motors to run without encoders.
    // May want to use RUN_USING_ENCODERS if encoders are installed.
    leftMotor.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
    rightMotor.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);

    // Define and initialize ALL installed servos.
    arm = hwMap.servo.get("arm");
    claw = hwMap.servo.get("claw");
    arm.setPosition(ARM_HOME);
    claw.setPosition(CLAW_HOME);
}
 
开发者ID:MHS-FIRSTrobotics,项目名称:RadicalRobotics2017,代码行数:25,代码来源:HardwareK9bot.java

示例10: execute

import com.qualcomm.robotcore.hardware.HardwareMap; //导入依赖的package包/类
/**
 * Executes the current state once by running the {@link State#execute()}, then checks to see if
 * the state needs to be changed by running the {@link State#changeState(Enum)} method of the
 * currently running state
 */
public void execute() {
    if (index == -1) {
        return;
    }

    STATE state = states.get(index);
    if (state.name().equalsIgnoreCase("NOTHING"))

        // Inject requested variables
        inject(state, "hardwareMap", HardwareMap.class, opMode.hardwareMap);
    inject(state, "gamepad1", Gamepad.class, opMode.gamepad1);
    inject(state, "gamepad2", Gamepad.class, opMode.gamepad2);
    inject(state, "telemetry", Telemetry.class, opMode.telemetry);
    inject(state, "opMode", opMode.getClass(), opMode);

    state.execute();
}
 
开发者ID:MHS-FIRSTrobotics,项目名称:RadicalRobotics2017,代码行数:23,代码来源:AdvancedFiniteStateMachine.java

示例11: createServoMap

import com.qualcomm.robotcore.hardware.HardwareMap; //导入依赖的package包/类
/**
 * create a map that links ServoName to ServoControl
 *
 * @param hardwareMap         retrieves the servos from here
 * @param servoStartPresetMap the map that assigns a start preset to each ServoName
 * @return the created servoMap
 */
public static Map<ServoName, ServoControl> createServoMap(HardwareMap hardwareMap, Map<ServoName, Enum> servoStartPresetMap) {
    Map<ServoName, ServoControl> servoMap = new HashMap<>(); //create the map

    //loop through the start preset map
    for (Map.Entry<ServoName, Enum> entry : servoStartPresetMap.entrySet()) {
        ServoName servoName = entry.getKey();
        Enum preset = entry.getValue();

        //get the servo from the hardwareMap
        Servo servo = hardwareMap.servo.get(servoName.getHardwareName());

        //create a ServoControl from that servo
        ServoControl servoControl = new ServoControl(servo, servoName, preset);
        servoMap.put(servoName, servoControl); //add it to the map
    }

    return servoMap; //return the map
}
 
开发者ID:FTC7393,项目名称:EVLib,代码行数:26,代码来源:ServoCfg.java

示例12: execute

import com.qualcomm.robotcore.hardware.HardwareMap; //导入依赖的package包/类
/**
 * Executes the current state once by running the {@link State#execute()}, then checks to see if
 * the state needs to be changed by running the {@link State#changeState(Enum)} method of the
 * currently running state
 */
public void execute() {
    if (index == -1) {
        return;
    }

    STATE state = states.get(index);
    if (state.name().equalsIgnoreCase("NOTHING"))

        // Inject requested variables
        inject(state, "hardwareMap", HardwareMap.class, opMode.hardwareMap);
    inject(state, "gamepad1", Gamepad.class, opMode.gamepad1);
    inject(state, "gamepad2", Gamepad.class, opMode.gamepad2);
    inject(state, "telemetry", Telemetry.class, opMode.telemetry);
    inject(state, "opMode", opMode.getClass(), opMode);

    state.execute();
    index = state.stateChange().ordinal();
}
 
开发者ID:MHS-FIRSTrobotics,项目名称:RadicalRobotics2017,代码行数:24,代码来源:FiniteStateMachine2.java

示例13: mapCoreInterfaceDeviceModule

import com.qualcomm.robotcore.hardware.HardwareMap; //导入依赖的package包/类
private void mapCoreInterfaceDeviceModule(HardwareMap map, DeviceManager deviceMgr, ControllerConfiguration ctrlConf) throws RobotCoreException, InterruptedException {
    if (!ctrlConf.isEnabled()) return;
    DeviceInterfaceModule deviceInterfaceModule = deviceMgr.createDeviceInterfaceModule(ctrlConf.getSerialNumber());
    map.deviceInterfaceModule.put(ctrlConf.getName(), deviceInterfaceModule);

    List<DeviceConfiguration> pwmDevices = ((DeviceInterfaceModuleConfiguration) ctrlConf).getPwmOutputs();
    buildDevices(pwmDevices, map, deviceMgr, deviceInterfaceModule);

    List<DeviceConfiguration> i2cDevices = ((DeviceInterfaceModuleConfiguration) ctrlConf).getI2cDevices();
    buildI2cDevices(i2cDevices, map, deviceMgr, deviceInterfaceModule);

    List<DeviceConfiguration> analogInputDevices = ((DeviceInterfaceModuleConfiguration) ctrlConf).getAnalogInputDevices();
    buildDevices(analogInputDevices, map, deviceMgr, deviceInterfaceModule);

    List<DeviceConfiguration> digitalDevices = ((DeviceInterfaceModuleConfiguration) ctrlConf).getDigitalDevices();
    buildDevices(digitalDevices, map, deviceMgr, deviceInterfaceModule);

    List<DeviceConfiguration> analogOutputDevices = ((DeviceInterfaceModuleConfiguration) ctrlConf).getAnalogOutputDevices();
    buildDevices(analogOutputDevices, map, deviceMgr, deviceInterfaceModule);
}
 
开发者ID:MHS-FIRSTrobotics,项目名称:RadicalRobotics2017,代码行数:21,代码来源:XtensibleEventLoop.java

示例14: buildDevices

import com.qualcomm.robotcore.hardware.HardwareMap; //导入依赖的package包/类
private void buildDevices(List<DeviceConfiguration> list, HardwareMap map, DeviceManager deviceMgr, DeviceInterfaceModule deviceInterfaceModule) {
    for (DeviceConfiguration deviceConfiguration : list) {
        ConfigurationType devType = deviceConfiguration.getType();
        if (devType == BuiltInConfigurationType.OPTICAL_DISTANCE_SENSOR) {
            mapOpticalDistanceSensor(map, deviceMgr, deviceInterfaceModule, deviceConfiguration);
        } else if (devType == BuiltInConfigurationType.ANALOG_INPUT) {
            mapAnalogInputDevice(map, deviceMgr, deviceInterfaceModule, deviceConfiguration);
        } else if (devType == BuiltInConfigurationType.TOUCH_SENSOR) {
            mapTouchSensor(map, deviceMgr, deviceInterfaceModule, deviceConfiguration);
        } else if (devType == BuiltInConfigurationType.DIGITAL_DEVICE) {
            mapDigitalDevice(map, deviceMgr, deviceInterfaceModule, deviceConfiguration);
        } else if (devType == BuiltInConfigurationType.PULSE_WIDTH_DEVICE) {
            mapPwmOutputDevice(map, deviceMgr, deviceInterfaceModule, deviceConfiguration);
        } else if (devType == BuiltInConfigurationType.ANALOG_OUTPUT) {
            mapAnalogOutputDevice(map, deviceMgr, deviceInterfaceModule, deviceConfiguration);
        } else if (devType == BuiltInConfigurationType.LED) {
            mapLED(map, deviceMgr, deviceInterfaceModule, deviceConfiguration);
        } else if (devType == BuiltInConfigurationType.NOTHING) {
            // nothing to do
        } else {
            RobotLog.w("Unexpected device type connected to Device Interface Module while parsing XML: " + devType.toString());
        }
    }
}
 
开发者ID:MHS-FIRSTrobotics,项目名称:RadicalRobotics2017,代码行数:25,代码来源:XtensibleEventLoop.java

示例15: execute

import com.qualcomm.robotcore.hardware.HardwareMap; //导入依赖的package包/类
/**
 * Executes the current state once by running the {@link State#execute()}, then checks to see if
 * the state needs to be changed by running the {@link State#changeState(Enum)} method of the
 * currently running state
 */
public void execute() {
    if (index == -1) {
        return;
    }

    STATE state = states.get(index);
    if (state.name().equalsIgnoreCase("NOTHING"))

        // Inject requested variables
        inject(state, "hardwareMap", HardwareMap.class, opMode.hardwareMap);
    inject(state, "gamepad1", Gamepad.class, opMode.gamepad1);
    inject(state, "gamepad2", Gamepad.class, opMode.gamepad2);
    inject(state, "telemetry", Telemetry.class, opMode.telemetry);
    inject(state, "opMode", opMode.getClass(), opMode);

    state.execute();
    if (state.stateChange()) {
        index = ++index;
        if (index > states.size()) {
            index = -1;
        }
    }
}
 
开发者ID:MHS-FIRSTrobotics,项目名称:RadicalRobotics2017,代码行数:29,代码来源:FiniteStateMachine.java


注:本文中的com.qualcomm.robotcore.hardware.HardwareMap类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。