Esempio n. 1
0
 @Override
 public void disconnect() {
   stop();
   landing();
   manager.close();
   if (videoManager != null) videoManager.close();
   if (navdataManager != null) navdataManager.close();
 }
Esempio n. 2
0
 /** 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);
    }
  }
Esempio n. 4
0
 @Override
 public void down(int speed) {
   if (manager != null) manager.down(speed);
 }
Esempio n. 5
0
 @Override
 public void up(int speed) {
   if (manager != null) manager.up(speed);
 }
Esempio n. 6
0
 @Override
 public void down() {
   if (manager != null) manager.down();
 }
Esempio n. 7
0
 @Override
 public void move3D(int speedX, int speedY, int speedZ, int speedSpin) {
   if (manager != null) manager.move3D(speedX, speedY, speedZ, speedSpin);
 }
Esempio n. 8
0
 @Override
 public void setVerticalCameraWithHorizontal() {
   if (manager != null) manager.setVerticalCameraWithHorizontal();
 }
Esempio n. 9
0
 @Override
 public void setSpeed(int speed) {
   if (manager != null) manager.setSpeed(speed);
 }
Esempio n. 10
0
 /**
  * 0.01-1.0 -> 1-100%
  *
  * @return 1-100%
  */
 @Override
 public int getSpeed() {
   if (manager == null) return -1;
   return manager.getSpeed();
 }
Esempio n. 11
0
 @Override
 public void forward(int speed) {
   if (manager != null) manager.forward(speed);
 }
Esempio n. 12
0
 @Override
 public void backward() {
   if (manager != null) manager.backward();
 }
Esempio n. 13
0
 @Override
 public void reset() {
   if (manager != null) manager.reset();
 }
Esempio n. 14
0
 @Override
 public void forward() {
   if (manager != null) manager.forward();
 }
Esempio n. 15
0
 @Override
 public void takeOff() {
   if (manager != null) manager.takeOff();
 }
Esempio n. 16
0
 @Override
 public void landing() {
   if (manager != null) manager.landing();
 }
Esempio n. 17
0
 @Override
 public void toggleCamera() {
   if (manager != null) manager.toggleCamera();
 }
Esempio n. 18
0
 @Override
 public void goLeft() {
   if (manager != null) manager.goLeft();
 }
Esempio n. 19
0
 @Override
 public void backward(int speed) {
   if (manager != null) manager.backward(speed);
 }
Esempio n. 20
0
 @Override
 public void goLeft(int speed) {
   if (manager != null) manager.goLeft(speed);
 }
Esempio n. 21
0
 @Override
 public void setHorizontalCamera() {
   if (manager != null) manager.setHorizontalCamera();
 }
Esempio n. 22
0
 @Override
 public void stop() {
   if (manager != null) manager.stop();
 }
Esempio n. 23
0
 @Override
 public void spinLeft(int speed) {
   if (manager != null) manager.spinLeft(speed);
 }
Esempio n. 24
0
 @Override
 public void setMinAltitude(int altitude) {
   if (manager != null) manager.setMinAltitude(altitude);
 }
Esempio n. 25
0
 @Override
 public void up() {
   if (manager != null) manager.up();
 }
Esempio n. 26
0
 @Override
 public void spinLeft() {
   if (manager != null) manager.spinLeft();
 }
Esempio n. 27
0
 @Override
 public void setVerticalCamera() {
   if (manager != null) manager.setVerticalCamera();
 }