예제 #1
0
 void Awake()
 {
     if (!active)
     {
         enabled = false;
         return;
     }
     init = false;
     ROSController.StartROS(OnRosInit);
 }
예제 #2
0
    void Start()
    {
//		forward = target.Forward;
        if (ROSController.instance != null)
        {
            ROSController.StartROS(OnRosInit);
        }
//		if ( ModeController.isTrainingMode )
        cam.cullingMask |= pathMask.value;
//		else
//			cam.cullingMask &= ~pathMask.value;
    }
예제 #3
0
    public void ConnectToRobot(string robotName)
    {
        Robots[robotName].Connected = true;
        Robots[robotName].RosBridge.Connect();
        Robot         robot         = Robots[robotName];
        GameObject    robotObject   = Instantiate(Resources.Load(_robotPrefabPath + robot.Name)) as GameObject;
        ROSController rosController = robotObject.GetComponent <ROSController>();

        rosController.InitialiseRobot(robot.RosBridge, robot.RobotConfig, robotName);
        ActiveRobots.Add(robotName, rosController);

        PlayerUIController.Instance.AddRobotToList(robot.Name);
    }
예제 #4
0
    public ROSController GetRosControllerFromName(string robotName)
    {
        ROSController rosController = null;

        if (ActiveRobots.TryGetValue(robotName, out rosController))
        {
            return(rosController);
        }
        else
        {
            return(null);
        }
    }
    void Awake()
    {
        if (instance != null && instance != this)
        {
            Debug.LogError("Too many ROSControllers! Only one must exist.");
            Destroy(gameObject);
            return;
        }

        GetConfigFile();

        Debug.LogWarning("Main thread ID " + System.Threading.Thread.CurrentThread.ManagedThreadId);

        status = ROSStatus.Disconnected;

//		Application.targetFrameRate = 0;
        if (QualitySettings.vSyncCount == 2)
        {
            Application.targetFrameRate = 30;
        }
        else
        {
            Application.targetFrameRate = 60;
        }

//		Debug.Log ( "ros master is " + ROS.ROS_MASTER_URI );
        if ((string.IsNullOrEmpty(Environment.GetEnvironmentVariable("ROS_MASTER_URI", EnvironmentVariableTarget.User)) &&
             string.IsNullOrEmpty(Environment.GetEnvironmentVariable("ROS_MASTER_URI", EnvironmentVariableTarget.Machine))) || overrideURI)
        {
            ROS.ROS_MASTER_URI = rosMasterURI;
        }

        if (overrideIP)
        {
            if (rosIP == "0.0.0.0")
            {
                Debug.LogError("host IP is set to override but address is set to 0.0.0.0");
            }
            else
            {
                ROS.ROS_IP = rosIP;
            }
        }

//			delayedStart = true;
        instance     = this;
        initComplete = false;
        StartROS();
        new Thread(new ThreadStart(UpdateMasterConnection)).Start();
    }
예제 #6
0
    public void DisconnectAllRobots()
    {
        foreach (KeyValuePair <string, Robot> pair in Robots)
        {
            ROSController rosController = null;
            pair.Value.Connected = false;

            if (ActiveRobots.TryGetValue(pair.Key, out rosController))
            {
                ActiveRobots[pair.Key].Destroy();
                ActiveRobots.Remove(pair.Key);
            }
        }
    }
예제 #7
0
 private void CleanUpDisconnectedRobot(ROSController robot)
 {
     Debug.LogError("Robot [" + robot.gameObject.name + "] lost connection!");
     DisconnectRobot(robot.RobotName);
     PlayerUIController.Instance.UpdateRobotList();
     PlayerUIController.Instance.RobotWasDisconnected(Robots[robot.RobotName]);
     if (ActiveRobots.Count > 0)
     {
         SelectRobot(ActiveRobots.First().Value);
     }
     else
     {
         WaypointController.Instance.ClearAllWaypoints();
     }
 }
