浏览代码

Integration test (#257)

/dev-backup
GitHub 3 年前
当前提交
2849e66b
共有 4 个文件被更改,包括 29 次插入14 次删除
  1. 2
      tutorials/pick_and_place/2_ros_tcp.md
  2. 27
      tutorials/pick_and_place/PickAndPlaceProject/Assets/DemoScripts/Demo.cs
  3. 11
      tutorials/pick_and_place/PickAndPlaceProject/Assets/Tests/EditMode/IntegrationTest.cs
  4. 3
      tutorials/pick_and_place/PickAndPlaceProject/Packages/manifest.json

2
tutorials/pick_and_place/2_ros_tcp.md


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.

27
tutorials/pick_and_place/PickAndPlaceProject/Assets/DemoScripts/Demo.cs


using System.IO;
using System.Reflection;
using System.Text;
using RosSharp;
using RosSharp.Control;
using RosSharp.Urdf;
using RosSharp.Urdf.Editor;
using Unity.Robotics.UrdfImporter;
using Unity.Robotics.UrdfImporter.Control;
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";

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";

CreateRosConnection();
CreateTrajectoryPlannerPublisher();
}
void Update()
{
// Make sure to publish only once in the demo

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()

11
tutorials/pick_and_place/PickAndPlaceProject/Assets/Tests/EditMode/IntegrationTest.cs


using System.Collections;
using System.IO;
using NUnit.Framework;
using RosSharp;
using RosSharp.Control;
using RosSharp.Urdf;
using Unity.Robotics.UrdfImporter;
using Unity.Robotics.UrdfImporter.Control;
using UnityEditor;
using UnityEditor.SceneManagement;
using UnityEngine.TestTools;

m_TimeElapsedSeconds += Time.deltaTime;
yield return null;
}
yield return new ExitPlayMode();
}

InstantiatePrefabFromName(k_NameTable);
InstantiatePrefabFromName(k_NameTarget);
InstantiatePrefabFromName(k_NameTargetPlacement);

3
tutorials/pick_and_place/PickAndPlaceProject/Packages/manifest.json


{
"dependencies": {
"com.unity.collab-proxy": "1.5.7",
"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",

正在加载...
取消
保存