// Create a new task with incorrect ipaddress public static void CTUC00200_CTUC00300() { // Make sure by browser that no task is present. SceneResource scene = CTUB00100(); string xmlFilepath = "C:\\connection2.xml"; XmlDocument document = new XmlDocument(); StreamReader reader = new StreamReader(xmlFilepath, Encoding.UTF8); document.Load(reader); string taskName = document.GetElementsByTagName("taskname")[0].InnerText; string taskType = document.GetElementsByTagName("tasktype")[0].InnerText; string controllerip = "192.168.9.99"; int controllerport = int.Parse(document.GetElementsByTagName("controllerport")[0].InnerText); BinPickingTask task = (BinPickingTask)scene.GetOrCreateTaskFromName( taskName, taskType, controllerip, controllerport); try { task.GetJointValues(); } catch (ClientException ex) { if (!ex.ToString().Contains("Controller ip is not correct")) { throw new Exception("Test case CTUC00200_CTUC00300 failed"); } } }
// Get robot's joint values public static void CTUD00100() { BinPickingTask task = CTUC00100(); RobotState state = task.GetJointValues(); Console.WriteLine("[Joint names]" + string.Join(",", state.jointNames)); Console.WriteLine("[Joint values]" + string.Join(",", state.jointValues)); }
// Get robot's joint values - Time out public static void CTUD00200() { BinPickingTask task = CTUC00100(); try { RobotState state = task.GetJointValues(100); } catch (ClientException ex) { if (!ex.ToString().Contains("timed out")) { throw new Exception("Test case CTUD00200 failed"); } } }
static void Main(string[] args) { if (true) { ControllerClient controllerClient2 = new ControllerClient("testuser", "mytestpass", "http://controller13"); //controllerClient.Initialize("mujin:/irex2013/irex2013.WPJ", "mujincollada", "wincaps", "mujin:/irex2013.mujin.dae"); //SceneResource scene2 = controllerClient2.GetScene("test.mujin.dae"); // JSON creation //Dictionary<string, object> jsonMessage = controllerClient2.GetJsonMessage(HttpMethod.POST, "scene/?format=json", "{\"name\":\"newname\", \"reference_uri\":\"mujin:/plasticnut-center.mujin.dae\"}"); // XML creation Dictionary <string, object> xmlMessage = controllerClient2.GetXMLMessage(HttpMethod.POST, "scene/?format=xml", "<request><name>newname3</name><reference_uri>mujin:/plasticnut-center.mujin.dae</reference_uri></request>"); } // Default XML path: // string xmlFilepath = AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "..\\..\\samples\\getsceneinfo\\config\\connection.xml"; // Custom XML path; string xmlFilepath = "C:\\connection2.xml"; XmlDocument document = new XmlDocument(); StreamReader reader = new StreamReader(xmlFilepath, Encoding.UTF8); document.Load(reader); string mujinIpAddress = document.GetElementsByTagName("ipaddress")[0].InnerText; string scenePrimaryKey = document.GetElementsByTagName("scenepk")[0].InnerText; string username = document.GetElementsByTagName("username")[0].InnerText; string password = document.GetElementsByTagName("password")[0].InnerText; string taskName = document.GetElementsByTagName("taskname")[0].InnerText; string taskType = document.GetElementsByTagName("tasktype")[0].InnerText; string controllerip = document.GetElementsByTagName("controllerip")[0].InnerText; int controllerport = int.Parse(document.GetElementsByTagName("controllerport")[0].InnerText); ControllerClient controllerClient = new ControllerClient(username, password, mujinIpAddress); //controllerClient.Initialize("mujin:/irex2013/irex2013.WPJ", "mujincollada", "wincaps", "mujin:/irex2013.mujin.dae"); SceneResource scene = controllerClient.GetScene(scenePrimaryKey); BinPickingTask task = (BinPickingTask)scene.GetOrCreateTaskFromName(taskName, taskType, controllerip, controllerport); // Test1: GetJointValues RobotState robotState = task.GetJointValues(); /* * // Test2: MoveJoints * robotState.jointValues[1] += 30; * robotState.jointValues[3] -= 30; * List<double> jointValues = new List<double>() { robotState.jointValues[1], robotState.jointValues[3] }; * List<int> jointIndices = new List<int>(){1, 3}; * task.MoveJoints(jointValues, jointIndices, 30, 0.2, ""); */ List <double> jointValues = new List <double>() { 45 }; List <int> jointIndices = new List <int>() { 6 }; task.MoveJoints(jointValues, jointIndices, 30, 0.2, ""); jointValues = new List <double>() { 0, 0, 0, 0, 0, 0, 0 }; jointIndices = new List <int>() { 0, 1, 2, 3, 4, 5, 6 }; task.MoveJoints(jointValues, jointIndices, 30, 0.2, ""); /* * // Test3: MoveToHandPosition * double[] basepos = robotState.tools["1Base"]; * basepos[1] += 50; * basepos[3] -= 50; * task.MoveToHandPosition(new List<double>(basepos), GoalType.transform6d, "1Base", 0.2); */ // Test4: PickAndMove //task.PickAndMove("container3", "camera3", "1Base", GoalType.translationdirection5d, new List<double>() { 1900, 240, 700, 0, 0, 1 }, 0.2); }