Ejemplo n.º 1
0
        void GestureDetection_LeftHandBackForwardsChanged(object sender, HandPositionChangedArgs args)
        {
            switch (args.Position)
            {
            case HandPosition.Center:
                break;

            case HandPosition.Backwards:
                if (isLanded)
                {
                    _client.FlatTrim();
                }
                DroneCommandChanged(_client, new DroneCommandChangedEventArgs {
                    CommandText = "Flat Trim "
                });
                break;

            case HandPosition.Forwards:
                _client.Hover();
                DroneCommandChanged(_client, new DroneCommandChangedEventArgs {
                    CommandText = "Hover"
                });
                break;
            }
        }
Ejemplo n.º 2
0
 private void DroneTakeOff()
 {
     droneClient.FlatTrim();//before take off send this command
     headPositionStart = OculusClient.GetOrientation();
     if (lastCommandSent != CommandType.TakeOff)
     {
         droneClient.Takeoff();
         lastCommandSent = CommandType.TakeOff;
     }
 }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            DroneClient drone = new DroneClient();

            drone.NavigationDataAcquired += HandleNavigationDataAcquired;

            JoystickFlightController controller = new JoystickFlightController();

            controller.Client = drone;
            drone.Start();
            drone.FlatTrim();
            controller.Start();
        }
Ejemplo n.º 4
0
        public MainForm()
        {
            InitializeComponent();

            // innitialize video packet decoder.
            videoDecoder = new VideoPacketDecoderWorker(PixelFormat.BGR24, true, OnFrameDecoded);
            videoDecoder.UnhandledException += VideoDecoder_UnhandledException;
            videoDecoder.Start();

            // Initalize drone.
            drone = new DroneClient();
            drone.VideoPacketAcquired += OnVideoPacketAqcuired;
            drone.Start();
            drone.ResetEmergency();
            drone.FlatTrim();


            JoystickFlightController controller = new JoystickFlightController();

            controller.Client = drone;
            controller.Start();

            /*
             * // Initialize joystick.
             * joystick = new JoystickDevice();
             * joystick.InputReceived += Joystick_InputReceived;
             * joystick.Initialize("/dev/input/js0");
             *
             * // Initialize height maintainer.
             * heightMaintainer = new HeightMaintainer();
             *          heightMaintainer.TargetHeight = 0.25f; //meter
             *
             * // Initialize velocity maintainer.
             * velocityMaintainer = new VelocityMaintainer();
             *          velocityMaintainer.TargetVelocity.Forward = -1.0f;
             * velocityMaintainer.TargetVelocity.Left = 0.0f;
             * velocityMaintainer.TargetVelocity.TurnLeft = 0.0f;
             *
             * // Initialize flight controller.
             * controller = new CompositeFlightController();
             * controller.Drone = drone;
             * controller.FlightBehaviors.Add(velocityMaintainer);
             * controller.FlightBehaviors.Add(heightMaintainer);
             *          controller.FlightBehaviors.Add(new JoystickBehavior(joystick));
             * controller.ControlCycleStarting += () => joystick.ProcessEvents();
             *
             * controller.Start();
             */

            videoTimer.Enabled = true;
        }
