本文整理汇总了Java中lejos.robotics.SampleProvider.sampleSize方法的典型用法代码示例。如果您正苦于以下问题:Java SampleProvider.sampleSize方法的具体用法?Java SampleProvider.sampleSize怎么用?Java SampleProvider.sampleSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lejos.robotics.SampleProvider
的用法示例。
在下文中一共展示了SampleProvider.sampleSize方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getInfraredSensorSeek
import lejos.robotics.SampleProvider; //导入方法依赖的package包/类
/**
* Get sample from infrared sensor set in <b>seek mode</b>.
*
* @param sensorPort on which the infrared sensor is connected
* @return array of size 7
*/
public synchronized ArrayList<Float> getInfraredSensorSeek(SensorPort sensorPort) {
SampleProvider sampleProvider = this.deviceHandler.getProvider(sensorPort, InfraredSensorMode.SEEK.getValues()[0]);
float[] sample = new float[sampleProvider.sampleSize()];
sampleProvider.fetchSample(sample, 0);
ArrayList<Float> result = new ArrayList<>();
result.add((float) Math.round(sample[0]));
result.add((float) Math.round(sample[1]));
result.add((float) Math.round(sample[2]));
result.add((float) Math.round(sample[3]));
result.add((float) Math.round(sample[4]));
result.add((float) Math.round(sample[5]));
result.add((float) Math.round(sample[6]));
result.add((float) Math.round(sample[7]));
return result;
}
示例2: isPressed
import lejos.robotics.SampleProvider; //导入方法依赖的package包/类
/**
* Check if the touch sensor is pressed.
*
* @param sensorPort on which the touch sensor is connected
* @return true if the sensor is pressed
*/
public synchronized boolean isPressed(SensorPort sensorPort) {
SampleProvider sampleProvider = this.deviceHandler.getProvider(sensorPort, "Touch");
float[] sample = new float[sampleProvider.sampleSize()];
sampleProvider.fetchSample(sample, 0);
if ( sample[0] == 1.0 ) {
return true;
} else {
return false;
}
}
示例3: getUltraSonicSensorPresence
import lejos.robotics.SampleProvider; //导入方法依赖的package包/类
/**
* Get if there is presence of other ultrasonic sensor.<br>
* <br>
*
* @param sensorPort on which the ultrasonic sensor is connected
* @return true if exists other ultrasonic sensor
*/
public synchronized boolean getUltraSonicSensorPresence(SensorPort sensorPort) {
SampleProvider sampleProvider = this.deviceHandler.getProvider(sensorPort, UltrasonicSensorMode.PRESENCE.getValues()[0]);
float[] sample = new float[sampleProvider.sampleSize()];
sampleProvider.fetchSample(sample, 0);
if ( sample[0] == 1.0 ) {
return true;
} else {
return false;
}
}
示例4: getUltraSonicSensorDistance
import lejos.robotics.SampleProvider; //导入方法依赖的package包/类
/**
* Get sample from ultrasonic sensor set in <b>distance mode</b>.
*
* @param sensorPort on which the ultrasonic sensor is connected
* @return value in <i>cm</i> of the distance of the ultrasonic sensor and some object
*/
public synchronized float getUltraSonicSensorDistance(SensorPort sensorPort) {
SampleProvider sampleProvider = this.deviceHandler.getProvider(sensorPort, UltrasonicSensorMode.DISTANCE.getValues()[0]);
float[] sample = new float[sampleProvider.sampleSize()];
sampleProvider.fetchSample(sample, 0); // ^= distance in cm
float distance = Math.round(sample[0] * 100.0f);
if ( distance <= 3 ) {
return 0;
} else if ( distance > 255 ) {
return 255;
}
return distance;
}
示例5: getColorSensorAmbient
import lejos.robotics.SampleProvider; //导入方法依赖的package包/类
/**
* Get sample from a color sensor set in <b>ambient light mode</b>
*
* @param sensorPort on which the color sensor is connected
* @return the value of the measurement of the sensor
*/
public synchronized float getColorSensorAmbient(SensorPort sensorPort) {
SampleProvider sampleProvider = this.deviceHandler.getProvider(sensorPort, ColorSensorMode.AMBIENTLIGHT.getValues()[0]);
float[] sample = new float[sampleProvider.sampleSize()];
sampleProvider.fetchSample(sample, 0);
return Math.round(sample[0] * 100.0f); // * 100
}
示例6: getColorSensorColour
import lejos.robotics.SampleProvider; //导入方法依赖的package包/类
/**
* Get sample from a color sensor in <b>colour mode</b>.
*
* @param sensorPort on which the sensor is connected
* @return color that is detected with the sensor (see {@link Pickcolor} for all colors that can be detected)
*/
public synchronized PickColor getColorSensorColour(SensorPort sensorPort) {
SampleProvider sampleProvider = this.deviceHandler.getProvider(sensorPort, ColorSensorMode.COLOUR.getValues()[0]);
float[] sample = new float[sampleProvider.sampleSize()];
sampleProvider.fetchSample(sample, 0);
return PickColor.get(Math.round(sample[0]));
}
示例7: getColorSensorRed
import lejos.robotics.SampleProvider; //导入方法依赖的package包/类
/**
* Get sample from a color sensor in <b>red mode</b>.
*
* @param sensorPort on which the sensor is connected
* @return the value of the measurement of the sensor
*/
public synchronized float getColorSensorRed(SensorPort sensorPort) {
SampleProvider sampleProvider = this.deviceHandler.getProvider(sensorPort, ColorSensorMode.RED.getValues()[0]);
float[] sample = new float[sampleProvider.sampleSize()];
sampleProvider.fetchSample(sample, 0);
return Math.round(sample[0] * 100.0f); // * 100
}
示例8: getColorSensorRgb
import lejos.robotics.SampleProvider; //导入方法依赖的package包/类
/**
* Get sample from a color sensor in <b>RGB mode</b>.
*
* @param sensorPort on which the sensor is connected
* @return array of size three where in each element of the array is encode on color channel (RGB), values are between 0 and 255
*/
public synchronized ArrayList<Float> getColorSensorRgb(SensorPort sensorPort) {
SampleProvider sampleProvider = this.deviceHandler.getProvider(sensorPort, ColorSensorMode.RGB.getValues()[0]);
float[] sample = new float[sampleProvider.sampleSize()];
sampleProvider.fetchSample(sample, 0);
ArrayList<Float> result = new ArrayList<>();
result.add((float) Math.round(sample[0] * 255.0f));
result.add((float) Math.round(sample[1] * 255.0f));
result.add((float) Math.round(sample[2] * 255.0f));
return result;
}
示例9: getInfraredSensorDistance
import lejos.robotics.SampleProvider; //导入方法依赖的package包/类
/**
* Get sample from infrared sensor set in <b>distance mode</b>.
*
* @param sensorPort on which the infrared sensor is connected
* @return value in <i>cm</i> of the distance of the infrared sensor and some object
*/
public synchronized float getInfraredSensorDistance(SensorPort sensorPort) {
SampleProvider sampleProvider = this.deviceHandler.getProvider(sensorPort, InfraredSensorMode.DISTANCE.getValues()[0]);
float[] sample = new float[sampleProvider.sampleSize()];
sampleProvider.fetchSample(sample, 0);
return Math.round(sample[0]);
}
示例10: getSoundLevel
import lejos.robotics.SampleProvider; //导入方法依赖的package包/类
/**
* Get sample from sound sensor.
*
* @param sensorPort on which the sound sensor is connected
* @return value in <i>dB</i> of the sound level measured
*/
public synchronized float getSoundLevel(SensorPort sensorPort) {
SampleProvider sampleProvider = this.deviceHandler.getProvider(sensorPort, SoundSensorMode.SOUND.getValues()[0]);
float[] sample = new float[sampleProvider.sampleSize()];
sampleProvider.fetchSample(sample, 0);
return Math.round(sample[0] * 100);
}
示例11: AbstractFilter
import lejos.robotics.SampleProvider; //导入方法依赖的package包/类
public AbstractFilter(SampleProvider source) {
this.source=source;
this.sampleSize=source.sampleSize();
}
示例12: getGyroSensorAngle
import lejos.robotics.SampleProvider; //导入方法依赖的package包/类
/**
* Get sample from gyro sensor.<br>
* <br>
* Client must provide sensor port on which the sensor is connected and the mode in which sensor would working (see {@link GyroSensorMode})
*
* @param sensorPort on which the gyro sensor sensor is connected
* @return angle of the measurment of the sensor
*/
public synchronized float getGyroSensorAngle(SensorPort sensorPort) {
SampleProvider sampleProvider = this.deviceHandler.getProvider(sensorPort, GyroSensorMode.ANGLE.getValues()[0]);
float[] sample = new float[sampleProvider.sampleSize()];
sampleProvider.fetchSample(sample, 0);
return Math.round(sample[0]);
}
示例13: getGyroSensorRate
import lejos.robotics.SampleProvider; //导入方法依赖的package包/类
/**
* Get sample from gyro sensor.<br>
* <br>
* Client must provide sensor port on which the sensor is connected and the mode in which sensor would working (see {@link GyroSensorMode})
*
* @param sensorPort on which the gyro sensor sensor is connected
* @return rate of the measurment of the sensor
*/
public synchronized float getGyroSensorRate(SensorPort sensorPort) {
SampleProvider sampleProvider = this.deviceHandler.getProvider(sensorPort, GyroSensorMode.RATE.getValues()[0]);
float[] sample = new float[sampleProvider.sampleSize()];
sampleProvider.fetchSample(sample, 0);
return Math.round(sample[0]);
}