コード例 #1
0
 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();
     }
 }
コード例 #2
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();
     }
 }
コード例 #3
0
        public void RunFrame()
        {
            connectionState = Tello.connectionState;
            //Frame info
            telloFrameCount++;
            timeSinceLastUpdate = Time.time - prevDeltaTime;
            prevDeltaTime       = Time.time;
            var deltaTime1 = (int)(timeSinceLastUpdate * 1000);

            telloDeltaTime = new System.TimeSpan(0, 0, 0, 0, (deltaTime1));
            //inputs
            var  inputs        = inputController.CheckFlightInputs();
            bool receivedInput = true;

            if (inputs.w == 0 & inputs.x == 0 & inputs.y == 0 & inputs.z == 0)
            {
                receivedInput = false;
            }
            if (receivedInput & autoPilot.enabled)
            {
                Debug.Log("AutoPilot disabled due to user input");
                ToggleAutoPilot(false);
            }
            //if we are flying the tello
            if (sceneType != SceneType.SimOnly)
            {
                switch (flightStatus)
                {
                case FlightStatus.Launching:
                    telloManager.CheckForLaunchComplete();
                    break;

                case FlightStatus.Flying:
                    bool validFrame = telloManager.SetTelloPosition();
                    if (!validFrame & autoPilot.enabled)
                    {
                        Debug.Log("AutoPilot disabled because Tello Lost Tracking");
                        ToggleAutoPilot(false);
                    }
                    break;
                }
            }
            if (autoPilot.enabled)
            {
                inputs = autoPilot.RunAutoPilot(telloDeltaTime);
            }
            finalInputs = CalulateFinalInputs(inputs.x, inputs.y, inputs.z, inputs.w);
            yaw         = finalInputs.x;
            elv         = finalInputs.y;
            roll        = finalInputs.z;
            pitch       = finalInputs.w;
        }
コード例 #4
0
        public void RunFrame()
        {
            connectionState = Tello.connectionState;
            //Frame info
            telloFrameCount++;
            timeSinceLastUpdate = Time.time - prevDeltaTime;
            prevDeltaTime       = Time.time;
            var deltaTime1 = (int)(timeSinceLastUpdate * 1000);

            telloDeltaTime = new System.TimeSpan(0, 0, 0, 0, (deltaTime1));
            //inputs
            var  inputs        = inputController.CheckFlightInputs();
            bool receivedInput = true;

            if (inputs.w == 0 & inputs.x == 0 & inputs.y == 0 & inputs.z == 0)
            {
                receivedInput = false;
            }
            if (receivedInput & autoPilot.enabled)
            {
                Debug.Log("AutoPilot disabled due to user input");
                ToggleAutoPilot(false);
            }
            //if we are flying the tello
            if (sceneType != SceneType.SimOnly)
            {
                switch (flightStatus)
                {
                case FlightStatus.Launching:
                    telloManager.CheckForLaunchComplete();
                    break;

                case FlightStatus.Flying:
                    bool validFrame = telloManager.SetTelloPosition();
                    if (!validFrame & autoPilot.enabled)
                    {
                        Debug.Log("AutoPilot disabled because Tello Lost Tracking");
                        ToggleAutoPilot(false);
                    }
                    break;
                }
            }
            if (autoPilot.enabled)
            {
                inputs = autoPilot.RunAutoPilot(telloDeltaTime);
            }
            finalInputs = CalulateFinalInputs(inputs.x, inputs.y, inputs.z, inputs.w);
            yaw         = finalInputs.x;
            elv         = finalInputs.y;
            roll        = finalInputs.z;
            pitch       = finalInputs.w;

            //yaw = inputs.x;
            //elv = inputs.y;
            //roll = inputs.z;
            //pitch = inputs.w;

            //switch (sceneType)
            //{
            //    case SceneType.FlyOnly:
            //        telloManager.SendTelloInputs(finalInputs);
            //        break;
            //    case SceneType.SimOnly:

            //        break;
            //}

            //if()

            //if (Input.GetKeyDown(KeyCode.Q))
            //{
            //    inputController.ToggleAutoPilot(!inputController.autoPilotActive);
            //}
            //if (Input.GetKeyDown(KeyCode.E))
            //{
            //    inputController.BeginFlightPath(FindObjectOfType<FlightPath>());
            //}

            //if (Tello.connected & sceneType != SceneType.SimOnly)
            //{
            //    if (Input.GetKeyDown(KeyCode.T))
            //    {
            //        telloManager.OnTakeOff();
            //    }
            //    else if (Input.GetKeyDown(KeyCode.V))
            //    {
            //        telloManager.StartProps();
            //    }
            //    else if (Input.GetKeyDown(KeyCode.L))
            //    {
            //        telloManager.OnLand();
            //    }
            //    else if (Input.GetKeyDown(KeyCode.Joystick1Button0) || Input.GetKeyDown(KeyCode.Space))
            //        BeginTracking();

            //    telloManager.CustomUpdate();
            //}
            //if (sceneType != SceneType.FlyOnly)
            //{
            //    simulator.CustomUpdate();
            //}
        }