public void CustomOnApplicationQuit()
 {
     Tello.onConnection -= Tello_onConnection;
     Tello.onUpdate     -= Tello_onUpdate;
     Tello.onVideoData  -= Tello_onVideoData;
     Tello.stopConnecting();
 }
Ejemplo n.º 2
0
        public basic_gui()
        {
            this.KeyPreview = true;
            InitializeComponent();

            //subscribe to Tello connection events
            Tello.onConnection += (Tello.ConnectionState newState) =>
            {
                if (newState != Tello.ConnectionState.Connected)
                {
                    Console.WriteLine("Tello Disconnected");
                }
                if (newState == Tello.ConnectionState.Connected)
                {
                    Tello.queryAttAngle();
                    Tello.setMaxHeight(50);
                }
            };

            //subscribe to Tello update events.
            Tello.onUpdate += (cmdId) =>
            {
                if (cmdId == 86)//ac update
                {
                    Console.WriteLine("Tello updated");
                }
            };

            Tello.startConnecting(IP);//Start trying to connect.
            while (Tello.connected)
            {
                // send back connecting message
                Console.WriteLine("Tello connected");
            }
        }
Ejemplo n.º 3
0
        public Form1()
        {
            InitializeComponent();


            Tello.onConnection += (Tello.ConnectionState newState) =>
            {
                if (newState != Tello.ConnectionState.Connected)
                {
                }
                if (newState == Tello.ConnectionState.Connected)
                {
                    Tello.setMaxHeight(5);
                }
                label1.Text = ("Tello " + newState.ToString());
            };
            Tello.startConnecting();

            var videoClient = UdpUser.ConnectTo("127.0.0.1", 7038);

            Tello.onVideoData += (byte[] data) =>
            {
                try
                {
                    videoClient.Send(data.Skip(2).ToArray());//Skip 2 byte header and send to ffplay.
                    //droneStream.StartPlay(new Uri("udp://127.0.0.1:7038"));
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error in Video Feed: " + ex.ToString());
                }
            };

            droneStream.StartPlay(new Uri("udp://127.0.0.1:7038"));
        }
Ejemplo n.º 4
0
        public override bool OnKeyUp(Keycode keyCode, KeyEvent e)
        {
            InputDevice device = e.Device;

            if (device != null && device.Id == current_device_id)
            {
                int index = ButtonMapping.OrdinalValue(keyCode);
                if (index >= 0)
                {
                    buttons[index] = 0;
                    if (index == 7)
                    {
                        Tello.takeOff();
                    }
                    if (index == 6)
                    {
                        Tello.land();
                    }
                    axes[4] = buttons[5];
                    Tello.setAxis(axes);

                    //controller_view.Invalidate();
                }
                return(true);
            }
            return(base.OnKeyUp(keyCode, e));
        }
Ejemplo n.º 5
0
        //Handle joystick axis events.
        public override bool OnGenericMotionEvent(MotionEvent e)
        {
            InputDevice device = e.Device;

            if (device != null && device.Id == current_device_id)
            {
                if (IsGamepad(device))
                {
                    for (int i = 0; i < AxesMapping.size; i++)
                    {
                        axes[i] = GetCenteredAxis(e, device, AxesMapping.OrdinalValueAxis(i));
                    }
                    axes[4] = buttons[5];//boost button.
                    Tello.setAxis(axes);
                    TextView joystat = FindViewById <TextView>(Resource.Id.joystick_state);

                    //var dataStr = string.Join(" ", buttons);
                    //joystat.Text = string.Format("JOY {0: 0.00;-0.00} {1: 0.00;-0.00} {2: 0.00;-0.00} {3: 0.00;-0.00} {4: 0.00;-0.00} BTN "+ dataStr , axes[0], axes[1], axes[2], axes[3], axes[4]);

                    //controller_view.Invalidate();
                    return(true);
                }
            }
            return(base.OnGenericMotionEvent(e));
        }
