示例#1
0
        public void TestMoveManipulatorTo()
        {
            var rng = new Random(312312);

            for (var testNo = 0; testNo < 1000; ++testNo)
            {
                var x      = rng.NextDouble() * 2 * Length - Length;
                var y      = rng.NextDouble() * 2 * Length - Length;
                var a      = rng.NextDouble() * 2 * Math.PI;
                var angles = ManipulatorTask.MoveManipulatorTo(x, y, a);
                Assert.AreEqual(3, angles.Length);

                if (double.IsNaN(angles[0]))
                {
                    continue;
                }

                var joints = AnglesToCoordinatesTask.GetJointPositions(
                    angles[0], angles[1], angles[2]);

                Assert.AreEqual(3, joints.Length);
                Assert.AreEqual(joints[2].X, x, 0.001);
                Assert.AreEqual(joints[2].Y, y, 0.001);
            }
        }
示例#2
0
        public static void UpdateManipulator()
        {
            var angles = ManipulatorTask.MoveManipulatorTo(X, Y, Alpha);

            Shoulder = angles[0];
            Elbow    = angles[1];
            Wrist    = angles[2];
        }
示例#3
0
        public void TestMoveManipulatorTo()
        {
            var p             = Generate();
            var angles        = ManipulatorTask.MoveManipulatorTo(p.x, p.y, p.angle);
            var points        = AnglesToCoordinatesTask.GetJointPositions(angles[0], angles[1], angles[2]);
            var generatePoint = new PointF((float)p.x, (float)p.y);

            Assert.AreEqual(generatePoint.X, points[2].X, 1e-4);
            Assert.AreEqual(generatePoint.Y, points[2].Y, 1e-4);
        }
示例#4
0
        public static void UpdateManipulator()
        {
            var newAngles = ManipulatorTask.MoveManipulatorTo(X, Y, Alpha);

            if (newAngles[0] != Double.NaN && newAngles[1] != Double.NaN && newAngles[2] != Double.NaN)
            {
                Shoulder = newAngles[0];
                Elbow    = newAngles[1];
                Wrist    = newAngles[2];
            }
        }
示例#5
0
        public static void UpdateManipulator()
        {
            var newAngles = ManipulatorTask.MoveManipulatorTo(X, Y, Alpha);

            if (!newAngles.Contains(double.NaN))
            {
                Shoulder = newAngles[0];
                Elbow    = newAngles[1];
                Wrist    = newAngles[2];
            }
        }
示例#6
0
        public static void UpdateManipulator()
        {
            var angles = ManipulatorTask.MoveManipulatorTo(X, Y, Alpha);

            if (!double.IsNaN(angles[0]))
            {
                Shoulder = angles[0];
                Elbow    = angles[1];
                Wrist    = angles[2];
            }
        }
        public static void UpdateManipulator()
        {
            // Вызовите ManipulatorTask.MoveManipulatorTo и обновите значения полей Shoulder, Elbow и Wrist,
            // если они не NaN. Это понадобится для последней задачи.
            var angle = Math.Acos(Math.Abs(X - AnglesToCoordinatesTask.GetJointPositions(Shoulder, Elbow, Wrist)[2].X) / Manipulator.Palm);

            if (!double.IsNaN(Shoulder) && !double.IsNaN(Elbow) && !double.IsNaN(Wrist))
            {
                ManipulatorTask.MoveManipulatorTo(X, Y, angle);
            }
        }
示例#8
0
 public static void UpdateManipulator()
 {
     if (X != double.NaN && Y != double.NaN && Alpha != double.NaN)
     {
         double[] angles = ManipulatorTask.MoveManipulatorTo(X, Y, Alpha);
         Shoulder = angles[0];
         Elbow    = angles[1];
         Wrist    = angles[2];
     }
     // Вызовите ManipulatorTask.MoveManipulatorTo и обновите значения полей Shoulder, Elbow и Wrist, если они не NaN
     // Это понадобится для последней задачи.
 }
示例#9
0
        public static void UpdateManipulator()
        {
            var angles = ManipulatorTask.MoveManipulatorTo(X, Y, Alpha);

            if (angles.Any(double.IsNaN))
            {
                return;
            }

            Shoulder = angles[0];
            Elbow    = angles[1];
            Wrist    = angles[2];
        }
示例#10
0
 public static void UpdateManipulator()
 {
     double[] angles = ManipulatorTask.MoveManipulatorTo(X, Y, Alpha);
     foreach (var angle in angles)
     {
         if (Double.IsNaN(angle))
         {
             return;
         }
     }
     Shoulder = angles[0];
     Elbow    = angles[1];
     Wrist    = angles[2];
 }
