Page 277 - The Definitive Guide to Building Java Robots
P. 277
Preston_5564C07.fm Page 258 Monday, September 26, 2005 5:38 AM
258 CHAPTER 7 ■ NAVIGATION
} else {
xOffset = (int)(ROBOT_RADIUS * Math.cos(Math.toRadians(westPos)));
navPoint.x = west;
}
if (bestReadings[1] == REL_NORTH) {
yOffset = (int)(ROBOT_RADIUS * Math.sin(Math.toRadians(northPos)));
navPoint.y = 100 - north;
} else {
yOffset = (int)(ROBOT_RADIUS * Math.sin(Math.toRadians(southPos)));
navPoint.y = south ;
}
navPoint.x = navPoint.x + xOffset;
navPoint.y = navPoint.y + yOffset;
return navPoint;
}
// move from a to b
public void move(Point a, Point b) throws Exception {
MotionVector v = getDistanceVector(a, b);
move(v);
}
public void move(Point b) throws Exception {
move(getStart(), b);
}
public SonarServos getSonarServos() {
return sonarServos;
}
public static void main(String[] args) {
try {
WebSerialClient sPort = new WebSerialClient("10.10.10.99", "8080", "1");
Localization local = new Localization(sPort);
local.move(new Point(36, 36));
} catch (Exception e) {
e.printStackTrace();
System.exit(1);
}
}
}