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


Java SampleProvider类代码示例

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


SampleProvider类属于lejos.robotics包,在下文中一共展示了SampleProvider类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
 
开发者ID:OpenRoberta,项目名称:robertalab-ev3lejos-v0,代码行数:22,代码来源:Hal.java

示例2: RMIRemoteSampleProvider

import lejos.robotics.SampleProvider; //导入依赖的package包/类
protected RMIRemoteSampleProvider(String portName, String sensorName, String modeName) throws RemoteException {
	super(0);
   	try {
		Class<?> c = Class.forName(sensorName);
		Class<?>[] params = new Class<?>[1];
		params[0] = Port.class;
		Constructor<?> con = c.getConstructor(params);
		Object[] args = new Object[1];
		args[0] = LocalEV3.get().getPort(portName);
		Object obj = con.newInstance(args);
		provider = (SampleProvider) obj;
		closer = (Closeable) obj;
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
开发者ID:SnakeSVx,项目名称:ev3,代码行数:17,代码来源:RMIRemoteSampleProvider.java

示例3: RoughUSLocalizer

import lejos.robotics.SampleProvider; //导入依赖的package包/类
public RoughUSLocalizer(Odometer odo,  SampleProvider usSensor, float[] usData, LocalizationType locType,EV3LargeRegulatedMotor leftMotor, EV3LargeRegulatedMotor rightMotor) {
	this.odo = odo;
	this.usSensor = usSensor;
	this.usData = usData;
	this.locType = locType;
	this.leftMotor=leftMotor;
	this.rightMotor=rightMotor;

}
 
开发者ID:alisharif2,项目名称:dpm-project,代码行数:10,代码来源:RoughUSLocalizer.java

示例4: 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;
    }
}
 
开发者ID:OpenRoberta,项目名称:robertalab-ev3lejos-v0,代码行数:17,代码来源:Hal.java

示例5: 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;
    }
}
 
开发者ID:OpenRoberta,项目名称:robertalab-ev3lejos-v0,代码行数:18,代码来源:Hal.java

示例6: 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;
}
 
开发者ID:OpenRoberta,项目名称:robertalab-ev3lejos-v0,代码行数:19,代码来源:Hal.java

示例7: 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
}
 
开发者ID:OpenRoberta,项目名称:robertalab-ev3lejos-v0,代码行数:13,代码来源:Hal.java

示例8: 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]));
}
 
开发者ID:OpenRoberta,项目名称:robertalab-ev3lejos-v0,代码行数:13,代码来源:Hal.java

示例9: 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
}
 
开发者ID:OpenRoberta,项目名称:robertalab-ev3lejos-v0,代码行数:13,代码来源:Hal.java

示例10: 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;
}
 
开发者ID:OpenRoberta,项目名称:robertalab-ev3lejos-v0,代码行数:17,代码来源:Hal.java

示例11: 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]);
}
 
开发者ID:OpenRoberta,项目名称:robertalab-ev3lejos-v0,代码行数:14,代码来源:Hal.java

示例12: 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);
}
 
开发者ID:OpenRoberta,项目名称:robertalab-ev3lejos-v0,代码行数:14,代码来源:Hal.java

示例13: findProviderByMode

import lejos.robotics.SampleProvider; //导入依赖的package包/类
private SampleProvider findProviderByMode(SampleProviderBean[] sampleProviders, String sensorMode) {
    for ( SampleProviderBean bean : sampleProviders ) {
        if ( bean.getModeName().equals(sensorMode) ) {
            return bean.getSampleProvider();
        }
    }
    throw new DbcException(sensorMode + " sample provider does not exists!");
}
 
开发者ID:OpenRoberta,项目名称:robertalab-ev3lejos-v0,代码行数:9,代码来源:DeviceHandler.java

示例14: LinearCalibrationFilter

import lejos.robotics.SampleProvider; //导入依赖的package包/类
public LinearCalibrationFilter(SampleProvider source) {
  super(source);
  lowPassFilter = new LowPassFilter(source, 0);
  lowerBound = new float[sampleSize];
  upperBound = new float[sampleSize];
  offset = new float[sampleSize];
  scale = new float[sampleSize];

  for (int i = 0; i < sampleSize; i++) {
    upperBound[i] = 0;
    lowerBound[i] = 0;
    offset[i] = 0;
    scale[i] = 1;
  }
}
 
开发者ID:SnakeSVx,项目名称:ev3,代码行数:16,代码来源:LinearCalibrationFilter.java

示例15: MinimumFilter

import lejos.robotics.SampleProvider; //导入依赖的package包/类
public MinimumFilter(SampleProvider source, int bufferSize) {
  super(source, bufferSize);
  min = new float[sampleSize];
  buf = new float[sampleSize];
  oldest = new float[sampleSize];

}
 
开发者ID:SnakeSVx,项目名称:ev3,代码行数:8,代码来源:MinimumFilter.java


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