示例#11
0
        /// Вызовите ManipulatorTask.MoveManipulatorTo и обновите значения полей Shoulder, Elbow и Wrist,
        /// если они не NaN. Это понадобится для последней задачи.
        public static void UpdateManipulator()
        {
            double[] angles     = ManipulatorTask.MoveManipulatorTo(X, Y, Alpha);
            bool     needUpdate = false;

            foreach (var angle in angles)
            {
                needUpdate = !angle.Equals(double.NaN);
            }
            if (needUpdate)
            {
                Shoulder = angles[0];
                Elbow    = angles[1];
                Wrist    = angles[2];
            }
        }
示例#12
0
        public void TestMoveManipulatorTo()
        {
            var random = new Random();

            for (int i = 0; i < 10; ++i)
            {
                var x      = random.Next(200);
                var y      = random.Next(200);
                var angle  = Math.PI * random.NextDouble();
                var result = ManipulatorTask.MoveManipulatorTo(x, y, angle);
                var joints = AnglesToCoordinatesTask.GetJointPositions(result[0],
                                                                       result[1], result[2]);
                Assert.AreEqual(x, joints[2].X, 1e-4);
                Assert.AreEqual(y, joints[2].Y, 1e-4);
            }
        }
示例#13
0
        public void RndTestMoveManipulatorTo()
        {
            var random         = new Random();
            var x              = random.NextDouble() * random.Next(0, 100);
            var y              = random.NextDouble() * random.Next(0, 100);
            var getRandomAngle = random.Next(0, 100);
            var angles         = ManipulatorTask.MoveManipulatorTo(x, y, getRandomAngle);
            var joints         = AnglesToCoordinatesTask.GetJointPositions(
                angles[0],
                angles[1],
                angles[2]);

            var palm = joints[2];

            Assert.AreEqual(x, palm.X, 1e-5);
            Assert.AreEqual(y, palm.Y, 1e-5);
        }
示例#14
0
        public void TestMoveManipulatorTo()
        {
            Random random = new Random();

            for (int i = 0; i < 10; i++)
            {
                var x      = random.Next();
                var y      = random.Next();
                var angle  = 2 * Math.PI * random.NextDouble();
                var angles = ManipulatorTask.MoveManipulatorTo(x, y, angle);
                if (!Double.IsNaN(angles[0]))
                {
                    var coordinates = AnglesToCoordinatesTask.GetJointPositions(angles[0], angles[1], angles[2]);
                    Assert.AreEqual(x, coordinates[2].X, 1e-5);
                    Assert.AreEqual(y, coordinates[2].Y, 1e-5);
                }
            }
        }
        public void TestMoveManipulatorTo()
        {
            var rnd = new Random();

            for (int i = 0; i < 1000; i++)
            {
                var x      = rnd.Next(-300, 300);
                var y      = rnd.Next(-300, 300);
                var al     = rnd.NextDouble() * Math.PI;
                var angles = ManipulatorTask.MoveManipulatorTo(x, y, al);

                if (!double.IsNaN(angles[0]))
                {
                    var coord = AnglesToCoordinatesTask.GetJointPositions(angles[0], angles[1], angles[2]);
                    Assert.AreEqual(x, coord[2].X, 0.001);
                    Assert.AreEqual(y, coord[2].Y, 0.001);
                }
            }
        }
示例#16
0
        public void TestMoveManipulatorTo()
        {
            var random = new Random();

            for (var i = 0; i < 1000; i++)
            {
                var x            = random.Next(100) + random.NextDouble();
                var y            = random.Next(100) + random.NextDouble();
                var alpha        = random.Next(100) + random.NextDouble();
                var actualAngles = ManipulatorTask.MoveManipulatorTo(x, y, alpha);
                if (!actualAngles.Contains(double.NaN))
                {
                    var actualCoordinates =
                        AnglesToCoordinatesTask.GetJointPositions(actualAngles[0], actualAngles[1], actualAngles[2]);
                    Assert.AreEqual(x, actualCoordinates[2].X, 1e-3, "X");
                    Assert.AreEqual(y, actualCoordinates[2].Y, 1e-3, "Y");
                }
            }
        }
示例#17
0
        public static void UpdateManipulator()
        {
            // Вызовите ManipulatorTask.MoveManipulatorTo и обновите значения полей Shoulder, Elbow и Wrist,
            // если они не NaN. Это понадобится для последней задачи.
            var Updated = ManipulatorTask.MoveManipulatorTo(X, Y, Alpha);

            if (Updated[0] == double.NaN || Updated[1] == double.NaN || Updated[2] == double.NaN)
            {
                Shoulder = double.NaN;
                Elbow    = double.NaN;
                Wrist    = double.NaN;
            }
            else
            {
                Shoulder = Updated[0];
                Elbow    = Updated[1];
                Wrist    = Updated[2];
            }
        }
