本文整理汇总了Java中lejos.hardware.sensor.EV3UltrasonicSensor类的典型用法代码示例。如果您正苦于以下问题:Java EV3UltrasonicSensor类的具体用法?Java EV3UltrasonicSensor怎么用?Java EV3UltrasonicSensor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EV3UltrasonicSensor类属于lejos.hardware.sensor包,在下文中一共展示了EV3UltrasonicSensor类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import lejos.hardware.sensor.EV3UltrasonicSensor; //导入依赖的package包/类
public static void init() {
GlobalDefinitions.LEFT_MOTOR = new EV3LargeRegulatedMotor(LocalEV3.get().getPort(GlobalDefinitions.leftMotorPort));
GlobalDefinitions.RIGHT_MOTOR = new EV3LargeRegulatedMotor(LocalEV3.get().getPort(GlobalDefinitions.rightMotorPort));
GlobalDefinitions.RELOADMOTOR = new EV3LargeRegulatedMotor(LocalEV3.get().getPort(GlobalDefinitions.reloadMotorPort));
GlobalDefinitions.SHOOTMOTOR = new EV3LargeRegulatedMotor(LocalEV3.get().getPort(GlobalDefinitions.shooterMotorPort));
GlobalDefinitions.LEFT_COLOR_SENSOR = new EV3ColorSensor(LocalEV3.get().getPort(GlobalDefinitions.leftColorSensorPort));
GlobalDefinitions.RIGHT_COLOR_SENSOR = new EV3ColorSensor(LocalEV3.get().getPort(GlobalDefinitions.rightColorSensorPort));
GlobalDefinitions.US_SENSOR = new EV3UltrasonicSensor(LocalEV3.get().getPort(GlobalDefinitions.usSensorPort));
//GlobalDefinitions.REAR_COLOR_SENSOR = new EV3ColorSensor(LocalEV3.get().getPort(GlobalDefinitions.rearColorSensorPort));
}
示例2: setupUltrasonicSensor
import lejos.hardware.sensor.EV3UltrasonicSensor; //导入依赖的package包/类
private void setupUltrasonicSensor() {
uSensorMotor = Motor.C;
uSensor = new EV3UltrasonicSensor(ev3.getPort("S3"));
ultrasonicDistSP = uSensor.getDistanceMode();
ultrasonicDistSample = new float[ultrasonicDistSP.sampleSize()];
//uSensorMotor.setAcceleration(200);
//uSensorMotor.setAcceleration(10);;
}
示例3: initSensor
import lejos.hardware.sensor.EV3UltrasonicSensor; //导入依赖的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!");
}
}
}
示例4: SimpleEV3UltrasonicSensor
import lejos.hardware.sensor.EV3UltrasonicSensor; //导入依赖的package包/类
public SimpleEV3UltrasonicSensor(Port port) {
delegate = new EV3UltrasonicSensor(port);
logger = SensorMonitorFactory.getLogger(port);
// Distance mode
distanceMode = delegate.getDistanceMode();
distanceSample = new float[distanceMode.sampleSize()];
// Listen (presence) mode
listenMode = delegate.getListenMode();
listenSample = new float[listenMode.sampleSize()];
}
示例5: setupSensors
import lejos.hardware.sensor.EV3UltrasonicSensor; //导入依赖的package包/类
void setupSensors() {
logger.trace("setupSensors");
leftTouch = new EV3TouchSensor(SensorPort.S1);
rightTouch = new EV3TouchSensor(SensorPort.S4);
distance = new EV3UltrasonicSensor(SensorPort.S2);
distance.enable();
distanceSampler = distance.getDistanceMode();
}
示例6: FilteredUltrasonicSensor
import lejos.hardware.sensor.EV3UltrasonicSensor; //导入依赖的package包/类
public FilteredUltrasonicSensor(EV3UltrasonicSensor usSensor) {
// TODO Auto-generated constructor stub
this.ultrasonicSampleProvider = usSensor.getDistanceMode();
this.ultrasonicData = new float[ultrasonicSampleProvider.sampleSize()];
}