예제 #1
0
        // Move robot's joints - Invalid clearance
        public static void CTUE00400()
        {
            BinPickingTask task = CTUC00100();

            // J7(linear rail), J1, J2, J3, J5, J6, J8(servo hand)
            List <double> jointValues = new List <double>()
            {
                -10.0, 0.0, 50.0, -100.0, 0.0, 0.0, 0.0
            };
            List <int> jointIndices = new List <int>()
            {
                0, 1, 2, 3, 4, 5, 6
            };

            try
            {
                task.MoveJoints(jointValues, jointIndices, -5.0, 0.2, "");
            }
            catch (ClientException ex)
            {
                if (!ex.ToString().Contains("Task Input Error"))
                {
                    throw new Exception("Test case CTUE00400 failed");
                }
            }
        }
예제 #2
0
        // Create a new task with incorrect port number
        public static void CTUC00400_CTUC00500()
        {
            // 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   = document.GetElementsByTagName("controllerip")[0].InnerText;
            int    controllerport = 9999;

            BinPickingTask task = (BinPickingTask)scene.GetOrCreateTaskFromName(
                taskName, taskType, controllerip, controllerport);

            try
            {
                task.GetJointValues();
            }
            catch (ClientException ex)
            {
                if (!ex.ToString().Contains("Controller port number is not correct"))
                {
                    throw new Exception("Test case CTUC00400_CTUC00500 failed");
                }
            }
        }
예제 #3
0
        // 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));
        }
예제 #4
0
        // Move towards a work and pick it - Invalid tool name
        public static void CTUG00700()
        {
            BinPickingTask task = CTUC00100();

            // For transform6d, X[mm], Y[mm], Z[mm], RX[deg], RY[deg], RZ[deg]
            List <double> goalpos = new List <double>()
            {
                300, 900, 500, 0, 0, 0
            };

            //task.PickAndMove("container1", "camera1", "hogehoge", GoalType.transform6d, goalpos, 0.2, 60000);
        }
예제 #5
0
        // Move towards a work and pick it - translatedirection5d
        public static void CTUG00200()
        {
            BinPickingTask task = CTUC00100();

            // For translationdirection5d, X[mm], Y[mm], Z[mm], DX[mm], DY[mm], DZ[mm]
            List <double> goalpos = new List <double>()
            {
                300, 900, 500, 0, 0, 0
            };

            //task.PickAndMove("container1", "camera1", "1Base", GoalType.translationdirection5d, goalpos, 0.2, 60000);
        }
예제 #6
0
        // Move towards a work and pick it - transform6d
        public static void CTUG00100()
        {
            BinPickingTask task = CTUC00100();

            // For transform6d, X[mm], Y[mm], Z[mm], RX[deg], RY[deg], RZ[deg]
            List <double> goalpos = new List <double>()
            {
                1000.5, 800, 1050, 1, -89, -89
            };

            //task.PickAndMove("container1", "camera1", "1Base", GoalType.transform6d, goalpos, 0.2, 60000);
        }
예제 #7
0
        // Move robot's joints based on hand position - Invalid goal position
        public static void CTUF00500()
        {
            BinPickingTask task = CTUC00100();

            // For transform6d, X[mm], Y[mm], Z[mm], RX[deg], RY[deg], RZ[deg]
            List <double> goalpos = new List <double>()
            {
                1500, 0, 600, 0, 0, 0
            };

            task.MoveToHandPosition(goalpos, GoalType.transform6d, "1Base", 0.2, 60000);
        }
예제 #8
0
        // Move robot's joints based on hand position - translatedirection5d
        public static void CTUF00200()
        {
            BinPickingTask task = CTUC00100();

            // For translationdirection5d, X[mm], Y[mm], Z[mm], DX[mm], DY[mm], DZ[mm]
            List <double> goalpos = new List <double>()
            {
                1500, 900, 500, 0, 0, 0
            };

            task.MoveToHandPosition(goalpos, GoalType.translationdirection5d, "1Base", 0.2, 60000);
        }
