- Code: Select all
float fMaxSpeed = motor.getMoveMaxSpeed();
motor.setMoveSpeed(fMaxSpeed);
// motor.backward();
while(!motor.isMoving())
if(sonic.getDistance() < 30)
for (int i=0; i< 1; i++)
try
{
motor.rotate(-640);
motor.travel(-30);
motor.rotate(-640);
shooter.travel(-48);
motor.stop();
shooter.stop();
Thread.sleep(1000);
}
catch(Exception e)
{
return;
}
what my robot is doing is if the robot is near an object it will turn away from the object and move 30cm away from the object fire at the object, now what i wanted to know is that if the robot was more than 30cm away from the object to move towards the object until it reaches 30 cm from the object and then stop.
can any one just give me a little help cuz im really stuck
