本文整理汇总了Java中lejos.hardware.motor.EV3MediumRegulatedMotor类的典型用法代码示例。如果您正苦于以下问题:Java EV3MediumRegulatedMotor类的具体用法?Java EV3MediumRegulatedMotor怎么用?Java EV3MediumRegulatedMotor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EV3MediumRegulatedMotor类属于lejos.hardware.motor包,在下文中一共展示了EV3MediumRegulatedMotor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initRegulatedMotor
import lejos.hardware.motor.EV3MediumRegulatedMotor; //导入依赖的package包/类
private void initRegulatedMotor(ActorPort actorPort, Actor actorType, Port hardwarePort) {
this.lcd.clear();
// Hal.formatInfoMessage("Initializing motor on port " + actorPort, this.lcd);
switch ( actorType.getName() ) {
case LARGE:
this.lejosRegulatedMotors.put(actorPort, new EV3LargeRegulatedMotor(hardwarePort));
break;
case MEDIUM:
this.lejosRegulatedMotors.put(actorPort, new EV3MediumRegulatedMotor(hardwarePort));
break;
case REGULATED:
this.lejosRegulatedMotors.put(actorPort, new NXTRegulatedMotor(hardwarePort));
break;
default:
throw new DbcException("Actor type " + actorType.getName() + " does not exists!");
}
}
示例2: init
import lejos.hardware.motor.EV3MediumRegulatedMotor; //导入依赖的package包/类
public void init(boolean isClockwiseMove) {
this.robotRunning = true;
//Init Motor
motorA = new EV3MediumRegulatedMotor(MotorPort.A);
motorB = new EV3LargeRegulatedMotor(MotorPort.B);
motorC = new EV3LargeRegulatedMotor(MotorPort.C);
// init sensors
this.colorSensor = new EV3ColorSensor(SensorPort.S3);
//For reading color only
try {
this.colorSensorRGB = new EV3ColorSensor(SensorPort.S2);
} catch(Exception e) {
this.colorSensorRGB = null;
}
new Thread(new ColorIdentifyTask()).start();
new Thread(new LightIdentifyTask()).start();
}
示例3: main
import lejos.hardware.motor.EV3MediumRegulatedMotor; //导入依赖的package包/类
public static void main(String[] args) {
log.info("Initializing...");
LCD.clear();
disableOtherLogLayers();
LCD.clear();
Button.setKeyClickVolume(1);
SystemTime.initSysTime();
ClockProperties clockProperties = ClockProperties.getInstance();
AnalogClock clock = new AnalogClock(clockProperties, new TickPeriod(5,
TimeUnit.SECONDS), new Time(0, 20),
MirrorMotor
.invertMotor(new EV3MediumRegulatedMotor(MotorPort.A)),
MirrorMotor
.invertMotor(new EV3LargeRegulatedMotor(MotorPort.B)));
MainWithMenu mainWithMenu = new MainWithMenu(clock);
log.info("Ready");
Sound.beep();
mainWithMenu.start();
}
示例4: handleMotorMessage
import lejos.hardware.motor.EV3MediumRegulatedMotor; //导入依赖的package包/类
public void handleMotorMessage(Object msg) {
if(msg instanceof RegulatedMotorMessages.RotateMessage){
((EV3MediumRegulatedMotor) motor).rotate(((RegulatedMotorMessages.RotateMessage)msg).getAngle());
return;
}
if(msg instanceof RegulatedMotorMessages.RotateToMessage){
((EV3MediumRegulatedMotor) motor).rotateTo(((RegulatedMotorMessages.RotateToMessage)msg).getAngle());
return;
}
if (msg instanceof RegulatedMotorMessages.ForwardMsg) {
motor.forward();
return;
}
if (msg instanceof RegulatedMotorMessages.BackwardMsg) {
motor.backward();
return;
}
if (msg instanceof RegulatedMotorMessages.StopMsg) {
motor.stop();
return;
}
if (msg instanceof RegulatedMotorMessages.SetSpeedMsg) {
((EV3MediumRegulatedMotor) motor).setSpeed(((RegulatedMotorMessages.SetSpeedMsg) msg).getSpeed());
return;
}
// Drop packet otherwise
}
示例5: handleMotorMessage
import lejos.hardware.motor.EV3MediumRegulatedMotor; //导入依赖的package包/类
@Override
public void handleMotorMessage(Object msg) {
if(msg instanceof RegulatedMotorMessages.RotateMessage){
((EV3MediumRegulatedMotor) motor).rotate(((RegulatedMotorMessages.RotateMessage)msg).getAngle());
return;
}
if(msg instanceof RegulatedMotorMessages.RotateToMessage){
((EV3MediumRegulatedMotor) motor).rotateTo(((RegulatedMotorMessages.RotateToMessage)msg).getAngle());
return;
}
if (msg instanceof RegulatedMotorMessages.ForwardMsg) {
motor.forward();
return;
}
if (msg instanceof RegulatedMotorMessages.BackwardMsg) {
motor.backward();
return;
}
if (msg instanceof RegulatedMotorMessages.StopMsg) {
motor.stop();
return;
}
if (msg instanceof RegulatedMotorMessages.SetSpeedMsg) {
((EV3MediumRegulatedMotor) motor).setSpeed(((RegulatedMotorMessages.SetSpeedMsg) msg).getSpeed());
return;
}
}
示例6: main
import lejos.hardware.motor.EV3MediumRegulatedMotor; //导入依赖的package包/类
public static void main(String[] args) {
LCD.drawString("Hello world", 2, 3);
Button.waitForAnyPress();
EV3MediumRegulatedMotor ev3MediumRegulatedMotor = new EV3MediumRegulatedMotor(MotorPort.C);
resetSmallEngine(ev3MediumRegulatedMotor);
grab(ev3MediumRegulatedMotor);
LCD.drawString("Position: " + ev3MediumRegulatedMotor.getPosition(), 2, 3);
resetSmallEngine(ev3MediumRegulatedMotor);
Button.waitForAnyPress();
}
示例7: Canon
import lejos.hardware.motor.EV3MediumRegulatedMotor; //导入依赖的package包/类
public Canon(Port canonEnginePort, Port rotationEnginePort) {
canonEngine = new EV3MediumRegulatedMotor(canonEnginePort);
rotationEngine = new EV3LargeRegulatedMotor(rotationEnginePort);
resetEngine(canonEngine);
resetEngine(rotationEngine);
}
示例8: mediumMotor
import lejos.hardware.motor.EV3MediumRegulatedMotor; //导入依赖的package包/类
public static synchronized Motor mediumMotor(Port port) {
Motor motor = mediumMotor.get(port);
if (motor == null) {
motor = new Motor(new EV3MediumRegulatedMotor(port.getPort()));
mediumMotor.put(port, motor);
}
return motor;
}
示例9: instantiateMotorCannon
import lejos.hardware.motor.EV3MediumRegulatedMotor; //导入依赖的package包/类
/**
* Instantiates the cannon-motor, optionally skips calibration
* @param skipMotorCannonCalibration
* @return
*/
private EV3MediumRegulatedMotor instantiateMotorCannon(
boolean skipMotorCannonCalibration) {
if (!skipMotorCannonCalibration) {
calibrateMotorCannon();
}
EV3MediumRegulatedMotor motor = new EV3MediumRegulatedMotor(MotorPort.C);
if (!skipMotorCannonCalibration) {
motor.rotate(-360);
}
return motor;
}
示例10: createMotor
import lejos.hardware.motor.EV3MediumRegulatedMotor; //导入依赖的package包/类
@Override
protected BaseMotor createMotor(Port motorPort){
return new EV3MediumRegulatedMotor(motorPort);
}
示例11: close
import lejos.hardware.motor.EV3MediumRegulatedMotor; //导入依赖的package包/类
@Override
public void close() {
((EV3MediumRegulatedMotor)motor).close();;
}
示例12: grab
import lejos.hardware.motor.EV3MediumRegulatedMotor; //导入依赖的package包/类
private static void grab(EV3MediumRegulatedMotor ev3MediumRegulatedMotor){
ev3MediumRegulatedMotor.setStallThreshold(2, 10);
ev3MediumRegulatedMotor.setSpeed(1000);
ev3MediumRegulatedMotor.rotate(-500, false);
ev3MediumRegulatedMotor.waitComplete();
}
示例13: Canon
import lejos.hardware.motor.EV3MediumRegulatedMotor; //导入依赖的package包/类
public Canon(Port port){
canonEngine = new EV3MediumRegulatedMotor(port);
resetMotor();
fire();
}
示例14: resetSmallEngine
import lejos.hardware.motor.EV3MediumRegulatedMotor; //导入依赖的package包/类
private static void resetSmallEngine(EV3MediumRegulatedMotor ev3MediumRegulatedMotor){
ev3MediumRegulatedMotor.setStallThreshold(2, 10);
ev3MediumRegulatedMotor.setSpeed(500);
ev3MediumRegulatedMotor.rotate(500, false);
ev3MediumRegulatedMotor.waitComplete();
}
示例15: SimpleEV3MediumMotor
import lejos.hardware.motor.EV3MediumRegulatedMotor; //导入依赖的package包/类
public SimpleEV3MediumMotor(Port port) {
super(port, new EV3MediumRegulatedMotor(port));
}