any help greatly appreciated
- Code: Select all
//package cleary.robot;
import java.util.Iterator;
import java.util.ArrayList;
import lejos.navigation.*;
import lejos.nxt.*;
import java.io.*;
public class DirectionTest {
public static void main(String [] args) {
Navigator robot = new SimpleNavigator(5.6F, 13.0F,Motor.C, Motor.B, false);
robot.setTurnSpeed(450);
RobotMover b = new RobotMover(robot);
PathFindingRoute route = new PathFindingRoute();
route.appendMove(8,0); //start
route.appendMove(7,0); // up
route.appendMove(6,0); // up
route.appendMove(5,0); // up
route.appendMove(4,0); // up
route.appendMove(4,1); // right
route.appendMove(3,1); // up
route.appendMove(3,2); // right
route.appendMove(2,2); // up
route.appendMove(1,2); // up
route.appendMove(1,3); // right
route.appendMove(1,4); // up
route.appendMove(0,4); // up
route.appendMove(0,5); // right
RouteToDirectionsConvertor convertor = new RouteToDirectionsConvertor(route);
convertor.convertRouteToDirections();
ArrayList<String> directions = new ArrayList<String>();
directions = convertor.getDirections();
int i = 0;
/*
This loop will take the ArrayList directions and loop through it taking all the directions and calling there rellevant
method from the robot mover class
*/
for(String s : directions)// loop Count will be for each String in the directions Arraylist
{
String t = directions.get(i);
LCD.drawString(t, 0, 4);
if(s == "North")
{
b.north(); //i.e. call north() from a RobotMover object that you have created
i++;
}
else if (t == "South")
{
b.south();
i++;
}
else if (t =="East")
{
b.east();
i++;
}
else if (t =="West")
{
b.west();
i++;
}
}
}
}