Ejemplo n.º 6
0
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Return))
        {
            if (Tello.state.flying)
            {
                Debug.Log("Landing");
                Tello.Land();
            }
            else
            {
                if (Tello.state.batteryLower)
                {
                    Debug.LogError("Battery too low for take off");
                    return;
                }

                if (Tello.state.batteryLow)
                {
                    Debug.LogWarning("Battery low");
                }

                Debug.Log("Taking off");
                Tello.TakeOff();
            }
        }

        if (Tello.ConnectionState == ConnectionState.Connected && Tello.state.flying)
        {
            Tello.controllerState.SetAxis(Input.GetAxis("Rotate") * droneSpeed / 100, Input.GetAxis("Levitate") * droneSpeed / 100, Input.GetAxis("LRTranslate") * droneSpeed / 100, Input.GetAxis("FBTranslate") * droneSpeed / 100);
            Tello.SetMaxHeight(height);
        }
    }
Ejemplo n.º 7
0
        public FlightPlan_gui()
        {
            InitializeComponent();
            input.AutoCompleteCustomSource = suggestedInstructions;

            //subscribe to Tello connection events
            Tello.onConnection += (Tello.ConnectionState newState) =>
            {
                if (newState != Tello.ConnectionState.Connected)
                {
                    //Console.WriteLine("Tello Disconnected");
                }
                if (newState == Tello.ConnectionState.Connected)
                {
                    Tello.queryAttAngle();
                    Tello.setMaxHeight(50);
                }
            };

            //subscribe to Tello update events.
            Tello.onUpdate += (cmdId) =>
            {
                if (cmdId == 86)//ac update
                {
                    //Console.WriteLine("Tello updated");
                }
            };

            Tello.startConnecting(IP);//Start trying to connect.
            while (Tello.connected)
            {
                // send back connecting message
                //Console.WriteLine("Tello connected");
            }
        }
 public void ConnectToTello()
 {
     Tello.onConnection += Tello_onConnection;
     Tello.onUpdate     += Tello_onUpdate;
     Tello.onVideoData  += Tello_onVideoData;
     Tello.startConnecting();
 }
        public MainPageViewModel(Action <Exception, string> errorLog, Action <string, IDictionary <string, string> > logger)
        {
            _logger = logger;
            _tello  = new Tello(false, false, errorLog);

            IncreaseAltitudeCommand = new Xamarin.Forms.Command(_ => IncreateMaxAltitude(), _ => CanIncreaseMaxAltitude);
            DecreaseAltitudeCommand = new Xamarin.Forms.Command(_ => DecreateMaxAltitude(), _ => CanDecreaseMaxAltitude);
        }
 public void OnLand()
 {
     Debug.Log("Land");
     Tello.land();
     sceneManager.flightStatus = SceneManager.FlightStatus.Landing;
     transform.position        = new Vector3(transform.position.x, 0, transform.position.z);
     CreateFlightPoint();
 }
Ejemplo n.º 11
0
 public MainForm()
 {
     InitializeComponent();
     _stickSamplier     = new StickSamplier(25);
     _teleSamplier      = new TelemetrySamplier();
     _vs                = new VideoSamplier(25);
     _tello             = new Tello();
     _tello.LogMessage += _tello_MessageReceived;
 }
Ejemplo n.º 12
0
    private void Start()
    {
        if (telloVideoTexture == null)
        {
            telloVideoTexture = FindObjectOfType <TelloVideoTexture>();
        }

        Tello.StartConnecting();
    }