Ejemplo n.º 5
0
        static void ConnectDrone()
        {
            Console.WriteLine("Connecting to drone... ");
            drone = new DroneClient();
            drone.Start();
            Thread.Sleep(2000);
            Console.WriteLine("Done connecting to drone...");
            drone.ResetEmergency();
            drone.FlatTrim();

            if (args.Contains("--enable-video"))
            {
                StartVideo(drone);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Sends the command with its parameters to a provided DroneClient
        /// </summary>
        /// <param name="aDroneClient">Drone client to the the command to</param>
        public void Send(DroneClient aDroneClient)
        {
            switch (Command)
            {
            case Type.Progress: aDroneClient.Progress(ProgressMode, roll: Roll, pitch: Pitch, yaw: Yaw, gaz: Gaz); break;

            case Type.Takeoff: aDroneClient.Takeoff(); break;

            case Type.Hover: aDroneClient.Hover(); break;

            case Type.Land: aDroneClient.Land(); break;

            case Type.Emergency: aDroneClient.Emergency(); break;

            case Type.ResetEmergency: aDroneClient.ResetEmergency(); break;

            case Type.FlatTrim: aDroneClient.FlatTrim(); break;
            }
        }
Ejemplo n.º 7
0
    /// <summary>
    /// Use this for initialization
    /// </summary>
    void Start()
    {
        Debug.Log("Start DroneObserver");
        // initialize data array
        data          = new byte[width * height * 3];
        cameraTexture = new Texture2D(width, height);
        // Initialize drone
        videoPacketDecoderWorker = new VideoPacketDecoderWorker(PixelFormat.RGB24, true, OnVideoPacketDecoded);
        videoPacketDecoderWorker.Start();

        droneClient = new DroneClient("192.168.1.1");
        //droneClient = new DroneClient ("127.0.0.1");
        droneClient.UnhandledException     += HandleUnhandledException;
        droneClient.VideoPacketAcquired    += OnVideoPacketAcquired;
        droneClient.NavigationDataAcquired += navData => navigationData = navData;

        droneClient.FlatTrim();

        videoPacketDecoderWorker.UnhandledException += HandleUnhandledException;
        droneClient.Start();

        Settings settings = new Settings();

        settings.Video.Codec = VideoCodecType.H264_720P;
        droneClient.Send(settings);
        droneClient.AckControlAndWaitForConfirmation();

        switchDroneCamera(AR.Drone.Client.Configuration.VideoChannelType.Horizontal);

        isDroneConnected = droneClient.IsConnected;

        if (!isDroneConnected)
        {
            Debug.LogError("Drone not Connected. Retry!!!");
        }
        if (isDroneConnected)
        {
            Debug.LogWarning("Drone Connected!!!");
        }

        // determine connection
        wlanClient = new WlanClient();
    }
Ejemplo n.º 8
0
 private void btnFlatTrim_Click(object sender, EventArgs e)
 {
     _droneClient.FlatTrim();
 }
Ejemplo n.º 9
0
 public void FlatTrim()
 {
     _droneClient.FlatTrim();
 }
Ejemplo n.º 10
0
 private void FlatTrim_Click(object sender, RoutedEventArgs e)
 {
     droneClient.FlatTrim();
 }
Ejemplo n.º 11
0
        public void Configure(DroneConfiguration droneConfiguration)
        {
            Task <Settings> configurationTask = droneClient.GetConfigurationTask();

            configurationTask.ContinueWith(
                delegate(Task <Settings> task)
            {
                if (task.Exception != null)
                {
                    Trace.TraceWarning("Get configuration task is faulted with exception: {0}",
                                       task.Exception.InnerException.Message);
                    return;
                }

                settings = task.Result;
            });
            configurationTask.Start();

            var sendConfigTask = new Task(() =>
            {
                if (settings == null)
                {
                    settings = new Settings();
                }

                if (string.IsNullOrEmpty(settings.Custom.SessionId) ||
                    settings.Custom.SessionId == "00000000")
                {
                    // set new session, application and profile
                    droneClient.AckControlAndWaitForConfirmation(); // wait for the control confirmation

                    settings.Custom.SessionId = Settings.NewId();
                    droneClient.Send(settings);

                    droneClient.AckControlAndWaitForConfirmation();

                    settings.Custom.ProfileId = Settings.NewId();
                    droneClient.Send(settings);

                    droneClient.AckControlAndWaitForConfirmation();

                    settings.Custom.ApplicationId = Settings.NewId();
                    droneClient.Send(settings);

                    droneClient.AckControlAndWaitForConfirmation();
                }

                settings.General.NavdataDemo    = false;
                settings.General.NavdataOptions = NavdataOptions.All;

                //settings.Video.BitrateCtrlMode = VideoBitrateControlMode.Dynamic;
                settings.Video.Bitrate    = 1000;
                settings.Video.MaxBitrate = 2000;

                settings.Leds.LedAnimation       = new LedAnimation(LedAnimationType.BlinkGreenRed, 2.0f, 2);
                settings.Control.FlightAnimation = new FlightAnimation(FlightAnimationType.Wave);


                //start
                settings.Userbox.Command = new UserboxCommand(UserboxCommandType.Start);
                //stop
                settings.Userbox.Command = new UserboxCommand(UserboxCommandType.Stop);

                //send all changes in one pice
                droneClient.Send(settings);

                droneClient.FlatTrim(); // calibrates the drone on flat surface
            });

            sendConfigTask.Start();
        }
Ejemplo n.º 12
0
        public void KeyBoardKeyPressed(object sender, TextCompositionEventArgs e)
        {
            string chr = e.Text;

            switch (chr)
            {
            case "a":     // left
                DroneControl("a");
                break;

            case "d":     // right
                DroneControl("d");
                break;

            case "w":     // forward
                DroneControl("w");
                break;

            case "s":     // backward
                DroneControl("s");
                break;

            case "j":     // yaw left
                DroneControl("j");
                break;

            case "l":     // yaw right
                DroneControl("l");
                break;

            case "i":     // gaz up
                DroneControl("i");
                break;

            case "k":     // gaz down
                DroneControl("k");
                break;

            case "x":     // hover
                DroneControl("x");
                break;

            case "v":     // start engine
                Debug("Starting engine");
                DroneControl("v");
                break;

            case "b":     // land
                Debug("Landing");
                DroneControl("b");
                break;

            case "n":     // emegency landing
                Debug("Emergency landing");
                DroneControl("n");
                break;

            case "m":     // reset
                Debug("Resetting drone");
                DroneControl("m");
                break;

            case "f":     // flat trim
                Debug("Calibrate ground");
                _droneClient.FlatTrim();
                break;
            }
            ;

            //Debug(chr);
        }
Ejemplo n.º 13
0
 public void Start()
 {
     _client.Start();
     _client.FlatTrim();
 }