예제 #9
0
        static void Main(string[] args)
        {
            string hostname = "controller65";
            string username = "******";
            string password = "******";
            string scenepk  = "knowledgepicking1.mujin.dae";

            ControllerClient controllerClient = new ControllerClient(username, password, "http://" + hostname);

            SceneResource  scene = controllerClient.GetScene(scenepk);
            BinPickingTask task  = (BinPickingTask)scene.GetOrCreateTaskFromName("test_task_1", "binpicking");

            // slave request id for the target slave, usually hostname + "_slave0"
            task.SlaveRequestID = hostname + "_slave0";

            // remove objects in the scene whose names have this prefix, optional
            string prefix = "detected_sourcecontainer_";

            // list of objects and their poses to be updated in the scene
            List <Dictionary <string, object> > envstate = new List <Dictionary <string, object> >()
            {
                new Dictionary <string, object>()
                {
                    { "name", prefix + "1" },
                    { "quat_", new List <double>()
                      {
                          1, 0, 0, 0
                      } },
                    { "translation_", new List <double>()
                      {
                          0, 0, 300
                      } },
                    { "object_uri", "mujin:/work1.mujin.dae" },
                },
                new Dictionary <string, object>()
                {
                    { "name", prefix + "2" },
                    { "quat_", new List <double>()
                      {
                          1, 0, 0, 0
                      } },
                    { "translation_", new List <double>()
                      {
                          0, 100, 400
                      } },
                    { "object_uri", "mujin:/work2_b.mujin.dae" },
                }
            };

            task.UpdateObjects(envstate, prefix);
        }
예제 #10
0
        // 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");
                }
            }
        }
예제 #11
0
        // Move robot's joints
        public static void CTUE00100()
        {
            BinPickingTask task = CTUC00100();

            // J7(linear rail), J1, J2, J3, J5, J6, J8(servo hand)
            //List<double> jointValues = new List<double>() { -10.0, 0.0, 50.0, -100.0, 0.0, 0.0, 0.0 };
            List <double> jointValues = new List <double>()
            {
                -800.0, 0.0, 35.0, 45.0, 0.0, 0.0, 0.0
            };
            List <int> jointIndices = new List <int>()
            {
                0, 1, 2, 3, 4, 5, 6
            };

            task.MoveJoints(jointValues, jointIndices, 20, 0.2, "");
        }
예제 #12
0
        // Move towards a work and pick it - Time out
        public static void CTUG00900()
        {
            BinPickingTask task = CTUC00100();

            // For transform6d, X[mm], Y[mm], Z[mm], RX[deg], RY[deg], RZ[deg]
            List <double> goalpos = new List <double>()
            {
                300, 900, 500, 0, 0, 0
            };

            try
            {
                //task.PickAndMove("container1", "camera1", "1Base", GoalType.transform6d, goalpos, 0.2, 100);
            }
            catch (ClientException ex)
            {
                if (!ex.ToString().Contains("timed out"))
                {
                    throw new Exception("Test case CTUG00900 failed");
                }
            }
        }
예제 #13
0
        // Move robot's joints based on hand position - Invalid tool name
        public static void CTUF00600()
        {
            BinPickingTask task = CTUC00100();

            // For transform6d, X[mm], Y[mm], Z[mm], RX[deg], RY[deg], RZ[deg]
            List <double> goalpos = new List <double>()
            {
                1500, 900, 500, 0, 0, 0
            };

            try
            {
                task.MoveToHandPosition(goalpos, GoalType.transform6d, "hogehoge", 0.2, 60000);
            }
            catch (ClientException ex)
            {
                if (!ex.ToString().Contains("failed to find manipulator with name"))
                {
                    throw new Exception("Test case CTUF00600 failed");
                }
            }
        }
예제 #14
0
        // Move robot's joints - Invalid Joint Values
        public static void CTUE00200()
        {
            BinPickingTask task = CTUC00100();

            // J7 (index=0) cannot go positive.
            List <double> jointValues = new List <double>()
            {
                -10.0, 0.0, 70.0, -140.0, 0.0, 0.0, 0.0
            };
            List <int> jointIndices = new List <int>()
            {
                0, 1, 2, 3, 4, 5, 6
            };

            try
            {
                task.MoveJoints(jointValues, jointIndices, 30, 0.2, "");
            }
            catch (ClientException ex)
            {
                System.Console.WriteLine(ex.ToString());
            }
        }
예제 #15
0
        // Create a new task and get the task
        public static BinPickingTask CTUC00100()
        {
            // 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   = document.GetElementsByTagName("controllerip")[0].InnerText;
            int    controllerport = int.Parse(document.GetElementsByTagName("controllerport")[0].InnerText);

            BinPickingTask task = (BinPickingTask)scene.GetOrCreateTaskFromName(
                taskName, taskType, controllerip, controllerport);

            return((BinPickingTask)scene.GetOrCreateTaskFromName(
                       taskName, taskType, controllerip, controllerport));
        }
예제 #16
0
        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);
        }