Beispiel #1
0
    // Update is called once per frame
    void Update()
    {
        positionData.update();

        transform.localPosition = positionData.GetPosition();
        transform.localRotation = Quaternion.Euler(positionData.GetRotation());

        float groundAltitude = positionData.getGroundAltitude();

        float droneAltitude = transform.localPosition.y;

        //Debug.Log("ground: " + groundAltitude +  drone: "+ droneAltitude + "m, height: "+ (droneAltitude- groundAltitude) + "m, distance: " + positionData.GetHomeDistance()+"m");

        heightText.text = "Height: " + droneAltitude.ToString("F1") + "m a.s.l.     Ground height: " + (droneAltitude - groundAltitude).ToString("F1") + "m     Horizonal distance: " + positionData.GetHomeDistance().ToString("F1") + "m";

        videoObjects.transform.localRotation = Quaternion.Euler(positionData.GetCameraRotation());
        droneCamera.transform.localRotation  = Quaternion.Euler(positionData.GetCameraRotation());

        droneModel.transform.localRotation = Quaternion.Euler(positionData.GetPitchRoll() + new Vector3(0, 90, 0));

        //vypíšeme hlášku o připojení k ROSbridge
        if (rosConnector != null)
        {
            int state = rosConnector.GetComponent <MyRosConnector>().ConnectionState;
            if (state == 1)
            {
                ConnectorText.text = "Connected";
            }
            else if (state == 2)
            {
                ConnectorText.text = "Problematic";
            }
            else if (state == 3)
            {
                ConnectorText.text = "Cennection lost" +
                                     "" +
                                     "" +
                                     "" +
                                     "";
            }
            else if (state == 0)
            {
                ConnectorText.text = "Connecting...";
            }
            else
            {
                ConnectorText.text = "Disonnected";
            }
        }


        if (rosConnector != null)
        {
            rosConnector.GetComponent <IDroneImageSubscriber>().OptimalizeForProjector = isProjectorActive;
        }
    }
    // Update is called once per frame
    void Update()
    {
        positionData.update();

        transform.localPosition = positionData.GetPosition();
        transform.localRotation = Quaternion.Euler(positionData.GetRotation());

        float groundAltitude = positionData.getGroundAltitude();

        float droneAltitude = transform.localPosition.y;

        //Debug.Log("ground: " + groundAltitude +  drone: "+ droneAltitude + "m, height: "+ (droneAltitude- groundAltitude) + "m, distance: " + positionData.GetHomeDistance()+"m");

        heightText.text = "Height: " + droneAltitude.ToString("F1") + "m a.s.l.     Ground height: " + (droneAltitude - groundAltitude).ToString("F1") + "m     Horizonal distance: " + positionData.GetHomeDistance().ToString("F1") + "m";

        videoObjects.transform.localRotation = Quaternion.Euler(positionData.GetCameraRotation());
        droneCamera.transform.localRotation  = Quaternion.Euler(positionData.GetCameraRotation());

        droneModel.transform.localRotation = Quaternion.Euler(positionData.GetPitchRoll() + new Vector3(0, 90, 0));

        //vypíšeme hlášku o připojení k ROSbridge
        if (rosConnector != null)
        {
            int state = rosConnector.GetComponent <MyRosConnector>().ConnectionState;
            if (state == 1)
            {
                ConnectorText.text = "Connected";
            }
            else if (state == 2)
            {
                ConnectorText.text = "Problematic";
            }
            else if (state == 3)
            {
                ConnectorText.text = "Connection lost" +
                                     "" +
                                     "" +
                                     "" +
                                     "";
            }
            else if (state == 0)
            {
                ConnectorText.text = "Connecting...";
            }
            else
            {
                ConnectorText.text = "Disonnected";
            }
        }


        if (rosConnector != null)
        {
            rosConnector.GetComponent <IDroneImageSubscriber>().OptimalizeForProjector = isProjectorActive;
        }


        if (nextUpdate > droneUpdateInterval)
        {
            nextUpdate = 0f;
            Vector2d latitudelongitude = Map.WorldToGeoPosition(transform.localPosition);
            Vector3  rotation          = positionData.GetPitchRoll();
            drone.FlightData.SetData(droneAltitude, latitudelongitude.x, latitudelongitude.y, pitch: rotation.x, roll: rotation.z, yaw: rotation.y + 90f, positionData.GetRotation().y);
            WebSocketManager.Instance.SendDataToServer(JsonUtility.ToJson(drone.FlightData), logInfo: false);
        }
        nextUpdate += Time.deltaTime;
    }