This repository has been archived by the owner on Apr 7, 2024. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
peterf.se@gmail.com
committed
Oct 15, 2009
1 parent
2101760
commit 87b1a58
Showing
2 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
TravelTest/src/org/penemunxt/projects/traveltest/nxt/CompassTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package org.penemunxt.projects.traveltest.nxt; | ||
|
||
import lejos.robotics.navigation.*; | ||
import lejos.nxt.Button; | ||
import lejos.nxt.LCD; | ||
import lejos.nxt.Motor; | ||
import lejos.nxt.SensorPort; | ||
import lejos.nxt.Sound; | ||
import lejos.nxt.addon.*; | ||
|
||
|
||
public class CompassTest { | ||
public static void main(String[] args) { | ||
CompassSensor CS = new CompassSensor(SensorPort.S2); | ||
while(!Button.ESCAPE.isPressed()){ | ||
Sound.playTone((int) CS.getDegrees()*10, 10, 75); | ||
} | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
TravelTest/src/org/penemunxt/projects/traveltest/nxt/TravelTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,47 @@ | ||
package org.penemunxt.projects.traveltest.nxt; | ||
|
||
import lejos.robotics.navigation.*; | ||
import lejos.nxt.Button; | ||
import lejos.nxt.LCD; | ||
import lejos.nxt.Motor; | ||
import lejos.nxt.SensorPort; | ||
import lejos.nxt.addon.*; | ||
|
||
|
||
public class TravelTest { | ||
public static void main(String[] args) { | ||
CompassPilot compil = new CompassPilot | ||
(new CompassSensor(SensorPort.S2), 49, 125, Motor.C, Motor.B); | ||
TachoPilot tacho = new TachoPilot(49, 125, Motor.C, Motor.B); | ||
SimpleNavigator simnav = new SimpleNavigator (tacho); | ||
// compil.calibrate(); | ||
compil.resetCartesianZero(); | ||
simnav.setTurnSpeed(50); | ||
simnav.forward(); | ||
try { | ||
Thread.sleep(5000); | ||
} catch (InterruptedException e) { | ||
|
||
} | ||
simnav.stop(); | ||
simnav.rotate(90); | ||
simnav.forward(); | ||
try { | ||
Thread.sleep(2000); | ||
} catch (InterruptedException e) { | ||
|
||
} | ||
simnav.stop(); | ||
// simnav.arc(300, 360); | ||
// simnav.setMoveSpeed(300); | ||
// simnav.goTo(1000, 0); | ||
// simnav.rotate(180); | ||
//// simnav.goTo(0, 0); | ||
//// simnav.updatePosition(); | ||
// simnav.travel(2000); | ||
LCD.drawString(String.valueOf(simnav.getX()), 1, 2); | ||
LCD.drawString(String.valueOf(simnav.getY()), 1, 3); | ||
LCD.drawString(String.valueOf(simnav.getHeading()), 1, 4); | ||
Button.ESCAPE.waitForPressAndRelease(); | ||
} | ||
} |