// URscript control
 private void Generate_Click(object sender, RoutedEventArgs e)
 {
     if ((point1 != null) && (point2 != null) && (point3 != null))
     {
         var    scanmove = new URMovement(point1, point2);
         var    boundary = new RectangularBoundary(scanmove, point3);
         double aperture = 0.06;
         double overlap  = 0.1;
         var    urMoves  = PathPlanner.SStyle(boundary, aperture, overlap);
         var    safeDist = new URVector(new Vector3D(0, 0, 0.02), new Vector3D(0, 0, 0));
         URScriptTextBox.Text = URScript.Generate("cscan", urMoves, safeDist);
     }
 }
Beispiel #2
0
        public void Generate_ShouldGenerateCorrectScript()
        {
            string             name  = "test";
            URPose             pose1 = new URPose(new Point3D(-1, 1, 0), new Point3D(0, 0, 0));
            URPose             pose2 = new URPose(new Point3D(1, 1, 0), new Point3D(0, 0, 0));
            URPose             pose3 = new URPose(new Point3D(1, -1, 0), new Point3D(0, 0, 0));
            URPose             pose4 = new URPose(new Point3D(-1, -1, 0), new Point3D(0, 0, 0));
            List <IURMovement> moves = new List <IURMovement>();

            moves.Add(new URMovement(pose1, pose2));
            moves.Add(new URMovement(pose3, pose4));


            URVector safe = new URVector(new Vector3D(0, 0, 1), new Vector3D(0, 0, 0));

            var actual = URScript.Generate(name, moves, safe);

            var expected =
                "def test():\n" +
                "  movel(p[-1, 1, 1, 0, 0, 0], a=0.5, v=0.3)\n" +
                "  sleep(0.5)\n" +
                "  force_mode(p[0.0,0.0,0.0,0.0,0.0,0.0], [0, 0, 1, 0, 0, 0], [0.0, 0.0, -70.0, 0.0, 0.0, 0.0], 2, [0.1, 0.1, 0.15, 0.3490658503988659, 0.3490658503988659, 0.3490658503988659])\n" +
                "  movel(p[-1, 1, 0, 0, 0, 0], a=0.1, v=0.02)\n" +
                "  sleep(1)\n" +
                "  movel(p[1, 1, 0, 0, 0, 0], a=0.1, v=0.02)\n" +
                "  end_force_mode()\n" +
                "  sleep(0.5)\n" +
                "  movel(p[1, 1, 1, 0, 0, 0], a=0.1, v=0.1)\n" +
                "  movel(p[1, -1, 1, 0, 0, 0], a=0.5, v=0.3)\n" +
                "  sleep(0.5)\n" +
                "  force_mode(p[0.0,0.0,0.0,0.0,0.0,0.0], [0, 0, 1, 0, 0, 0], [0.0, 0.0, -70.0, 0.0, 0.0, 0.0], 2, [0.1, 0.1, 0.15, 0.3490658503988659, 0.3490658503988659, 0.3490658503988659])\n" +
                "  movel(p[1, -1, 0, 0, 0, 0], a=0.1, v=0.02)\n" +
                "  sleep(1)\n" +
                "  movel(p[-1, -1, 0, 0, 0, 0], a=0.1, v=0.02)\n" +
                "  end_force_mode()\n" +
                "  sleep(0.5)\n" +
                "  movel(p[-1, -1, 1, 0, 0, 0], a=0.1, v=0.1)\n" +
                "end\n";


            Assert.Equal(expected, actual);
        }
Beispiel #3
0
        public void SubtractMethodVectorPose_RotationShouldSubtract(
            double x, double y, double z,                         // initial rotation
            double dx, double dy, double dz,                      // ratation vector
            double expectedX, double expectedY, double expectedZ) // expected position
        {
            Vector3D poseVector     = new Vector3D(0, 0, 0);
            Vector3D rotationVector = new Vector3D(dx, dy, dz);
            URVector vector         = new URVector(poseVector, rotationVector);

            Point3D position = new Point3D(0, 0, 0);
            Point3D rotation = new Point3D(x, y, z);
            URPose  pose     = new URPose(position, rotation);

            var finalPose = URVector.Subtract(vector, pose);

            var actualX = finalPose.Rotation.X;
            var actualY = finalPose.Rotation.Y;
            var actualZ = finalPose.Rotation.Z;

            Assert.Equal(expectedX, actualX);
            Assert.Equal(expectedY, actualY);
            Assert.Equal(expectedZ, actualZ);
        }
Beispiel #4
0
        public void SubtractionOperatorVectorVector_RotationVectorShouldSubtract(
            double x1, double y1, double z1,                      // first rotation vector
            double x2, double y2, double z2,                      // second rotation vector
            double expectedX, double expectedY, double expectedZ) // expected rotation vector
        {
            Vector3D poseVector1     = new Vector3D(0, 0, 0);
            Vector3D rotationVector1 = new Vector3D(x1, y1, z1);
            URVector vector1         = new URVector(poseVector1, rotationVector1);

            Vector3D poseVector2     = new Vector3D(0, 0, 0);
            Vector3D rotationVector2 = new Vector3D(x2, y2, z2);
            URVector vector2         = new URVector(poseVector2, rotationVector2);

            var finalVector = vector1 - vector2;

            var actualX = finalVector.RotationVector.X;
            var actualY = finalVector.RotationVector.Y;
            var actualZ = finalVector.RotationVector.Z;

            Assert.Equal(expectedX, actualX);
            Assert.Equal(expectedY, actualY);
            Assert.Equal(expectedZ, actualZ);
        }
Beispiel #5
0
        public void AddittionOperatorVectorPose_RotationShouldAdd(
            double x, double y, double z,                         // initial rotation
            double dx, double dy, double dz,                      // rotation vector
            double expectedX, double expectedY, double expectedZ) // expected rotation
        {
            Vector3D poseVector     = new Vector3D(0, 0, 0);
            Vector3D rotationVector = new Vector3D(dx, dy, dz);
            URVector vector         = new URVector(poseVector, rotationVector);

            Point3D position = new Point3D(0, 0, 0);
            Point3D rotation = new Point3D(x, y, z);
            URPose  pose     = new URPose(position, rotation);

            var finalPose = vector + pose;

            var actualX = finalPose.Rotation.X;
            var actualY = finalPose.Rotation.Y;
            var actualZ = finalPose.Rotation.Z;

            Assert.Equal(expectedX, actualX);
            Assert.Equal(expectedY, actualY);
            Assert.Equal(expectedZ, actualZ);
        }
Beispiel #6
0
        public void SubtractionOperatorPoseVector_PoseShouldSubtract(
            double x, double y, double z,                         // initial position
            double dx, double dy, double dz,                      // vector
            double expectedX, double expectedY, double expectedZ) // expected position
        {
            Point3D position = new Point3D(x, y, z);
            Point3D rotation = new Point3D(0, 0, 0);
            URPose  pose     = new URPose(position, rotation);

            Vector3D poseVector     = new Vector3D(dx, dy, dz);
            Vector3D rotationVector = new Vector3D(0, 0, 0);
            URVector vector         = new URVector(poseVector, rotationVector);

            var finalPose = pose - vector;

            var actualX = finalPose.Position.X;
            var actualY = finalPose.Position.Y;
            var actualZ = finalPose.Position.Z;

            Assert.Equal(expectedX, actualX);
            Assert.Equal(expectedY, actualY);
            Assert.Equal(expectedZ, actualZ);
        }
Beispiel #7
0
 public URMovement(URPose start, URPose end)
 {
     Start    = start;
     End      = end;
     Movement = End - Start;
 }