本文整理汇总了Java中lejos.robotics.RegulatedMotor类的典型用法代码示例。如果您正苦于以下问题:Java RegulatedMotor类的具体用法?Java RegulatedMotor怎么用?Java RegulatedMotor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RegulatedMotor类属于lejos.robotics包,在下文中一共展示了RegulatedMotor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: motorGo
import lejos.robotics.RegulatedMotor; //导入依赖的package包/类
private void motorGo(RegulatedMotor regulatedMotor, int power) {
if (regulatedMotor != null) {
Log.d(TAG, "motorGo " + power);
if (power > 0) {
regulatedMotor.setSpeed(power);
regulatedMotor.forward();
} else if (power == 0) {
stopMotor(regulatedMotor);
} else {
regulatedMotor.setSpeed(Math.abs(power));
regulatedMotor.backward();
}
}
}
示例2: main
import lejos.robotics.RegulatedMotor; //导入依赖的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();
}
示例3: main
import lejos.robotics.RegulatedMotor; //导入依赖的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();
}
示例4: main
import lejos.robotics.RegulatedMotor; //导入依赖的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);
}
示例5: run
import lejos.robotics.RegulatedMotor; //导入依赖的package包/类
public void run() {
lcd.drawString("Hello Trayan", 4, 2);
lcd.drawString("from leJOS", 4, 3);
// config motors
mB.setSpeed(900); // Degree per second
mC.setSpeed(900);
mB.synchronizeWith(new RegulatedMotor[] { mC });
// for (int i = 0; i < 4; i++) {
// moveForward(2000); //2s
// turnLeft(520);
// }
moveBackward(2000); //2s
}
示例6: OmniPilot
import lejos.robotics.RegulatedMotor; //导入依赖的package包/类
/**
* Instantiates a new omnidirectional pilot.
* This class also keeps track of the odometry
* Express the distances in the units you prefer (mm, in, cm ...)
*
* @param wheelDistanceFromCenter the wheel distance from center
* @param wheelDiameter the wheel diameter
* @param centralMotor the central motor
* @param CW120degMotor the motor at 120 degrees clockwise from front
* @param CCW120degMotor the motor at 120 degrees counter-clockwise from front
* @param centralWheelFrontal if true, the central wheel frontal else it is facing back
* @param motorReverse if motors are mounted reversed
*/
public OmniPilot (float wheelDistanceFromCenter, float wheelDiameter,
RegulatedMotor centralMotor, RegulatedMotor CW120degMotor, RegulatedMotor CCW120degMotor,
boolean centralWheelFrontal, boolean motorReverse,
Battery battery) {
this.wheelBase = wheelDistanceFromCenter;
this.wheelDiameter = wheelDiameter;
this.motor1 = centralMotor;
this.motor2 = CCW120degMotor;
this.motor3 = CW120degMotor;
this.battery = battery;
motor1.addListener(this);
motor2.addListener(this);
motor3.addListener(this);
initMatrices(centralWheelFrontal, motorReverse);
odo.setDaemon(true);
// odo.setPriority(6);
odo.start();
}
示例7: action
import lejos.robotics.RegulatedMotor; //导入依赖的package包/类
@Override
public void action() {
suppressed = false;
RegulatedMotor leftMotor = grabBot.getLeft();
RegulatedMotor rightMotor = grabBot.getRight();
leftMotor.synchronizeWith(new RegulatedMotor[]{rightMotor});
leftMotor.forward();
rightMotor.forward();
while( !suppressed ) {
Thread.yield();
}
leftMotor.stop(); // clean up
rightMotor.stop();
}
示例8: action
import lejos.robotics.RegulatedMotor; //导入依赖的package包/类
@Override
public void action() {
suppressed = false;
RegulatedMotor leftMotor = grabBot.getLeft();
RegulatedMotor rightMotor = grabBot.getRight();
leftMotor.rotate(-180, true);
rightMotor.rotate(-360, true);
while( (leftMotor.isMoving() || rightMotor.isMoving()) && !suppressed )
Thread.yield();
leftMotor.stop(); // clean up
rightMotor.stop();
}
示例9: getRegulatedMotor
import lejos.robotics.RegulatedMotor; //导入依赖的package包/类
/**
* Get regulated motor connected on port ({@link ActorPort})
*
* @exception DbcException if regulated motor does not exist
* @param actorPort on which the motor is connected
* @return regulate motor
*/
public RegulatedMotor getRegulatedMotor(ActorPort actorPort) {
RegulatedMotor motor = this.lejosRegulatedMotors.get(actorPort);
if ( motor == null ) {
throw new DbcException("No regulated motor on port " + actorPort + "!");
}
return motor;
}
示例10: LineFollower01
import lejos.robotics.RegulatedMotor; //导入依赖的package包/类
public LineFollower01() {
mA = new EV3LargeRegulatedMotor(MotorPort.A);
mB = new EV3LargeRegulatedMotor(MotorPort.B);
mC = new EV3LargeRegulatedMotor(MotorPort.C);
mB.setSpeed(120);// 2 RPM
mC.setSpeed(120);
mB.synchronizeWith(new RegulatedMotor[] { mC });
color = colorSensor.getRGBMode();
colorSample = new float[color.sampleSize()];
touch = touchSensor.getTouchMode();
sample = new float[touch.sampleSize()];
}
示例11: main
import lejos.robotics.RegulatedMotor; //导入依赖的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);
// Open clow
RegulatedMotor mA = new EV3LargeRegulatedMotor(MotorPort.A);
while (true) {
mA.resetTachoCount();
lcd.drawString("Up - Close", 4, 2);
lcd.drawString("Down - Open", 4, 3);
lcd.drawString("Escape - Exit", 4, 4);
// Simple menu
keys.waitForAnyPress(60000);
int maRotation = 0;
if (Button.DOWN.isDown()) {
maRotation = -620;
} else if (Button.UP.isDown()) {
maRotation = 620;
}
if (Button.ESCAPE.isDown()) {
System.exit(0);
}
mA.rotateTo(maRotation, false);
int count = mA.getTachoCount();
lcd.drawString("Tacho: " + count, 0, 2);
}
}
示例12: getMotor
import lejos.robotics.RegulatedMotor; //导入依赖的package包/类
/**
* Utility method to get Motor instance from string (A, B or C)
*/
public static RegulatedMotor getMotor(String motor)
{
if (motor.equals("A"))
return Motor.A;
else if (motor.equals("B"))
return Motor.B;
else if (motor.equals("C"))
return Motor.C;
else if (motor.equals("D"))
return Motor.D;
else
return null;
}
示例13: Cuckoo
import lejos.robotics.RegulatedMotor; //导入依赖的package包/类
public Cuckoo(RegulatedMotor cuckooMotor, Time tickTime,
ClockProperties clockProperties) {
this.cuckooMotor = cuckooMotor;
this.tickTime = tickTime;
this.clockProperties = clockProperties;
cuckooMotor.setAcceleration(400);
cuckooMotor.setSpeed(CUCKOO_SPEED);
}
示例14: rotationStarted
import lejos.robotics.RegulatedMotor; //导入依赖的package包/类
public void rotationStarted(RegulatedMotor motor, int tachoCount, boolean stall, long timeStamp) {
isMoving = true;
oldTacho = tachoCount;
// Notify MoveListener
if(listener != null) {
listener.moveStarted(moveEvent, this);
}
}
示例15: rotationStopped
import lejos.robotics.RegulatedMotor; //导入依赖的package包/类
public void rotationStopped(RegulatedMotor motor, int tachoCount,boolean stall, long timeStamp) {
isMoving = false;
int tachoTotal = tachoCount - oldTacho ;
float distance = (float)((tachoTotal/360f) * Math.PI * driveWheelDiameter);
float angle = Move.convertDistanceToAngle(distance, moveEvent.getArcRadius());
moveEvent = new Move(distance ,angle, isMoving);
// Notify MoveListener
if(listener != null) {
listener.moveStopped(moveEvent, this);
}
}