private void ImportAssets() { // setup Urdf Transfer UrdfTransferFromRos urdfTransfer = new UrdfTransferFromRos(rosSocket, assetPath, urdfParameter); StatusEvents["robotNameReceived"] = urdfTransfer.Status["robotNameReceived"]; StatusEvents["robotDescriptionReceived"] = urdfTransfer.Status["robotDescriptionReceived"]; StatusEvents["resourceFilesReceived"] = urdfTransfer.Status["resourceFilesReceived"]; urdfTransfer.Transfer(); if (StatusEvents["robotNameReceived"].WaitOne(timeout * 1000)) { robotName = urdfTransfer.RobotName; localDirectory = urdfTransfer.LocalUrdfDirectory; } // import URDF assets: if (StatusEvents["resourceFilesReceived"].WaitOne(timeout * 1000)) { UnityEngine.Debug.Log("Imported urdf resources to " + localDirectory); } else { UnityEngine.Debug.LogWarning("Not all resource files have been received before timeout."); } rosSocket.Close(); }
private void ImportAssets() { // setup urdfImporter UrdfImporter urdfImporter = new UrdfImporter(rosSocket, assetPath, robotDescriptionParamName); StatusEvents["robotNameReceived"] = urdfImporter.Status["robotNameReceived"]; StatusEvents["robotDescriptionReceived"] = urdfImporter.Status["robotDescriptionReceived"]; StatusEvents["resourceFilesReceived"] = urdfImporter.Status["resourceFilesReceived"]; urdfImporter.Import(); if (StatusEvents["robotNameReceived"].WaitOne(timeout * 1000)) { robotName = urdfImporter.RobotName; localDirectory = urdfImporter.LocalDirectory; } // import URDF assets: if (StatusEvents["resourceFilesReceived"].WaitOne(timeout * 1000)) { Debug.Log("Imported urdf resources to " + urdfImporter.LocalDirectory); } else { Debug.LogWarning("Not all resource files have been received before timeout."); } rosSocket.Close(); }
public void Close() { closed = true; if (RosSocket != null) { RosSocket.protocol.OnClosed -= OnClosed; RosSocket.Close(); } }
private void OnClosed(object sender, EventArgs e) { IsConnected.Reset(); Debug.Log("Disconnected from RosBridge: " + RosBridgeServerUrl); RosSocket.Close(); RosSocket = null; SocketThread.Join(); SocketThread = new Thread(ConnectAndWait); SocketThread.Start(); }
private void OnApplicationQuit() { if (RosSocket != null) { RosSocket.Close(); } // Necessary as this is also our flag to stop running threads RosSocket = null; if (SocketThread != null) { SocketThread.Join((int)(SecondsTimeout * 1000)); } }
private void TransferAsync(Protocols.Protocol protocolType, string serverUrl, int timeout, string urdfPath, string rosPackage, RosSocket.SerializerEnum serializer) { RosSocket = RosConnector.ConnectToRos(protocolType, serverUrl, OnConnected, OnClose, serializer); if (!StatusEvents["connected"].WaitOne(timeout * 1000)) { Debug.LogWarning("Failed to connect to " + serverUrl + " before timeout."); RosSocket.Close(); return; } string robotName = Path.GetFileName(urdfPath); UrdfTransferToRos urdfTransferToRos = new UrdfTransferToRos(RosSocket, robotName, urdfPath, rosPackage); StatusEvents["robotNamePublished"] = urdfTransferToRos.Status["robotNamePublished"]; StatusEvents["robotDescriptionPublished"] = urdfTransferToRos.Status["robotDescriptionPublished"]; StatusEvents["resourceFilesSent"] = urdfTransferToRos.Status["resourceFilesSent"]; urdfTransferToRos.Transfer(); }
public void Reset() { Debug.Log("Resetting RosBridge!"); if (RosSocket != null) { RosSocket.Close(); } // Necessary as this is also our flag to stop running threads RosSocket = null; if (SocketThread != null) { SocketThread.Join(); } IsConnected = new ManualResetEvent(false); SocketThread = new Thread(ConnectAndWait); SocketThread.Start(); }
private void ImportAssets() { // setup Urdf Transfer UrdfTransferFromRos urdfTransfer = new UrdfTransferFromRos(rosSocket, assetPath, urdfParameter); StatusEvents["robotNameReceived"] = urdfTransfer.Status["robotNameReceived"]; StatusEvents["robotDescriptionReceived"] = urdfTransfer.Status["robotDescriptionReceived"]; StatusEvents["resourceFilesReceived"] = urdfTransfer.Status["resourceFilesReceived"]; urdfTransfer.Transfer(); if (StatusEvents["robotNameReceived"].WaitOne(timeout * 1000)) { robotName = urdfTransfer.RobotName; localDirectory = urdfTransfer.LocalUrdfDirectory; } // import URDF assets: if (StatusEvents["resourceFilesReceived"].WaitOne(timeout * 1000)) { Debug.Log("Imported urdf resources to " + localDirectory); Debug.Log("Now creating txt files from .dae files"); var files = Directory.GetFiles(localDirectory, "*.dae", SearchOption.AllDirectories); foreach (var file in files) { string newPath = file.Replace(".dae", ".txt"); Debug.Log("Copied " + Path.GetFileName(file)); File.Copy(file, newPath); } } else { Debug.LogWarning("Not all resource files have been received before timeout."); } rosSocket.Close(); }
private void OnApplicationQuit() { RosSocket.Close(); }
protected void OnApplicationQuit() { RosSocket.Close(); }
public void Stop() { socket.Close(); }