Ejemplo n.º 1
0
 private void ReceiverOnWebSocketStateChanged(object sender, EventArgs eventArgs)
 {
     if (_receiver.WebsocketReady)
     {
         RunOnUiThread(() => _websocketTextView.SetBackgroundColor(new Color(0, 255, 0)));
     }
     else
     {
         RunOnUiThread(() => _websocketTextView.SetBackgroundColor(new Color(255, 0, 0)));
         _client.Hover();
     }
 }
Ejemplo n.º 2
0
 private void Joystick_InputReceived(object sender, JoystickEventArgs e)
 {
     if (e.Button == 0 && e.IsPressed) // Front button
     {
         drone.Hover();
     }
     else if (e.Button == 1 && e.IsPressed) // Pad-2 button
     {
         drone.Emergency();
     }
     else if (e.Button == 2 && e.IsPressed) // Pad-3 button
     {
         drone.Takeoff();
     }
     else if (e.Button == 4 && e.IsPressed) // Pad-5 button
     {
         drone.Land();
     }
     else if (e.Button == 9 && e.IsPressed)      // Throttle-10 button
     {
         heightMaintainer.TargetHeight += 0.25f; // meter
     }
     else if (e.Button == 10 && e.IsPressed)     // Throttle-11 button
     {
         heightMaintainer.TargetHeight -= 0.25f; // meter
     }
 }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            var droneClient = new DroneClient("192.168.1.1");

            SleepAndPaint(droneClient);

            droneClient.Start();

            SleepAndPaint(droneClient);

            droneClient.Takeoff();

            SleepAndPaint(droneClient);


            droneClient.Progress(FlightMode.Progressive, yaw: -0.05f);

            System.Console.WriteLine("Yaw -0.05");
            SleepAndPaint(droneClient);

            droneClient.Hover();
            SleepAndPaint(droneClient);

            droneClient.Land();

            SleepAndPaint(droneClient);

            droneClient.Stop();

            SleepAndPaint(droneClient);

            System.Console.ReadLine();

            droneClient.Dispose();
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Allows the drone to hover
 /// </summary>
 /// <returns>Boolean Value whether the command works properly</returns>
 public bool Hover()
 {
     try
     {
         _client.Hover();
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Ejemplo n.º 5
0
        private void CommandReceiverOnCommandReceived(object sender, CommandEventArgs eventArgs)
        {
            switch (eventArgs.Command)
            {
            case "takeoff":
                _client.Takeoff();
                break;

            case "land":
                _client.Land();
                break;

            case "hover":
                _client.Hover();
                break;

            case "up":
                _client.Progress(FlightMode.Progressive, gaz: 0.25f);
                break;

            case "turnleft":
                _client.Progress(FlightMode.Progressive, yaw: 0.25f);
                break;

            case "forward":
                _client.Progress(FlightMode.Progressive, pitch: -0.05f);
                break;

            case "turnright":
                _client.Progress(FlightMode.Progressive, yaw: -0.25f);
                break;

            case "down":
                _client.Progress(FlightMode.Progressive, gaz: -0.25f);
                break;

            case "lLeft":
                _client.Progress(FlightMode.Progressive, yaw: 0.25f);
                break;

            case "right":
                _client.Progress(FlightMode.Progressive, roll: 0.05f);
                break;

            case "back":
                _client.Progress(FlightMode.Progressive, pitch: 0.05f);
                break;

            default:
                Debug.WriteLine("Unknown Command: " + eventArgs.Command);
                break;
            }
        }
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
 private void btnHover_Click(object sender, EventArgs e)
 {
     _droneClient.Hover();
 }
Ejemplo n.º 8
0
 public void Hover()
 {
     _droneClient.Hover();
 }
Ejemplo n.º 9
0
        void DroneControl(object sender)
        {
            int  expiration = Properties.Settings.Default.AutoPilotExpiration;
            bool useQ       = Properties.Settings.Default.UseAutoPilot;

            _autopilot.Active = useQ;

            float _lrfb = Properties.Settings.Default.DefaultLRFBSpeed;
            float _yaw  = Properties.Settings.Default.DefaultYawSpeed;
            float _gaz  = Properties.Settings.Default.DefaultGazSpeed;

            #region // engine
            if (sender == "v")
            {
                _droneClient.FlatTrim();
                _autopilot.ClearObjectives();

                _droneClient.Takeoff();
            }
            ;
            if (sender == "n")
            {
                _autopilot.ClearObjectives();
                _droneClient.Emergency();
            }
            ;
            if (sender == "m")
            {
                _droneClient.ResetEmergency();
            }
            ;
            if (sender == "b")
            {
                _autopilot.ClearObjectives();
                _droneClient.Land();
            }
            ;
            #endregion

            _autopilot.Active = true;

            // navigation
            #region left right up down and hover
            //if (sender == btnLeft || sender == btnRight)
            //{
            //    if (useQ)
            //    {
            //        _autopilot.EnqueueObjective(Objective.Create(expiration, new SetRoll(
            //            (sender == btnLeft ? -_lrfb : _lrfb)
            //        )));
            //    }
            //    else
            //    {
            //        _droneClient.Progress(FlightMode.Progressive,
            //            roll: (sender == btnLeft ? -_lrfb : _lrfb)
            //        );
            //    }
            //}

            if (sender == "a")
            {
                if (useQ)
                {
                    _autopilot.EnqueueObjective(Objective.Create(expiration, new SetRoll(-_lrfb)));
                }
                else
                {
                    _droneClient.Progress(FlightMode.Progressive, roll: -_lrfb);
                }
            }
            ;
            if (sender == "d")
            {
                if (useQ)
                {
                    _autopilot.EnqueueObjective(Objective.Create(expiration, new SetRoll(_lrfb)));
                }
                else
                {
                    _droneClient.Progress(FlightMode.Progressive, roll: _lrfb);
                }
            }
            ;
            if (sender == "w")
            {
                if (useQ)
                {
                    _autopilot.EnqueueObjective(Objective.Create(expiration, new SetPitch(-_lrfb)));
                }
                else
                {
                    _droneClient.Progress(FlightMode.Progressive, pitch: -_lrfb);
                }
            }
            ;
            if (sender == "s")
            {
                if (useQ)
                {
                    _autopilot.EnqueueObjective(Objective.Create(expiration, new SetPitch(_lrfb)));
                }
                else
                {
                    _droneClient.Progress(FlightMode.Progressive, pitch: _lrfb);
                }
            }
            ;

            if (sender == "x")
            {
                if (useQ)
                {
                    _autopilot.EnqueueObjective(
                        Objective.Create(expiration,
                                         new VelocityX(0.0f),
                                         new VelocityY(0.0f),
                                         new Altitude(1.0f)
                                         ));
                }
                else
                {
                    _droneClient.Hover();
                }
            }
            #endregion

            #region yaw left and right
            if (sender == "j")
            {
                if (useQ)
                {
                    _autopilot.EnqueueObjective(Objective.Create(expiration, new SetYaw(-_yaw)));
                }
                else
                {
                    _droneClient.Progress(FlightMode.Progressive, yaw: -_yaw);
                }
            }
            ;
            if (sender == "l")
            {
                if (useQ)
                {
                    _autopilot.EnqueueObjective(Objective.Create(expiration, new SetYaw(_yaw)));
                }
                else
                {
                    _droneClient.Progress(FlightMode.Progressive, yaw: _yaw);
                }
            }
            ;
            #endregion

            #region gaz up and down
            if (sender == "i")
            {
                if (useQ)
                {
                    _autopilot.EnqueueObjective(Objective.Create(expiration, new SetGaz(_gaz)));
                }
                else
                {
                    _droneClient.Progress(FlightMode.Progressive, gaz: _gaz);
                }
                //_droneClient.Hover();
            }
            ;
            if (sender == "k")
            {
                if (useQ)
                {
                    _autopilot.EnqueueObjective(Objective.Create(expiration, new SetGaz(-_gaz)));
                }
                else
                {
                    _droneClient.Progress(FlightMode.Progressive, gaz: -_gaz);
                }
            }
            ;
            #endregion
        }
Ejemplo n.º 10
0
 public void Hover()
 {
     _client.Hover();
 }
Ejemplo n.º 11
0
 private void hover()
 {
     droneClient.Hover();
 }