private void Update()
        {
            if (Input.GetKeyDown("space") && On)
            {
                var p = QueryJsonFactory.MakeQueryJson("visual-detection");

                GcsSocket.Emit("gcs-query-received", p);
            }

            ;
        }
Пример #2
0
        public static void StopMission()
        {
            if (!GcsSocket.Alive)
            {
                Debug.Log("Error: Socket connection could not be established.");
                SceneFlowController.LoadErrorScene();
            }

            GcsSocket.Emit(STOP_MISSION,
                           ParticipantBehavior.Participant.CurrentMission);
        }
Пример #3
0
        public static void StartMission()
        {
            if (!GcsSocket.Alive)
            {
                Debug.Log("Error: Socket connection could not be established.");
                SceneFlowController.LoadErrorScene();
            }

            GcsSocket.Emit(START_MISSION,
                           ParticipantBehavior.Participant.CurrentMission);
            Started = true;
            Lifecycle.EventManager.OnStarted();
        }
Пример #4
0
        /// <summary>
        /// Starts the initialization process for a mission.
        /// </summary>
        public static void InitializeMission()
        {
            if (!GcsSocket.Alive)
            {
                Debug.Log("Error: Socket connection could not be established.");
                SceneFlowController.LoadErrorScene();
            }
            ;

            var initializeMissionParameters = string.Format("mission{0}-{1}-{2}-{3}",
                                                            ParticipantBehavior.Participant.CurrentMission,
                                                            ParticipantBehavior.Participant.Data.Adaptive ? "true" : "false",
                                                            ParticipantBehavior.Participant.Data.Id,
                                                            ParticipantBehavior.Participant.Data.Transparent ? "true" : "false");

            Debug.Log("Initializing Mission.  Parameters: " + initializeMissionParameters);

            GcsSocket.Emit(INITIALIZE_MISSION, initializeMissionParameters);

            Lifecycle.EventManager.OnInitialize(ParticipantBehavior.Participant.CurrentMission);
        }
Пример #5
0
        // Extremely important to disconnect from ROS. OTherwise packets continue to flow.
        private void OnApplicationQuit()
        {
            if (_ros != null)
            {
                _ros.Disconnect();
            }
            if (_ros1 != null)
            {
                _ros1.Disconnect();
            }
            if (_ros4 != null)
            {
                _ros4.Disconnect();
            }

            if (Isbot1.isOn && flag1 == false)
            {
                GcsSocket.Emit(ServerURL.TOGGLE_MANUAL_CONTROL,
                               1);
            }
            if (Isbot2.isOn && flag2 == false)
            {
                GcsSocket.Emit(ServerURL.TOGGLE_MANUAL_CONTROL,
                               1);
            }
            if (Isbot3.isOn && flag3 == false)
            {
                GcsSocket.Emit(ServerURL.TOGGLE_MANUAL_CONTROL,
                               1);
            }
            if (Isbot4.isOn && flag4 == false)
            {
                GcsSocket.Emit(ServerURL.TOGGLE_MANUAL_CONTROL,
                               1);
            }
        }
Пример #6
0
        /*
         * private void OnDestroy()
         * {
         *  if (Isbot1.isOn && flag1 == false)
         *      GcsSocket.Emit(GcsSocket.TOGGLE_MANUAL_CONTROL, 1);
         *  if (Isbot2.isOn && flag2 == false)
         *      GcsSocket.Emit(GcsSocket.TOGGLE_MANUAL_CONTROL, 1);
         *  if (Isbot3.isOn && flag3 == false)
         *      GcsSocket.Emit(GcsSocket.TOGGLE_MANUAL_CONTROL, 1);
         *  if (Isbot4.isOn && flag4 == false)
         *      GcsSocket.Emit(GcsSocket.TOGGLE_MANUAL_CONTROL, 1);
         * }
         */

        private void ActiveToggle()
        {
            if (Isbot1.isOn)
            {
                _topic = "/robot1/cmd_vel";
                _ros   = _ros1;
                GcsSocket.Emit(ServerURL.TOGGLE_MANUAL_CONTROL,
                               1);
                flag1 = false;
            }
            else if (Isbot2.isOn)
            {
                _topic = "/robot2/cmd_vel";
                _ros   = _ros1;
                GcsSocket.Emit(ServerURL.TOGGLE_MANUAL_CONTROL,
                               2);
                flag2 = false;
            }
            else if (Isbot3.isOn)
            {
                _topic = "/robot3/cmd_vel";
                _ros   = _ros4;
                GcsSocket.Emit(ServerURL.TOGGLE_MANUAL_CONTROL,
                               3);
                flag3 = false;
            }
            else if (Isbot4.isOn)
            {
                _topic = "/robot4/cmd_vel";
                _ros   = _ros4;
                GcsSocket.Emit(ServerURL.TOGGLE_MANUAL_CONTROL,
                               4);
                flag4 = false;
            }

            // turn waypoints back on
            if (!Isbot1.isOn && flag1 == false)
            {
                GcsSocket.Emit(ServerURL.TOGGLE_MANUAL_CONTROL,
                               1);
                flag1 = true;
            }
            else if (!Isbot2.isOn && flag2 == false)
            {
                GcsSocket.Emit(ServerURL.TOGGLE_MANUAL_CONTROL,
                               2);
                flag2 = true;
            }
            else if (!Isbot3.isOn && flag3 == false)
            {
                GcsSocket.Emit(ServerURL.TOGGLE_MANUAL_CONTROL,
                               3);
                flag3 = true;
            }
            else if (!Isbot4.isOn && flag4 == false)
            {
                GcsSocket.Emit(ServerURL.TOGGLE_MANUAL_CONTROL,
                               4);
                flag4 = true;
            }


            //TODO

            /*
             * if (CurrentRobot == robotId)
             * {
             * _topic = "";
             * CurrentRobot = -1;
             * GcsSocket.Emit(ServerURL.TOGGLE_MANUAL_CONTROL, CurrentRobot);
             * Debug.Log(robotId);
             * Debug.Log(CurrentRobot);
             * Debug.Log(_topic);
             * Debug.Log(_ros);
             * return;
             * }
             *
             *
             * // The current robot cannot be equal to robotID because of the statement above.
             * // If there is a robot selected, turn off manual control
             * if (CurrentRobot <= 1)
             * {
             * GcsSocket.Emit(ServerURL.TOGGLE_MANUAL_CONTROL, CurrentRobot);
             * }
             *
             * CurrentRobot = robotId;
             * GcsSocket.Emit(ServerURL.TOGGLE_MANUAL_CONTROL, CurrentRobot);
             * _topic = string.Format("/robot{0}/cmd_vel", CurrentRobot);
             * _ros = _ros4;
             *
             * Debug.Log(robotId);
             * Debug.Log(CurrentRobot);
             * Debug.Log(_topic);
             * Debug.Log(_ros);*/
        }