@Override public void disconnect() { stop(); landing(); manager.close(); if (videoManager != null) videoManager.close(); if (navdataManager != null) navdataManager.close(); }
/** connect to AR.Drone */ @Override public boolean connect() { if (inetaddr == null) { inetaddr = getInetAddress(ipaddr); } manager = new CommandManager(inetaddr); return manager.connect(ARDroneUtils.PORT); }
public void execute(BaseActivity activity) throws InterruptedException { YADroneApplication app = (YADroneApplication) activity.getApplication(); ARDrone drone = app.getARDrone(); final CommandManager cm = drone.getCommandManager(); final NavDataManager nm = drone.getNavDataManager(); if (mSound.length() > 0) { int resId = activity.getResources().getIdentifier(mSound, "raw", activity.getPackageName()); if (resId != 0) { activity.setVolumeControlStream(AudioManager.STREAM_MUSIC); activity.soundPlayer.loadAndPlaySound(resId); } } int repetitions = mRepetitions > 0 ? mRepetitions : 1; for (int i = 0; i < repetitions; i++) { Log.d("FlyRoute", mCommand.toString()); nm.setStateListener( new StateListener() { private boolean done = false; @Override public synchronized void stateChanged(DroneState state) { if (!done && state.isEmergency()) { cm.emergency(); } nm.setStateListener(null); done = true; } @Override public void controlStateChanged(ControlState state) { // ignore } }); cm.setCommand(mCommand); Thread.sleep(mDuration / repetitions); } }
@Override public void down(int speed) { if (manager != null) manager.down(speed); }
@Override public void up(int speed) { if (manager != null) manager.up(speed); }
@Override public void down() { if (manager != null) manager.down(); }
@Override public void move3D(int speedX, int speedY, int speedZ, int speedSpin) { if (manager != null) manager.move3D(speedX, speedY, speedZ, speedSpin); }
@Override public void setVerticalCameraWithHorizontal() { if (manager != null) manager.setVerticalCameraWithHorizontal(); }
@Override public void setSpeed(int speed) { if (manager != null) manager.setSpeed(speed); }
/** * 0.01-1.0 -> 1-100% * * @return 1-100% */ @Override public int getSpeed() { if (manager == null) return -1; return manager.getSpeed(); }
@Override public void forward(int speed) { if (manager != null) manager.forward(speed); }
@Override public void backward() { if (manager != null) manager.backward(); }
@Override public void reset() { if (manager != null) manager.reset(); }
@Override public void forward() { if (manager != null) manager.forward(); }
@Override public void takeOff() { if (manager != null) manager.takeOff(); }
@Override public void landing() { if (manager != null) manager.landing(); }
@Override public void toggleCamera() { if (manager != null) manager.toggleCamera(); }
@Override public void goLeft() { if (manager != null) manager.goLeft(); }
@Override public void backward(int speed) { if (manager != null) manager.backward(speed); }
@Override public void goLeft(int speed) { if (manager != null) manager.goLeft(speed); }
@Override public void setHorizontalCamera() { if (manager != null) manager.setHorizontalCamera(); }
@Override public void stop() { if (manager != null) manager.stop(); }
@Override public void spinLeft(int speed) { if (manager != null) manager.spinLeft(speed); }
@Override public void setMinAltitude(int altitude) { if (manager != null) manager.setMinAltitude(altitude); }
@Override public void up() { if (manager != null) manager.up(); }
@Override public void spinLeft() { if (manager != null) manager.spinLeft(); }
@Override public void setVerticalCamera() { if (manager != null) manager.setVerticalCamera(); }