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


Java MotorPort类代码示例

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


MotorPort类属于lejos.hardware.port包,在下文中一共展示了MotorPort类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: DeviceManager

import lejos.hardware.port.MotorPort; //导入依赖的package包/类
public DeviceManager(){
	mm 	= new MotorManager(BrickType.EV3);
	sm 	= new SensorManager(BrickType.EV3);
	
	sensPorts.put("S1", SensorPort.S1);
	sensPorts.put("S2", SensorPort.S2);
	sensPorts.put("S3", SensorPort.S3);
	sensPorts.put("S4", SensorPort.S4);

	motorPorts.put("A", MotorPort.A);
	motorPorts.put("B", MotorPort.B);
	motorPorts.put("C", MotorPort.C);
	motorPorts.put("D", MotorPort.D);
	
	checkForCreationThread();
}
 
开发者ID:Echtzeitsysteme,项目名称:mindroid,代码行数:17,代码来源:DeviceManager.java

示例2: main

import lejos.hardware.port.MotorPort; //导入依赖的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

示例3: main

import lejos.hardware.port.MotorPort; //导入依赖的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();
	}
 
开发者ID:iproduct,项目名称:course-social-robotics,代码行数:21,代码来源:MotorDemo01.java

示例4: main

import lejos.hardware.port.MotorPort; //导入依赖的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);
}
 
开发者ID:iproduct,项目名称:course-social-robotics,代码行数:27,代码来源:MoveRobot.java

示例5: EV3Helper

import lejos.hardware.port.MotorPort; //导入依赖的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();
}
 
开发者ID:magnusbae,项目名称:HelloBrick,代码行数:23,代码来源:EV3Helper.java

示例6: calibrateMotorCannon

import lejos.hardware.port.MotorPort; //导入依赖的package包/类
/**
 * Calibrates the cannon and puts it in a read-to-fire state.
 */
private void calibrateMotorCannon() {
  UnregulatedMotor motor = new UnregulatedMotor(MotorPort.C);
  motor.setPower(50);

  int maxIterations = 40;
  int lastTachoCount = 0;
  while (maxIterations-- > 0) {
    Delay.msDelay(100);
    int newTachoCount = motor.getTachoCount();
    if (newTachoCount == lastTachoCount) {
      break;
    }
    lastTachoCount = newTachoCount;
  }

  motor.close();
}
 
开发者ID:magnusbae,项目名称:HelloBrick,代码行数:21,代码来源:EV3Helper.java

示例7: testEV3DevPlatformOnEV3BrickTest

import lejos.hardware.port.MotorPort; //导入依赖的package包/类
@Test
public void testEV3DevPlatformOnEV3BrickTest() throws IOException {

    BatteryMock batteryMock = new BatteryMock(this.tempFolder);
    batteryMock.createEV3DevMocksEV3BrickPlatformPath();

    System.out.println(batteryMock.getTempBatteryFolder());

    System.setProperty(EV3DevFileSystem.EV3DEV_TESTING_KEY, tempMocksFolder.getAbsolutePath().toString());

    EV3DevDeviceChild device = new EV3DevDeviceChild();
    LOGGER.debug(device.getROOT_PATH());
    LOGGER.debug(device.getMotorPort(MotorPort.A));
    assertThat(device.getPlatform(), is(EV3DevPlatform.EV3BRICK));

    /*
    LOGGER.debug(device.getSensorPort("asdf"));
    device.detect("demo","ui");
    device.getIntegerAttribute("demo");
    device.getPlatform();
    device.getStringAttribute("demo");
    device.setIntegerAttribute("", 0);
    device.setStringAttribute("","");
    */
}
 
开发者ID:ev3dev-lang-java,项目名称:ev3dev-lang-java,代码行数:26,代码来源:EV3DevDeviceTest.java

示例8: init

import lejos.hardware.port.MotorPort; //导入依赖的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();
}
 
开发者ID:eSDK,项目名称:esdk_ide_ev3,代码行数:20,代码来源:HDCIDERobot.java

示例9: main

import lejos.hardware.port.MotorPort; //导入依赖的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();
}
 
开发者ID:rafalmag,项目名称:EV3-projects,代码行数:20,代码来源:MainWithMenu.java

示例10: GrabBot

import lejos.hardware.port.MotorPort; //导入依赖的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

示例11: GrabBot

import lejos.hardware.port.MotorPort; //导入依赖的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

示例12: main

import lejos.hardware.port.MotorPort; //导入依赖的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();
}
 
开发者ID:jweijers,项目名称:EV3-robots,代码行数:12,代码来源:Hello.java

示例13: MotorControl

import lejos.hardware.port.MotorPort; //导入依赖的package包/类
public MotorControl()
{
	// init
	leftMotor = new UnregulatedMotor(MotorPort.A);
	rightMotor = new UnregulatedMotor(MotorPort.D);
	
	freeMotors();
}
 
开发者ID:galme,项目名称:ROLF-EV3,代码行数:9,代码来源:MotorControl.java

示例14: LineFollower01

import lejos.hardware.port.MotorPort; //导入依赖的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()];
}
 
开发者ID:iproduct,项目名称:course-social-robotics,代码行数:13,代码来源:LineFollower01.java

示例15: main

import lejos.hardware.port.MotorPort; //导入依赖的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);
	}

}
 
开发者ID:iproduct,项目名称:course-social-robotics,代码行数:36,代码来源:MoveClaw.java


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