本文整理汇总了Java中lejos.hardware.motor.EV3LargeRegulatedMotor类的典型用法代码示例。如果您正苦于以下问题:Java EV3LargeRegulatedMotor类的具体用法?Java EV3LargeRegulatedMotor怎么用?Java EV3LargeRegulatedMotor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EV3LargeRegulatedMotor类属于lejos.hardware.motor包,在下文中一共展示了EV3LargeRegulatedMotor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Odometer
import lejos.hardware.motor.EV3LargeRegulatedMotor; //导入依赖的package包/类
public Odometer (EV3LargeRegulatedMotor leftMotor, EV3LargeRegulatedMotor rightMotor, int INTERVAL, boolean autostart) {
this.leftMotor = leftMotor;
this.rightMotor = rightMotor;
// default values, modify for your robot
this.rightRadius = GlobalDefinitions.WHEEL_RADIUS;
this.leftRadius = GlobalDefinitions.WHEEL_RADIUS;
this.width = GlobalDefinitions.WHEEL_BASE;
this.x = 0.0;
this.y = 0.0;
this.theta = 0.0;
this.oldDH = new double[2];
this.dDH = new double[2];
if (autostart) {
// if the timeout interval is given as <= 0, default to 20ms timeout
this.timer = new Timer((INTERVAL <= 0) ? INTERVAL : DEFAULT_TIMEOUT_PERIOD, this);
this.timer.start();
} else
this.timer = null;
}
示例2: initRegulatedMotor
import lejos.hardware.motor.EV3LargeRegulatedMotor; //导入依赖的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!");
}
}
示例3: main
import lejos.hardware.motor.EV3LargeRegulatedMotor; //导入依赖的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();
}
示例4: main
import lejos.hardware.motor.EV3LargeRegulatedMotor; //导入依赖的package包/类
public static void main(String[] args) {
EV3 ev3 = (EV3) BrickFinder.getLocal();
TextLCD lcd = ev3.getTextLCD();
Keys keys = ev3.getKeys();
RegulatedMotor m = new EV3LargeRegulatedMotor(MotorPort.A);
m.resetTachoCount();
m.rotateTo(-40);
int angle = m.getTachoCount(); // should be 760
lcd.drawInt(angle, 0, 0);
// keys.waitForAnyPress();
// m.rotateTo(0);
// angle = m.getTachoCount(); // should be 0
// lcd.drawInt(angle, 0, 1);
// keys.waitForAnyPress(); // wait for a button press
m.close();
}
示例5: main
import lejos.hardware.motor.EV3LargeRegulatedMotor; //导入依赖的package包/类
public static void main(String[] args) {
EV3 ev3 = (EV3) BrickFinder.getLocal();
TextLCD lcd = ev3.getTextLCD();
Keys keys = ev3.getKeys();
// lcd.drawString("Hello Trayan", 4, 2);
// lcd.drawString("from leJOS", 4, 3);
// Move forward
RegulatedMotor mB = new EV3LargeRegulatedMotor(MotorPort.B);
RegulatedMotor mC = new EV3LargeRegulatedMotor(MotorPort.C);
mB.synchronizeWith(new RegulatedMotor[] { mC });
mB.startSynchronization();
mB.forward();
mC.forward();
mB.endSynchronization();
Delay.msDelay(3000);
mB.startSynchronization();
mB.stop();
mC.stop();
mB.endSynchronization();
// keys.waitForAnyPress(5000);
}
示例6: EV3Helper
import lejos.hardware.motor.EV3LargeRegulatedMotor; //导入依赖的package包/类
/**
* Instantiates a new helper class and optionally calibrates the cannon.
* Robot is ready for operation after completion.
* @param skipMotorCannonCalibration Set to true if you don't want to calibrate the cannon
*/
public EV3Helper(boolean skipMotorCannonCalibration) {
motorRight = new EV3LargeRegulatedMotor(MotorPort.A);
motorLeft = new EV3LargeRegulatedMotor(MotorPort.B);
//Sets default motor speed for driving motors
motorRight.setSpeed(DEFAULT_MOTOR_SPEED);
motorLeft.setSpeed(DEFAULT_MOTOR_SPEED);
motorCannon = instantiateMotorCannon(skipMotorCannonCalibration);
irSensor = new EV3IRSensor(SensorPort.S1);
colorSensor = new EV3ColorSensor(SensorPort.S4);
rangeSampler = irSensor.getDistanceMode();
lastRange = new float[rangeSampler.sampleSize()];
colors = getColors();
}
示例7: init
import lejos.hardware.motor.EV3LargeRegulatedMotor; //导入依赖的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();
}
示例8: main
import lejos.hardware.motor.EV3LargeRegulatedMotor; //导入依赖的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();
}
示例9: Navigation
import lejos.hardware.motor.EV3LargeRegulatedMotor; //导入依赖的package包/类
public Navigation(Odometer odo) {
this.odometer = odo;
EV3LargeRegulatedMotor[] motors = this.odometer.getMotors();
this.leftMotor = motors[0];
this.rightMotor = motors[1];
// set acceleration
this.leftMotor.setAcceleration(ACCELERATION);
this.rightMotor.setAcceleration(ACCELERATION);
}
示例10: RoughUSLocalizer
import lejos.hardware.motor.EV3LargeRegulatedMotor; //导入依赖的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;
}
示例11: init
import lejos.hardware.motor.EV3LargeRegulatedMotor; //导入依赖的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));
}
示例12: TestDriver
import lejos.hardware.motor.EV3LargeRegulatedMotor; //导入依赖的package包/类
public TestDriver(Odometer odo){
this.odo = odo;
EV3LargeRegulatedMotor[] motors = this.odo.getMotors();
this.leftMotor = motors[0];
this.rightMotor = motors[1];
// set acceleration
this.leftMotor.setAcceleration(ACCELERATION);
this.rightMotor.setAcceleration(ACCELERATION);
}
示例13: GrabBot
import lejos.hardware.motor.EV3LargeRegulatedMotor; //导入依赖的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});
}
示例14: GrabBot
import lejos.hardware.motor.EV3LargeRegulatedMotor; //导入依赖的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});
}
示例15: Canon
import lejos.hardware.motor.EV3LargeRegulatedMotor; //导入依赖的package包/类
public Canon(Port canonEnginePort, Port rotationEnginePort) {
canonEngine = new EV3MediumRegulatedMotor(canonEnginePort);
rotationEngine = new EV3LargeRegulatedMotor(rotationEnginePort);
resetEngine(canonEngine);
resetEngine(rotationEngine);
}