Ejemplo n.º 1
0
 @Override
 public void attitudeUpdated(float pitch, float roll, float yaw) {
   pitch = pitch / 1000;
   roll = roll / 1000;
   yaw = yaw / 1000;
   if (attitude != null) attitude.setAttitude(pitch, roll, yaw);
 }
Ejemplo n.º 2
0
  public CCPanel(final ARDrone ardrone) {
    super(new GridBagLayout());

    setBackground(Color.BLUE);
    video = new VideoPanel(ardrone);
    battery = new BatteryPanel();
    state = new StatePanel();
    attitude = new AttitudePanel();

    add(
        video,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            0.7,
            1,
            GridBagConstraints.FIRST_LINE_START,
            GridBagConstraints.BOTH,
            new Insets(0, 0, 0, 0),
            0,
            0));
    add(
        new JScrollPane(state),
        new GridBagConstraints(
            1,
            0,
            1,
            2,
            0.3,
            1,
            GridBagConstraints.FIRST_LINE_START,
            GridBagConstraints.VERTICAL,
            new Insets(0, 0, 0, 0),
            0,
            0));

    add(
        attitude.getPane(),
        new GridBagConstraints(
            0,
            1,
            1,
            1,
            1,
            1,
            GridBagConstraints.FIRST_LINE_START,
            GridBagConstraints.BOTH,
            new Insets(0, 0, 0, 0),
            0,
            0));
    // add(battery, new GridBagConstraints(0, 1, 1, 1, 1, 1,
    // GridBagConstraints.FIRST_LINE_START, GridBagConstraints.BOTH, new
    // Insets(0,0,0,0), 0, 0));

    // CommandManager handles (keyboard) input and dispatches events to the
    // drone
    System.out.println("CCPanel.KeyEventDispatcher: grab the whole keyboard input from now on ...");
    KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager();
    manager.addKeyEventDispatcher(
        new KeyEventDispatcher() {

          private KeyboardCommandManager cmdManager = new KeyboardCommandManager(ardrone, 45);

          public boolean dispatchKeyEvent(KeyEvent e) {
            if (e.getID() == KeyEvent.KEY_PRESSED) {
              cmdManager.keyPressed(e);
            } else if (e.getID() == KeyEvent.KEY_RELEASED) {
              cmdManager.keyReleased(e);
            }
            return true;
          }
        });

    VideoManager vm = ardrone.getVideoManager();
    vm.setImageListener(this);
    NavDataManager m = ardrone.getNavDataManager();
    m.setStateListener(this);
    m.setAttitudeListener(this);
    m.setBatteryListener(this);
  }