To program the drone, one needs to insert Thread.sleep statements between successive commands. For example, if you want to go forward for three seconds and then turn left, you need to write something like
The nodeCopter project has a nice API call for command sequences like these:
drone.forward();
drone.after(3000).turnLeft();
The behaviour is the same, but it looks much nicer.
One question remains: should the after()-method be executed synchronously (i.e. it blocks the command thread for 3 seconds) or should it be called asynchronously, return immediately and schedule the command in a TimerTask ?
CommandManager now has 3 more methods: doFor(millis), waitFor(millis) and schedule(millis, runnable). First and second have same semantics and are blocking calls. Schedule is non-blocking.
To program the drone, one needs to insert Thread.sleep statements between successive commands. For example, if you want to go forward for three seconds and then turn left, you need to write something like
drone.forward(); Thread.sleep(3000); drone.turnLeft();
The nodeCopter project has a nice API call for command sequences like these:
drone.forward(); drone.after(3000).turnLeft();
The behaviour is the same, but it looks much nicer.
One question remains: should the after()-method be executed synchronously (i.e. it blocks the command thread for 3 seconds) or should it be called asynchronously, return immediately and schedule the command in a TimerTask ?