private void Update()
    {
        if (!mainSystem.IsFinishReadConfig())
        {
            return;
        }
        else
        {
            if (!finish_set_address)
            {
                ws = new WebSocket(mainSystem.GetConfig().ros_ip);
                //open message
                ws.OnOpen += (sender, e) => {
                    Debug.Log("*********** Websocket connected ***********");
                    conneciton_state = wscCONST.STATE_CONNECTED;
                };
                //close message
                ws.OnClose += (sender, e) => {
                    Debug.Log("*********** Websocket disconnected ***********");
                    conneciton_state = wscCONST.STATE_DISCONNECTED;
                };
                //error message
                ws.OnError += (sender, e) => {
                    Debug.Log("Error : " + e.Message);
                    conneciton_state = wscCONST.STATE_ERROR;
                };
                OnMessage();

                finish_set_address = true;
                Debug.Log("OK ROS_IP");

                Connect();
            }
        }
    }
Ejemplo n.º 2
0
 // Update is called once per frame
 void Update()
 {
     if (!Main.IsFinishReadConfig())
     {
         return;
     }
     else
     {
         if (!finish_setup)
         {
             SetupWebSocket();
             Connect();
         }
     }
 }
    // Update is called once per frame
    void Update()
    {
        if (!mainSystem.IsFinishReadConfig())
        {
            return;
        }

        if (wsc.conneciton_state == wscCONST.STATE_DISCONNECTED)           //切断時
        {
            time_access += Time.deltaTime;
            if (time_access > 5.0f)
            {
                time_access = 0.0f;
                wsc.Connect();
            }
        }

        if (wsc.conneciton_state == wscCONST.STATE_CONNECTED)           //接続時
        {
            if (!success_access || !abort_access)
            {
                //Vehicle
                if (wait_VehicleState)
                {
                    WaitResponce(0.5f);
                }
                if (wait_VehiclePos)
                {
                    WaitResponce(0.5f);
                }
                if (wait_VehicleStop)
                {
                    WaitResponce(1.0f);
                }
                if (wait_VehicleMove)
                {
                    WaitResponce(1.0f);
                }

                //Right Arm
                if (wait_RightArmPower)
                {
                    WaitResponce(0.5f);
                }
                if (wait_RightArmServo)
                {
                    WaitResponce(0.5f);
                }
                if (wait_RightArmState)
                {
                    WaitResponce(0.5f);
                }
                if (wait_RightArmPos)
                {
                    WaitResponce(0.5f);
                }
                if (wait_RightArmStop)
                {
                    WaitResponce(1.0f);
                }
                if (wait_RightArmReset)
                {
                    WaitResponce(1.0f);
                }
                if (wait_RightArmMove)
                {
                    WaitResponce(1.0f);
                }
                if (wait_RightArmClearAlarm)
                {
                    WaitResponce(1.0f);
                }

                //Left Arm
                if (wait_LeftArmPower)
                {
                    WaitResponce(0.5f);
                }
                if (wait_LeftArmServo)
                {
                    WaitResponce(0.5f);
                }
                if (wait_LeftArmState)
                {
                    WaitResponce(0.5f);
                }
                if (wait_LeftArmPos)
                {
                    WaitResponce(0.5f);
                }
                if (wait_LeftArmStop)
                {
                    WaitResponce(1.0f);
                }
                if (wait_LeftArmReset)
                {
                    WaitResponce(1.0f);
                }
                if (wait_LeftArmMove)
                {
                    WaitResponce(1.0f);
                }
                if (wait_LeftArmClearAlarm)
                {
                    WaitResponce(1.0f);
                }

                //Right Gripper
                if (wait_RightGripperState)
                {
                    WaitResponce(0.5f);
                }
                if (wait_RightGripperPos)
                {
                    WaitResponce(0.5f);
                }
                if (wait_RightGripperStop)
                {
                    WaitResponce(1.0f);
                }
                if (wait_RightGripperMove)
                {
                    WaitResponce(1.0f);
                }

                //Left Gripper
                if (wait_LeftGripperState)
                {
                    WaitResponce(0.5f);
                }
                if (wait_LeftGripperPos)
                {
                    WaitResponce(0.5f);
                }
                if (wait_LeftGripperStop)
                {
                    WaitResponce(1.0f);
                }
                if (wait_LeftGripperMove)
                {
                    WaitResponce(1.0f);
                }
            }
        }
    }