Java Reference
In-Depth Information
if
(detectMeasure !
#
null
) {
writeOut("LASER DETECT d
#
"
!
detectMeasure.distance
!
" t
#
"
!
detectMeasure.direction);
detectMeasure
#
null
;
}
else if
(localPos.getT()
##
Math.toRadians(45.0)) {
// move the laser to the left position
commands.add("ROTATETO 315");
// repeats this command
commands.add("DETECT");
}
else if
(localPos.getT()
##
Math.toRadians(315.0)) {
// move the laser to the right position
commands.add("ROTATETO 45");
// repeats this command
commands.add("DETECT");
}
else
{
// move the laser to the right position
commands.add("ROTATETO 45");
// repeats this command
commands.add("DETECT");
}
}
else
writeOut("DECLINED");
}
public void
nextStep() {
if
(running && numSteps > 0.0) {
if
(numSteps < 1.0)
local.rototrans
(0.0, 0.0, orientation*numSteps*rotStep);
else
local.rototrans(0.0, 0.0, orientation*rotStep);
environment.repaint();
numSteps-
#
1.0;
running
#
true
;
}
else if
(running) {
running
#
false
;
if
(!detect && !scan) writeOut("LASER ARRIVED");
}
if
(detect) {
double
distance
#
this.read(
true
);
if
(distance > -1.0) {
if
(detectMeasure
##
null
)
detectMeasure
#
new
Measure
(distance, localPos.getT());