本文整理汇总了Java中lejos.hardware.sensor.EV3IRSensor类的典型用法代码示例。如果您正苦于以下问题:Java EV3IRSensor类的具体用法?Java EV3IRSensor怎么用?Java EV3IRSensor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EV3IRSensor类属于lejos.hardware.sensor包,在下文中一共展示了EV3IRSensor类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: EV3Helper
import lejos.hardware.sensor.EV3IRSensor; //导入依赖的package包/类
/**
* Instantiates a new helper class and optionally calibrates the cannon.
* Robot is ready for operation after completion.
* @param skipMotorCannonCalibration Set to true if you don't want to calibrate the cannon
*/
public EV3Helper(boolean skipMotorCannonCalibration) {
motorRight = new EV3LargeRegulatedMotor(MotorPort.A);
motorLeft = new EV3LargeRegulatedMotor(MotorPort.B);
//Sets default motor speed for driving motors
motorRight.setSpeed(DEFAULT_MOTOR_SPEED);
motorLeft.setSpeed(DEFAULT_MOTOR_SPEED);
motorCannon = instantiateMotorCannon(skipMotorCannonCalibration);
irSensor = new EV3IRSensor(SensorPort.S1);
colorSensor = new EV3ColorSensor(SensorPort.S4);
rangeSampler = irSensor.getDistanceMode();
lastRange = new float[rangeSampler.sampleSize()];
colors = getColors();
}
示例2: initSensor
import lejos.hardware.sensor.EV3IRSensor; //导入依赖的package包/类
private void initSensor(SensorPort sensorPort, Sensor sensorType, Port hardwarePort) {
if ( sensorType != null && isUsed(sensorType) ) {
this.lcd.clear();
// Hal.formatInfoMessage("Initializing " + sensorType.getComponentType().getShortName() + " on port " + sensorPort + " ...", this.lcd);
switch ( sensorType.getType() ) {
case COLOR:
this.lejosSensors.put(sensorPort, sensorSampleProviders(new EV3ColorSensor(hardwarePort)));
break;
case INFRARED:
this.lejosSensors.put(sensorPort, sensorSampleProviders(new EV3IRSensor(hardwarePort)));
break;
case GYRO:
this.gyroSensor = new EV3GyroSensor(hardwarePort);
this.lejosSensors.put(sensorPort, sensorSampleProviders(this.gyroSensor));
break;
case TOUCH:
this.lejosSensors.put(sensorPort, sensorSampleProviders(new EV3TouchSensor(hardwarePort)));
break;
case ULTRASONIC:
this.lejosSensors.put(sensorPort, sensorSampleProviders(new EV3UltrasonicSensor(hardwarePort)));
break;
case COMPASS_HI_TEC:
this.hiTechnicCompass = new HiTechnicCompass(hardwarePort);
this.lejosSensors.put(sensorPort, sensorSampleProviders(this.hiTechnicCompass));
break;
case SOUND:
this.lejosSensors.put(sensorPort, sensorSampleProviders(new NXTSoundSensor(hardwarePort)));
break;
default:
throw new DbcException("Sensor type " + sensorType.getType() + " does not exists!");
}
}
}
示例3: IRSensor
import lejos.hardware.sensor.EV3IRSensor; //导入依赖的package包/类
public IRSensor() // Constructor initiates the IR Sensor and the sampler we will use to fetch sensor data
{
Port port = LocalEV3.get().getPort("S4"); // Define the port used by the Sensor
SensorModes sensor = new EV3IRSensor(port); // Initiate the EV3 IR Sensor
sampler = sensor.getMode("Distance"); // Define the sampler to be the IRSensor in "Distance" measuring mode
this.setDaemon(true); // Daemonize the sensor thread.
}
示例4: SimpleEV3IRSensor
import lejos.hardware.sensor.EV3IRSensor; //导入依赖的package包/类
public SimpleEV3IRSensor(Port port) throws EV3ScriptException {
delegate = new EV3IRSensor(port);
logger = SensorMonitorFactory.getLogger(port);
setChannel(1); // Set default channel
// Distance mode
distanceMode = delegate.getDistanceMode();
distanceSample = new float[distanceMode.sampleSize()];
// Seek mode
seekMode = delegate.getSeekMode();
seekSample = new float[seekMode.sampleSize()];
}
示例5: createSensor
import lejos.hardware.sensor.EV3IRSensor; //导入依赖的package包/类
private EV3IRSensor createSensor(Port port) {
return new EV3IRSensor(port);
}
示例6: createSensor
import lejos.hardware.sensor.EV3IRSensor; //导入依赖的package包/类
private EV3IRSensor createSensor(Port port) {
System.out.println("Create LeJOS sensor");
return new EV3IRSensor(port.getPort());
}
示例7: closeSensor
import lejos.hardware.sensor.EV3IRSensor; //导入依赖的package包/类
private void closeSensor(EV3IRSensor sensor) {
System.out.println("Close LeJOS sensor");
sensor.close();
}
示例8: getIrSensor
import lejos.hardware.sensor.EV3IRSensor; //导入依赖的package包/类
public EV3IRSensor getIrSensor() {
return irSensor;
}