Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        RBS.Messages.std_msgs.Float32 msg = new RBS.Messages.std_msgs.Float32();
        msg.data = (float)(10000 * pathNum) + (float)markers.Count;
        if (RBSocket.Instance.IsConnected)
        {
            debugPub.publish(msg);
        }

        // 現在のpath数がマーカーの数より少ないとき
        if (pathNum <= markers.Count)
        {
            // マーカーの位置を更新
            for (int i = 0; i < pathNum; i++)
            {
                if (!markers[i].activeInHierarchy)
                {
                    markers[i].SetActive(true);
                }
                markers[i].transform.position = new Vector3((float)-path[i].position.y,
                                                            (float)path[i].position.z + 0.1f,
                                                            (float)path[i].position.x);
            }
            // 現在のパーティクル数以上のマーカーは非表示
            for (int i = pathNum; i < markers.Count; i++)
            {
                if (markers[i].activeInHierarchy)
                {
                    markers[i].SetActive(false);
                }
            }
        }
        // 現在のpath数がパーティクル数がマーカーの数より多いとき
        else
        {
            // マーカーの位置を更新
            for (int i = 0; i < markers.Count; i++)
            {
                if (!markers[i].activeInHierarchy)
                {
                    markers[i].SetActive(true);
                }
                markers[i].transform.position = new Vector3((float)-path[i].position.y,
                                                            0.1f,
                                                            (float)path[i].position.x);
            }
            // 最新のパーティクル数がマーカーより多かったらマーカー生成
            for (int i = markers.Count; i < pathNum; i++)
            {
                markers.Add(Instantiate <GameObject>(pathPrefab,
                                                     new Vector3((float)-path[i].position.y,
                                                                 0.1f,
                                                                 (float)path[i].position.x),
                                                     Quaternion.identity));
            }
        }
    }
Ejemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        RBS.Messages.std_msgs.Float32 msg = new RBS.Messages.std_msgs.Float32();
        msg.data = (float)(0);

        //GameObject generateRobotAnchor = GameObject.Find("GenerateRobotAnchor");

        //if (robotScript.isDetected)
        //{
        Vector3 position = new Vector3((float)-pose.position.y,
                                       (float)pose.position.z,
                                       (float)pose.position.x);
        Quaternion rotation = new Quaternion((float)-pose.orientation.y,
                                             (float)pose.orientation.z,
                                             (float)pose.orientation.x,
                                             (float)-pose.orientation.w);

        // マーカーが生成されていなかったら生成
        if (marker == null)
        {
            marker = Instantiate <GameObject>(footPrefab, position, rotation);
        }
        // マーカーが生成されていたら位置を更新
        else
        {
            marker.transform.position = position;
            marker.transform.rotation = rotation;
        }
        msg.data = (float)(1);
        //robotScript.isDetected = false;
        //}
        if (RBSocket.Instance.IsConnected)
        {
            debugPub.publish(msg);
        }
    }