Ejemplo n.º 13
0
        public override bool OnKeyDown(Keycode keyCode, KeyEvent e)
        {
            InputDevice device = e.Device;

            if (device != null && device.Id == current_device_id)
            {
                if (IsGamepad(device))
                {
                    if (keyCode == Preferences.takeoffButtonCode && e.RepeatCount == 7)
                    {
                        if (Tello.connected && !Tello.state.flying)
                        {
                            Tello.takeOff();
                        }
                        else if (Tello.connected && Tello.state.flying)
                        {
                            Tello.land();
                        }
                        return(true);
                    }
                    if (keyCode == Preferences.landButtonCode && e.RepeatCount == 7)
                    {
                        Tello.land();
                        return(true);
                    }
                    if (keyCode == Preferences.pictureButtonCode && e.RepeatCount == 0)
                    {
                        Tello.takePicture();
                        cameraShutterSound.Play();
                        return(true);
                    }
                    ;
                    if (keyCode == Preferences.recButtonCode && e.RepeatCount == 0)
                    {
                        toggleRecording = true;
                        return(true);
                    }
                    ;
                    //controller_view.Invalidate();
                    if (keyCode == Preferences.speedButtonCode)
                    {
                        Tello.controllerState.setSpeedMode(1);
                        Tello.sendControllerUpdate();
                        return(true);
                    }

                    //if joy button return handled.
                    if (keyCode >= Keycode.ButtonA && keyCode <= Keycode.ButtonMode)
                    {
                        return(true);
                    }
                    ;
                }
            }
            return(base.OnKeyDown(keyCode, e));
        }
 private void Tello_onConnection(Tello.ConnectionState newState)
 {
     if (newState == Tello.ConnectionState.Connected)
     {
         Debug.Log("Connected to Tello, please wait for camera feed");
         Tello.setPicVidMode(1); // 0: picture, 1: video
         Tello.setVideoBitRate((int)TelloController.VideoBitRate.VideoBitRateAuto);
         Tello.requestIframe();
     }
 }
Ejemplo n.º 15
0
        protected override void OnResume()
        {
            isPaused = false;
            base.OnResume();
            input_manager.RegisterInputDeviceListener(this, null);
            updateOnScreenJoyVisibility();
            //fix if joy was moved when paused.
            onScreenJoyL.returnHandleToCenter();
            onScreenJoyR.returnHandleToCenter();

            Tello.connectionSetPause(false);//reanable connections if paused.
        }
Ejemplo n.º 16
0
 private void Tello_onConnection(Tello.ConnectionState newState)
 {
     //throw new System.NotImplementedException();
     //Debug.Log("Tello_onConnection : " + newState);
     if (newState == Tello.ConnectionState.Connected)
     {
         Tello.setPicVidMode(1);             // 0: picture, 1: video
         Tello.setVideoBitRate((int)Tello.VideoBitRate.VideoBitRateAuto);
         //Tello.setEV(0);
         Tello.requestIframe();
     }
 }
        //This is called when you press 'T'
        public void AutoTakeOff()
        {
            Debug.Log("TakeOff!");
            var preFlightPanel = GameObject.Find("Pre Flight Panel");

            if (preFlightPanel)
            {
                preFlightPanel.SetActive(false);
            }
            Tello.takeOff();
            sceneManager.flightStatus = SceneManager.FlightStatus.Launching;
        }
Ejemplo n.º 18
0
        public CaduhdAppTests()
        {
            string ip   = "127.0.0.1";
            int    port = 8889;

            this.tello = new Tello(ip, port);

            this.udpClient = new UdpClient(new IPEndPoint(IPAddress.Parse(ip), port));
            this.udpClient.Client.ReceiveTimeout = 1000;

            this.anyEndPoint = new IPEndPoint(IPAddress.Any, 0);
        }
Ejemplo n.º 19
0
 private void connect_Click(object sender, RoutedEventArgs e)
 {
     if (connect.Content.ToString() == "Connect")
     {
         Tello.startConnecting();
         connect.Content = "Disconnect";
     }
     else
     {
         connect.Content = "Connect";
     }
 }
Ejemplo n.º 20
0
    private void Start()
    {
        if (telloVideoTexture == null)
        {
            telloVideoTexture = FindObjectOfType <TelloVideoTexture>();
        }

        Tello.startConnecting();

        //バーチャルドローンの初期位置指定
        Drone_Yup_Virtual.transform.position = new Vector3(0, 1.1f, 0);
    }