示例#18
0
        public void TestMoveManipulatorTo()
        {
            var rng = new Random(TestSeed);

            for (var testNo = 0; testNo < NumTests; ++testNo)
            {
                var x      = rng.NextDouble() * 2 * FullSize - FullSize;
                var y      = rng.NextDouble() * 2 * FullSize - FullSize;
                var a      = rng.NextDouble() * 2 * Math.PI;
                var angles = ManipulatorTask.MoveManipulatorTo(x, y, a);
                Assert.AreEqual(3, angles.Length);
                if (!Double.IsNaN(angles[0]))
                {
                    var joints = AnglesToCoordinatesTask.GetJointPositions(
                        angles[0], angles[1], angles[2]);
                    Assert.AreEqual(3, joints.Length);
                    Assert.AreEqual(joints[2].X, x, 0.001);
                    Assert.AreEqual(joints[2].Y, y, 0.001);
                }
            }
        }
示例#19
0
        public void TestMoveManipulatorTo()
        {
            var rng = new Random(TestSeed);

            for (var testNo = 0; testNo < NumTests; ++testNo)
            {   // выбираем какую-то точку. не факт, что мы до неё сможем дотянуться.
                var x      = rng.NextDouble() * 2 * FullSize - FullSize;
                var y      = rng.NextDouble() * 2 * FullSize - FullSize;
                var a      = rng.NextDouble() * 2 * Math.PI;
                var angles = ManipulatorTask.MoveManipulatorTo(x, y, a);
                Assert.AreEqual(3, angles.Length);
                if (!Double.IsNaN(angles[0]))
                { // кажется, дотянулись! проверим, в нужную ли точку
                    var joints = AnglesToCoordinatesTask.GetJointPositions(
                        angles[0], angles[1], angles[2]);
                    Assert.AreEqual(3, joints.Length);
                    Assert.AreEqual(joints[2].X, x, 0.001);
                    Assert.AreEqual(joints[2].Y, y, 0.001);
                }
            }
        }
示例#20
0
        public void TestMoveManipulatorTo()
        {
            const float armLength = Manipulator.Forearm + Manipulator.Palm + Manipulator.UpperArm;
            var         rnd       = new Random();

            for (var i = 0; i < 100; ++i)
            {
                var x        = rnd.NextDouble() * 2 * armLength - armLength;
                var y        = rnd.NextDouble() * 2 * armLength - armLength;
                var angle    = rnd.NextDouble() * 2 * Math.PI;
                var solution = ManipulatorTask.MoveManipulatorTo(x, y, angle);

                if (double.IsNaN(solution[0]))
                {
                    continue;
                }

                var palmEnd = AnglesToCoordinatesTask.GetJointPositions(
                    solution[0], solution[1], solution[2])[2];
                Assert.AreEqual(palmEnd.X, x, 1e-4);
                Assert.AreEqual(palmEnd.Y, y, 1e-4);
            }
        }
示例#21
0
        public void TestMoveManipulatorTo()
        {
            Random rand = new Random();
            double x, y, angle;

            x     = Convert.ToDouble(rand.Next(1234567890)) / 300;
            y     = Convert.ToDouble(rand.Next(1234567890)) / 400;
            angle = Convert.ToDouble(rand.Next(1234567890)) / 500;
            var joints = ManipulatorTask.MoveManipulatorTo(x, y, angle);
            var actual = AnglesToCoordinatesTask.GetJointPositions(joints[0], joints[1], joints[2])[2];

            if (x * x + y * y <= Math.Pow(Manipulator.UpperArm + Manipulator.Forearm + Manipulator.Palm, 2))
            {
                Assert.AreEqual(x, actual.X, 1e-5);
                Assert.AreEqual(y, actual.Y, 1e-5);
            }
            else
            {
                Assert.AreEqual(Double.NaN, joints[0]);
                Assert.AreEqual(Double.NaN, joints[1]);
                Assert.AreEqual(Double.NaN, joints[2]);
            }
        }
示例#22
0
 public static void UpdateManipulator()
 {
     // Вызовите ManipulatorTask.MoveManipulatorTo и обновите значения полей Shoulder, Elbow и Wrist,
     // если они не NaN. Это понадобится для последней задачи.
     ManipulatorTask.MoveManipulatorTo(X, Y, Alpha);
 }
示例#23
0
 public void TestMoveManipulatorTo(double x, double y, double angle, double[] arr)
 {
     Assert.AreEqual(ManipulatorTask.MoveManipulatorTo(x, y, angle), arr);
     //Assert.Fail("Write real tests here!");
 }