diff --git a/tutorials/pick_and_place/2_ros_tcp.md b/tutorials/pick_and_place/2_ros_tcp.md index 9e04cf20..acaa7ae1 100644 --- a/tutorials/pick_and_place/2_ros_tcp.md +++ b/tutorials/pick_and_place/2_ros_tcp.md @@ -47,6 +47,8 @@ To enable communication between Unity and ROS, a TCP endpoint running as a ROS n In the ROS Message Browser window, click `Browse` next to the ROS message path. Navigate to and select the ROS directory of this cloned repository (`Unity-Robotics-Hub/tutorials/pick_and_place/ROS/`). This window will populate with all msg and srv files found in this directory. + In the ROS Message Browser window, type in `Scripts/RosMessages` in the text field of Build message path. + ![](img/2_browser.png) > Note: If any of these ROS directories appear to be empty, you can run the command `git submodule update --init --recursive` to download the packages via Git submodules. diff --git a/tutorials/pick_and_place/PickAndPlaceProject/Assets/DemoScripts/Demo.cs b/tutorials/pick_and_place/PickAndPlaceProject/Assets/DemoScripts/Demo.cs index 3fd53b75..4ea42f98 100644 --- a/tutorials/pick_and_place/PickAndPlaceProject/Assets/DemoScripts/Demo.cs +++ b/tutorials/pick_and_place/PickAndPlaceProject/Assets/DemoScripts/Demo.cs @@ -6,14 +6,12 @@ using System.IO; using System.Reflection; using System.Text; -using RosSharp; -using RosSharp.Control; -using RosSharp.Urdf; -using RosSharp.Urdf.Editor; using UnityEditor; using UnityEngine; using Unity.Robotics.ROSTCPConnector; using Unity.Robotics.ROSTCPConnector.MessageGeneration; +using Unity.Robotics.UrdfImporter; +using Unity.Robotics.UrdfImporter.Control; public class Demo : MonoBehaviour { @@ -43,7 +41,7 @@ public class Demo : MonoBehaviour float controllerSpeed = 30; float controllerAcceleration = 10; - string rosMessagesDirectory = "Assets/RosMessages"; + string rosMessagesDirectory = "Assets/Scripts/RosMessages"; string rosSrcDirectory = "../ROS/src"; string msgDirectory = "msg"; string srvDirectory = "srv"; @@ -53,6 +51,17 @@ public class Demo : MonoBehaviour string moverServiceFileName = "MoverService.srv"; string scriptPattern = "*.cs"; + string registerMethodName = "Register"; + string[] rosGeneratedTypeFullName = new string[] + { + "RosMessageTypes.Moveit.RobotTrajectoryMsg", + "RosMessageTypes.NiryoMoveit.NiryoMoveitJointsMsg", + "RosMessageTypes.NiryoMoveit.NiryoTrajectoryMsg", + "RosMessageTypes.NiryoMoveit.MoverServiceResponse", + "RosMessageTypes.NiryoMoveit.MoverServiceRequest" + }; + + string externalScriptsDirectory = "../Scripts"; //string scriptsDirectory = "Assets/Scripts"; @@ -77,7 +86,7 @@ void Awake() CreateRosConnection(); CreateTrajectoryPlannerPublisher(); } - + void Update() { // Make sure to publish only once in the demo @@ -138,6 +147,12 @@ private void AddRosMessages() scripts.AddRange(Directory.GetFiles(rosMessagesDirectory, scriptPattern, SearchOption.AllDirectories)); scripts.AddRange(Directory.GetFiles(externalScriptsDirectory)); RecompileScripts(scripts.ToArray()); + + // Register Ros message names and their deserialize function + foreach (var typeFullName in rosGeneratedTypeFullName) + { + assembly.GetType(typeFullName).GetMethod(registerMethodName).Invoke(null, null); + } } private void CreateTrajectoryPlannerPublisher() diff --git a/tutorials/pick_and_place/PickAndPlaceProject/Assets/Tests/EditMode/IntegrationTest.cs b/tutorials/pick_and_place/PickAndPlaceProject/Assets/Tests/EditMode/IntegrationTest.cs index 29294aca..47e5a878 100644 --- a/tutorials/pick_and_place/PickAndPlaceProject/Assets/Tests/EditMode/IntegrationTest.cs +++ b/tutorials/pick_and_place/PickAndPlaceProject/Assets/Tests/EditMode/IntegrationTest.cs @@ -2,12 +2,11 @@ using System.Collections; using System.IO; using NUnit.Framework; -using RosSharp; -using RosSharp.Control; -using RosSharp.Urdf; using Unity.Robotics.PickAndPlace; using UnityEngine; using Unity.Robotics.ROSTCPConnector; +using Unity.Robotics.UrdfImporter; +using Unity.Robotics.UrdfImporter.Control; using UnityEditor; using UnityEditor.SceneManagement; using UnityEngine.TestTools; @@ -101,16 +100,16 @@ public IEnumerator TrajectoryPublisher_PickAndPlaceDemo_CompletesTask() m_TimeElapsedSeconds += Time.deltaTime; yield return null; } - + Assert.IsTrue(DidPlacementSucceed, "Pick and Place did not complete before test timed out."); - + yield return new ExitPlayMode(); } void SetUpScene() { EditorSceneManager.OpenScene(k_PathTestScene); - + InstantiatePrefabFromName(k_NameTable); InstantiatePrefabFromName(k_NameTarget); InstantiatePrefabFromName(k_NameTargetPlacement); diff --git a/tutorials/pick_and_place/PickAndPlaceProject/Packages/manifest.json b/tutorials/pick_and_place/PickAndPlaceProject/Packages/manifest.json index cee94b0a..3b5463ba 100644 --- a/tutorials/pick_and_place/PickAndPlaceProject/Packages/manifest.json +++ b/tutorials/pick_and_place/PickAndPlaceProject/Packages/manifest.json @@ -1,11 +1,10 @@ { "dependencies": { - "com.unity.collab-proxy": "1.5.7", "com.unity.ide.rider": "2.0.7", "com.unity.ide.visualstudio": "2.0.8", "com.unity.ide.vscode": "1.2.3", "com.unity.robotics.ros-tcp-connector": "https://github.com/Unity-Technologies/ROS-TCP-Connector.git?path=/com.unity.robotics.ros-tcp-connector#dev", - "com.unity.robotics.urdf-importer": "https://github.com/Unity-Technologies/URDF-Importer.git?path=/com.unity.robotics.urdf-importer#stl-package-import-fix", + "com.unity.robotics.urdf-importer": "https://github.com/Unity-Technologies/URDF-Importer.git?path=/com.unity.robotics.urdf-importer#dev", "com.unity.test-framework": "1.1.24", "com.unity.textmeshpro": "3.0.6", "com.unity.timeline": "1.4.8",