本文整理汇总了Java中lejos.hardware.sensor.EV3TouchSensor类的典型用法代码示例。如果您正苦于以下问题:Java EV3TouchSensor类的具体用法?Java EV3TouchSensor怎么用?Java EV3TouchSensor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EV3TouchSensor类属于lejos.hardware.sensor包,在下文中一共展示了EV3TouchSensor类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: main
import lejos.hardware.sensor.EV3TouchSensor; //导入依赖的package包/类
public static void main(String[] args) {
EV3 ev3 = (EV3) BrickFinder.getLocal();
TextLCD lcd = ev3.getTextLCD();
Keys keys = ev3.getKeys();
EV3TouchSensor touchSensor = new EV3TouchSensor(SensorPort.S1);
SensorMode touch = touchSensor.getTouchMode();
float[] sample = new float[touch.sampleSize()];
RegulatedMotor m = new EV3LargeRegulatedMotor(MotorPort.A);
m.resetTachoCount();
m.rotateTo(320, true);
// int angle = m.getTachoCount(); // should be -360
// lcd.drawInt(angle, 0, 0);
// keys.waitForAnyPress();
// m.rotateTo(-100, true);
// do{
// touch.fetchSample(sample, 0);
// } while (sample[0] == 0);
while (m.isMoving())
Thread.yield();
m.stop();
int angle = m.getTachoCount(); // should be < -100
lcd.drawInt(angle, 0, 1);
// keys.waitForAnyPress();
}
开发者ID:iproduct,项目名称:course-social-robotics,代码行数:32,代码来源:MotorDemo03.java
示例2: GrabBot
import lejos.hardware.sensor.EV3TouchSensor; //导入依赖的package包/类
private GrabBot(){
left = new EV3LargeRegulatedMotor(MotorPort.A);
right = new EV3LargeRegulatedMotor(MotorPort.B);
touch = new EV3TouchSensor(SensorPort.S1);
arbitrator = new Arbitrator(new Behavior[]{forward, hit});
}
开发者ID:jweijers,项目名称:EV3-robots,代码行数:8,代码来源:GrabBot.java
示例3: GrabBot
import lejos.hardware.sensor.EV3TouchSensor; //导入依赖的package包/类
private GrabBot(){
left = new EV3LargeRegulatedMotor(MotorPort.A);
right = new EV3LargeRegulatedMotor(MotorPort.B);
touch = new EV3TouchSensor(SensorPort.S1);
Behavior forward = new ForwardBehavior(this);
Behavior hit = new ObstacleBehavior(this);
arbitrator = new Arbitrator(new Behavior[]{forward, hit});
}
开发者ID:jweijers,项目名称:EV3-robots,代码行数:10,代码来源:GrabBot.java
示例4: initSensor
import lejos.hardware.sensor.EV3TouchSensor; //导入依赖的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!");
}
}
}
开发者ID:OpenRoberta,项目名称:robertalab-ev3lejos-v0,代码行数:34,代码来源:DeviceHandler.java
示例5: SimpleEV3TouchSensor
import lejos.hardware.sensor.EV3TouchSensor; //导入依赖的package包/类
public SimpleEV3TouchSensor(Port port) {
delegate = new EV3TouchSensor(port);
logger = SensorMonitorFactory.getLogger(port);
// Touch mode
touchMode = delegate.getTouchMode();
touchSample = new float[touchMode.sampleSize()];
}
开发者ID:jbenech,项目名称:gnikrap,代码行数:8,代码来源:SimpleEV3TouchSensor.java
示例6: setupSensors
import lejos.hardware.sensor.EV3TouchSensor; //导入依赖的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();
}
开发者ID:RadicalZephyr,项目名称:ev3java,代码行数:10,代码来源:Main.java
示例7: createSensor
import lejos.hardware.sensor.EV3TouchSensor; //导入依赖的package包/类
private EV3TouchSensor createSensor(Port port) {
return new EV3TouchSensor(port);
}
开发者ID:jweijers,项目名称:EV3-robots,代码行数:4,代码来源:TouchSensor.java
示例8: createSensor
import lejos.hardware.sensor.EV3TouchSensor; //导入依赖的package包/类
private EV3TouchSensor createSensor(Port port) {
System.out.println("Create LeJOS sensor");
return new EV3TouchSensor(port);
}
开发者ID:jweijers,项目名称:EV3-robots,代码行数:5,代码来源:TouchSensor.java
示例9: closeSensor
import lejos.hardware.sensor.EV3TouchSensor; //导入依赖的package包/类
private void closeSensor(EV3TouchSensor sensor) {
System.out.println("Close LeJOS sensor");
sensor.close();
}
开发者ID:jweijers,项目名称:EV3-robots,代码行数:5,代码来源:TouchSensor.java
示例10: getTouch
import lejos.hardware.sensor.EV3TouchSensor; //导入依赖的package包/类
public EV3TouchSensor getTouch() {
return touch;
}
开发者ID:jweijers,项目名称:EV3-robots,代码行数:4,代码来源:GrabBot.java
示例11: createSensor
import lejos.hardware.sensor.EV3TouchSensor; //导入依赖的package包/类
private EV3TouchSensor createSensor(Port port) {
System.out.println("Create LeJOS sensor");
return new EV3TouchSensor(port.getPort());
}
开发者ID:bdeneuter,项目名称:rx-mindstorms,代码行数:5,代码来源:TouchSensor.java
示例12: main
import lejos.hardware.sensor.EV3TouchSensor; //导入依赖的package包/类
public static void main(String[] args) {
EV3 ev3 = (EV3) BrickFinder.getLocal();
TextLCD lcd = ev3.getTextLCD();
Keys keys = ev3.getKeys();
EV3TouchSensor touchSensor = new EV3TouchSensor(SensorPort.S1);
SensorMode touch = touchSensor.getTouchMode();
float[] sample = new float[touch.sampleSize()];
RegulatedMotor mA = new EV3LargeRegulatedMotor(MotorPort.A);
RegulatedMotor mB = new EV3LargeRegulatedMotor(MotorPort.B);
RegulatedMotor mC = new EV3LargeRegulatedMotor(MotorPort.C);
mA.resetTachoCount();
mB.resetTachoCount();
mC.resetTachoCount();
mA.rotateTo(760);
int angle = mA.getTachoCount(); // should be -360
lcd.drawInt(angle, 0, 0);
keys.waitForAnyPress();
mB.setSpeed(720);// 2 RPM
mC.setSpeed(720);
mB.forward();
mC.forward();
Delay.msDelay(1000);
mB.stop();
mC.stop();
mB.rotateTo(360);
mB.rotate(-720, true);
while (mB.isMoving())
Thread.yield();
angle = mB.getTachoCount();
lcd.drawInt(angle, 0, 1);
mA.rotateTo(-100, true);
do{
touch.fetchSample(sample, 0);
} while (mA.isMoving() && sample[0] == 0);
mA.stop();
angle = mA.getTachoCount(); // should be -360
lcd.drawInt(angle, 0, 2);
keys.waitForAnyPress();
}
开发者ID:iproduct,项目名称:course-social-robotics,代码行数:46,代码来源:MotorDemo06.java
示例13: TRAC3RsArm
import lejos.hardware.sensor.EV3TouchSensor; //导入依赖的package包/类
public TRAC3RsArm() {
System.out.println("Setting up Touch Sensor 1...");
touchSensor1 = new EV3TouchSensor(LocalEV3.get().getPort(touchSensorPortName1));
System.out.println("Setting up Touch Sensor 2...");
touchSensor2 = new EV3TouchSensor(LocalEV3.get().getPort(touchSensorPortName2));
System.out.println("Setting up Motor 1...");
motor1 = new EV3LargeRegulatedMotor(motorPort1);
motor1.rotateTo(0);
System.out.println("Setting up Motor 2...");
motor2 = new EV3LargeRegulatedMotor(motorPort2);
motor2.rotateTo(0);
System.out.println("Setting up Motor 3...");
motor3 = new EV3MediumRegulatedMotor(motorPort3);
motor3.rotateTo(0);
}
开发者ID:stahlfabrik,项目名称:TRAC3R,代码行数:23,代码来源:TRAC3RsArm.java
注:本文中的lejos.hardware.sensor.EV3TouchSensor类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论