浏览代码

Fixing issue with Demo.cs not working with new URDF Importer co-routine

/merge-resolve-conflicts
peifeng-unity 3 年前
当前提交
7c70d8d0
共有 1 个文件被更改,包括 10 次插入6 次删除
  1. 16
      tutorials/pick_and_place/PickAndPlaceProject/Assets/DemoScripts/Demo.cs

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


using System.Text;
using RosSharp;
using RosSharp.Control;
using RosSharp.Urdf;
using Unity.EditorCoroutines.Editor;
using UnityEditor;
using UnityEngine;
using Unity.Robotics.ROSTCPConnector;

// Create RosConnect
GameObject rosConnect = new GameObject(rosConnectName);
rosConnection = rosConnect.AddComponent<ROSConnection>();
rosConnection.RosIPAddress = hostIP;
rosConnection.RosPort = hostPort;
rosConnection.rosIPAddress = hostIP;
rosConnection.rosPort = hostPort;
rosConnection.overrideUnityIP = overrideUnityIP;
rosConnection.unityPort = unityPort;
rosConnection.awaitDataMaxRetries = awaitDataMaxRetries;
rosConnection.awaitDataSleepSeconds = awaitDataSleepSeconds;
}
private void ImportRobot()

string urdfFilepath = Path.Combine(Application.dataPath, urdfRelativeFilepath);
// Create is a coroutine that would usually run only in EditMode, so we need to force its execution here
var robotImporter = UrdfRobotExtensions.Create(urdfFilepath, urdfImportSettings, false);
while (robotImporter.MoveNext()) { }
while (robotImporter.MoveNext()) {}
// Adjust robot parameters
Controller controller = GameObject.Find(niryoOneName).GetComponent<Controller>();
controller.stiffness = controllerStiffness;

parameters.GenerateExecutable = false;
string[] texts = new string[filepaths.Length];
for (int i = 0; i < filepaths.Length; i++)
for (int i = 0; i < filepaths.Length; i ++)
texts[i] = File.ReadAllText(filepaths[i]);
texts[i] = File.ReadAllText(filepaths[i]);
}
CompilerResults results = provider.CompileAssemblyFromSource(parameters, texts);
checkCompileErrors(results);

正在加载...
取消
保存