コード例 #1
0
    // Update is called once per frame and is used to display the point cloud sent by the robot
    void Update()
    {
        // Update the point cloud mesh to display the most recent aligned point cloud sent by the robot side
        Vector3[] newPointCloudVertices;
        bool      isAvailable = internalPointCloudQueue.TryDequeue(out newPointCloudVertices);

        TimeSpan currentTime = Timer.SampleCurrentStopwatch();
        TimeSpan elapsedRobotPointCloudReceived = currentTime - lastTimeRobotPointCloudReceived;

        if (isAvailable)
        {
            lastTimeRobotPointCloudReceived = currentTime;
            UpdatePointCloudMesh(ref newPointCloudVertices);
            isShowingRobotLostTrackingMessage = false;
        }
        else if (elapsedRobotPointCloudReceived.TotalSeconds > thresholdRobotLostTrackingMessage)
        {
            thresholdRobotLostTrackingMessage = 15;
            isRobotPointCloudGameObjectActive = false;
            robotTargetFlag.SetActive(false);
            robotPointCloudGameObject.SetActive(isRobotPointCloudGameObjectActive);
            if (!isShowingRobotLostTrackingMessage)
            {
                isShowingRobotLostTrackingMessage = true;
                string userMessage = "You are not receiving any new point clouds from the robot. Please try to move robot around using the virtual joystick!";
                userMessageManager.ShowUserMessage(userMessage, 999f);
            }
        }
    }