예제 #8
0
    private void OnRobotDebugListValueChanged(int newIndex)
    {
        if (_oldDebugRobotSelection != null)
        {
            _oldDebugRobotSelection.UnsubscribeToRobotLogsUpdate(OnReceivedRobotLog);
        }

        string        selectedRobot = _robotDebugSelectRobot.options[newIndex].text;
        ROSController robot         = RobotMasterController.Instance.GetRosControllerFromName(selectedRobot);

        if (robot != null)
        {
            InitialiseRobotDebugPanel(robot.GetRobotLogs());
            robot.SubscribeToRobotLogsUpdate(OnReceivedRobotLog);
            _oldDebugRobotSelection = robot;
        }
    }
예제 #9
0
    private void OnSelectedRobotValueChanged(int newIndex)
    {
        ROSController selectedRobot = RobotMasterController.Instance.GetRosControllerFromName(_selectRobot.options[newIndex].text);

        UpdateUI(selectedRobot);
        RobotMasterController.Instance.SelectRobot(selectedRobot);

        if (CurrentUIState != UIState.RobotDebug)
        {
            if (_oldSelectRobotSelection != null)
            {
                _oldSelectRobotSelection.UnsubscribeToRobotLogsUpdate(OnReceivedRobotLog);
            }
            if (selectedRobot != null)
            {
                selectedRobot.SubscribeToRobotLogsUpdate(OnReceivedRobotLog);
            }
        }
        _oldSelectRobotSelection = selectedRobot;
    }
예제 #10
0
    public void SelectRobot(ROSController rosController)
    {
        if (SelectedRobot != null)
        {
            SelectedRobot.OnDeselected();
        }

        if (rosController == null)
        {
            SelectedRobot = null;
            WaypointController.Instance.ClearAllWaypoints();
        }
        else
        {
            SelectedRobot = rosController;
            SelectedRobot.OnSelected();
            PlayerController.Instance.FocusCameraOn(SelectedRobot.transform);
        }
        PlayerUIController.Instance.UpdateUI(rosController);
    }
예제 #11
0
 public void UpdateUI(ROSController robot)
 {
     if (robot == null)
     {
         CurrentRobotDrivingUIState = RobotDrivingUIState.NoRobotSelected;
         WaypointController.Instance.ClearAllWaypoints();
         _overrideRobotPosition.interactable = false;
         _clearAllWaypoints.interactable     = false;
         _routeName.interactable             = false;
         _loadRoute.interactable             = false;
         _saveRoute.interactable             = false;
         _resetRobot.interactable            = false;
     }
     else
     {
         _overrideRobotPosition.interactable = true;
         _clearAllWaypoints.interactable     = true;
         _routeName.interactable             = true;
         _resetRobot.interactable            = true;
         if (robot.CurrenLocomotionType == ROSController.RobotLocomotionType.DIRECT)
         {
             CurrentRobotDrivingUIState = RobotDrivingUIState.RobotStopped;
         }
         else
         {
             if (robot.CurrentRobotLocomotionState == ROSController.RobotLocomotionState.MOVING)
             {
                 CurrentRobotDrivingUIState = RobotDrivingUIState.RobotDriving;
             }
             else if (robot.CurrentRobotLocomotionState == ROSController.RobotLocomotionState.STOPPED)
             {
                 CurrentRobotDrivingUIState = RobotDrivingUIState.RobotStopped;
             }
         }
     }
 }
 void Start()
 {
     ROSController.StartROS(OnRosInit);
 }
 public void OnExitButton()
 {
             #if !UNITY_EDITOR
     ROSController.StopROS(new System.Action(() => { Application.Quit(); }));
             #endif
 }
예제 #14
0
 void Awake()
 {
     ROSController.StartROS(OnRosInit);
 }
예제 #15
0
 public void RobotLostConnection(ROSController robot)
 {
     _hasRobotLostConnection = true;
     _robotLostConnection    = robot;
 }