Ejemplo n.º 21
0
        async public void TestTello()
        {
            WifiHelper = new WifiHelper("TELLO-C53FBC", "SFR_6A30");

            Debug.WriteLine("Connecting to Tello network...");
            await WifiHelper.ConnectToTelloWifi();

            Tello = new Tello();

            Tello.CommunicationManager.ConnectionStatusHandler += ConnectionStatusHandler;

            Tello.FlightManager.Start();
        }
Ejemplo n.º 22
0
        public void OnTouchJoystickMoved(JoystickView joystickView)
        {
            if (isPaused)//Zero out any movement when paused.
            {
                Tello.controllerState.setAxis(0, 0, 0, 0);
            }
            else
            {
                Tello.controllerState.setAxis(onScreenJoyL.normalizedX, -onScreenJoyL.normalizedY, onScreenJoyR.normalizedX, -onScreenJoyR.normalizedY);
            }

            Tello.sendControllerUpdate();
        }
Ejemplo n.º 23
0
        protected override void OnPause()
        {
            //fix if joy was moved when paused.
            onScreenJoyL.returnHandleToCenter();
            onScreenJoyR.returnHandleToCenter();

            //Zero out Joy input so we don't keep flying.
            Tello.controllerState.setAxis(0, 0, 0, 0);
            Tello.sendControllerUpdate();

            isPaused = true;
            base.OnPause();
            input_manager.UnregisterInputDeviceListener(this);
        }
Ejemplo n.º 24
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.T))
        {
            Tello.takeOff();
        }
        else if (Input.GetKeyDown(KeyCode.L))
        {
            Tello.land();
        }

        float lx = 0f;
        float ly = 0f;
        float rx = 0f;
        float ry = 0f;

        if (Input.GetKey(KeyCode.UpArrow))
        {
            ry = 1;
        }
        if (Input.GetKey(KeyCode.DownArrow))
        {
            ry = -1;
        }
        if (Input.GetKey(KeyCode.RightArrow))
        {
            rx = 1;
        }
        if (Input.GetKey(KeyCode.LeftArrow))
        {
            rx = -1;
        }
        if (Input.GetKey(KeyCode.W))
        {
            ly = 1;
        }
        if (Input.GetKey(KeyCode.S))
        {
            ly = -1;
        }
        if (Input.GetKey(KeyCode.D))
        {
            lx = 1;
        }
        if (Input.GetKey(KeyCode.A))
        {
            lx = -1;
        }
        Tello.controllerState.setAxis(lx, ly, rx, ry);
    }
Ejemplo n.º 25
0
        public override bool OnKeyUp(Keycode keyCode, KeyEvent e)
        {
            InputDevice device = e.Device;

            if (device != null && device.Id == current_device_id)
            {
                if (keyCode == Preferences.speedButtonCode)
                {
                    Tello.controllerState.setSpeedMode(0);
                    Tello.sendControllerUpdate();
                    return(true);
                }
            }
            return(base.OnKeyUp(keyCode, e));
        }
Ejemplo n.º 26
0
        private void handleAutopilot()
        {
            if (bAutopilot && Tello.state.flying)
            {
                var eular = Tello.state.toEuler();
                var yaw   = eular[2];

                var deltaPosX   = autopilotTarget.X - Tello.state.posX;
                var deltaPosY   = autopilotTarget.Y - Tello.state.posY;
                var dist        = Math.Sqrt(deltaPosX * deltaPosX + deltaPosY * deltaPosY);
                var normalizedX = deltaPosX / dist;
                var normalizedY = deltaPosY / dist;

                var targetYaw = Math.Atan2(normalizedY, normalizedX);
                var deltaYaw  = targetYaw - yaw;

                double lx = 0, ly = 0, rx = 0, ry = 0;

                var minYaw  = 0.1;   //Radians
                var minDist = 0.125; //Meters (I think)
                if (deltaYaw > minYaw)
                {
                    //lx = Math.Max(0.7, deltaYaw / 10.0);
                }
                else if (deltaYaw < -minYaw)
                {
                    //lx = -Math.Max(0.7, deltaYaw / 10.0);
                }
                //else
                if (dist > minDist)
                {
                    var speed = Math.Min(0.3, dist * 2);//0.2 limits max throttle for safety.
                    rx = speed * Math.Sin(deltaYaw);
                    ry = speed * Math.Cos(deltaYaw);
                }
                else
                {
                    bAutopilot = false;//arrived
                }

                Tello.controllerState.setAxis((float)lx, (float)ly, (float)rx, (float)ry);
                Tello.sendControllerUpdate();
            }
        }
Ejemplo n.º 27
0
        public override bool OnKeyDown(Keycode keyCode, KeyEvent e)
        {
            InputDevice device = e.Device;

            if (device != null && device.Id == current_device_id)
            {
                if (IsGamepad(device))
                {
                    int index = ButtonMapping.OrdinalValue(keyCode);
                    if (index >= 0)
                    {
                        buttons[index] = 1;
                        //controller_view.Invalidate();
                        axes[4] = buttons[5];
                        Tello.setAxis(axes);
                    }
                    return(true);
                }
            }
            return(base.OnKeyDown(keyCode, e));
        }
Ejemplo n.º 28
0
        static void Main(string[] args)
        {
            //subscribe to Tello connection events
            Tello.onConnection += (Tello.ConnectionState newState) =>
            {
                if (newState == Tello.ConnectionState.Connected)
                {
                    //When connected update maxHeight to 5 meters
                    Tello.setMaxHeight(5);
                }
                //Show connection messages.
                Console.WriteLine("Tello " + newState.ToString());
            };

            //subscribe to Tello update events. Called when update data arrives from drone.
            Tello.onUpdate += (int cmdId) =>
            {
                if (cmdId == 86)//ac update
                {
                    Console.WriteLine("FlyMode:" + Tello.state.flyMode + " Height:" + Tello.state.height);
                }
            };

            Tello.startConnecting();//Start trying to connect.

            var str = "";

            while (str != "exit")
            {
                str = Console.ReadLine().ToLower();
                if (str == "takeoff" && Tello.connected && !Tello.state.flying)
                {
                    Tello.takeOff();
                }
                if (str == "land" && Tello.connected && Tello.state.flying)
                {
                    Tello.land();
                }
            }
        }
Ejemplo n.º 29
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MainViewModel"/> class.
        /// </summary>
        public MainViewModel()
        {
            var handsAnalyzer        = new HandsAnalyzer();
            var skiColorHandDetector = new SkinColorHandsDetector();

            var drone = new Tello();
            var droneControllerKeyInputEvaluator   = new TelloKeyInputEvaluator();
            var droneControllerHandsInputEvaluator = new DroneControllerHandsInputEvaluator();

            this.app = new CaduhdApp(handsAnalyzer,
                                     skiColorHandDetector,
                                     drone,
                                     droneControllerKeyInputEvaluator,
                                     droneControllerHandsInputEvaluator);

            this.app.Bind(this.UserInterfaceConnector);

            this.webCamera           = new WebCamera(320, 180);
            this.webCamera.NewFrame += this.ProcessWebCameraFrame;
            this.webCamera.On();
            this.keyEventProcessor = new KeyEventProcessor();
        }
        public void PrimeProps()
        {
            Debug.Log("Start Prop");
            sceneManager.flightStatus = SceneManager.FlightStatus.PrimingProps;
            Tello.SuspendControllerUpdate();
            int i = 0;

            do
            {
                i++;
                Tello.StartMotors();
            } while (i < 900);
            // OnFlyBegin();
            Tello.ResumeControllerUpdate();
            var preFlightPanel = GameObject.Find("Pre Flight Panel");

            if (preFlightPanel)
            {
                preFlightPanel.SetActive(false);
            }
            sceneManager.flightStatus = SceneManager.FlightStatus.Launching;
            UnityEngine.Debug.Log("props started");
        }