public static void specified_pos(Needle needle)
        {
            /*
            Needle needle = new Needle(); // for sake of have a valid head position and initial joint values for the following optimizer
            needle.kinematics.joint.UpperBevel = 60;
            needle.kinematics.joint.LowerBevel = 60;
            needle.kinematics.joint.Elbow = 150; // no need for twist, twist will be given in loop
            needle.kinematics.joint.twist=0;
            needle.update_needle();
            */

            Optimizer optimizer = new Optimizer();
            optimizer.point_target.X = NeedleKinematics.get_translation(needle.head).X;
            optimizer.point_target.Y = NeedleKinematics.get_translation(needle.head).Y;
            optimizer.point_target.Z = NeedleKinematics.get_translation(needle.head).Z;

            optimizer.x = new double[3] { needle.kinematics.joint.UpperBevel, needle.kinematics.joint.LowerBevel, needle.kinematics.joint.Elbow };
            int n = 20;
            for (int i = 0; i < n; i++)
            {
                optimizer.point_target.W = i * 360 / n;
                Joints optimized_joints = optimizer.minimize_postionNtwist();
                needle.kinematics.joint=optimized_joints;
                needle.update_needle();
                Print.PrintJointOnFile(optimized_joints);
                Print.PrintMatrixOnFile(needle.center);
                optimizer.x = new double[3] { optimized_joints.UpperBevel, optimized_joints.LowerBevel, optimized_joints.Elbow };
            }
        }
Example #2
0
        public static void specified_pos(Needle needle)
        {
            /*
             * Needle needle = new Needle(); // for sake of have a valid head position and initial joint values for the following optimizer
             * needle.kinematics.joint.UpperBevel = 60;
             * needle.kinematics.joint.LowerBevel = 60;
             * needle.kinematics.joint.Elbow = 150; // no need for twist, twist will be given in loop
             * needle.kinematics.joint.twist=0;
             * needle.update_needle();
             */

            Optimizer optimizer = new Optimizer();

            optimizer.point_target.X = NeedleKinematics.get_translation(needle.head).X;
            optimizer.point_target.Y = NeedleKinematics.get_translation(needle.head).Y;
            optimizer.point_target.Z = NeedleKinematics.get_translation(needle.head).Z;

            optimizer.x = new double[3] {
                needle.kinematics.joint.UpperBevel, needle.kinematics.joint.LowerBevel, needle.kinematics.joint.Elbow
            };
            int n = 20;

            for (int i = 0; i < n; i++)
            {
                optimizer.point_target.W = i * 360 / n;
                Joints optimized_joints = optimizer.minimize_postionNtwist();
                needle.kinematics.joint = optimized_joints;
                needle.update_needle();
                Print.PrintJointOnFile(optimized_joints);
                Print.PrintMatrixOnFile(needle.center);
                optimizer.x = new double[3] {
                    optimized_joints.UpperBevel, optimized_joints.LowerBevel, optimized_joints.Elbow
                };
            }
        }
Example #3
0
        public void SELECT_ENTRY(Joints joints)
        {
            needle.kinematics.joint.UpperBevel = joints.UpperBevel; //-60; //joints.UpperBevel;
            needle.kinematics.joint.LowerBevel = joints.LowerBevel; //-50;// joints.LowerBevel;
            needle.kinematics.joint.Elbow      = joints.Elbow;      //80;// joints.Elbow;
            needle.kinematics.joint.twist      = joints.twist;      //0;// joints.twist;
            needle.update_needle();                                 // one-point suturing
            Print.PrintJointOnFile(joints);                         // print joints at the entry time
            switch (mode)
            {
            case 1:     // mode.one_point_suturing
                state++;
                state++;
                break;

            case 2:     //mode.two_point_suturing
                trajectory.entry_point = NeedleKinematics.get_translation(needle.head);
                //trajectory.set_entry_needle(joints);
                state++;
                break;
            }
        }
Example #4
0
        public static void optimization_test() // given a matrix find the possible one
        {
            Optimizer optimizaer = new Optimizer();
            Matrix3D  T_target   = new Matrix3D(0.0630, 0.0303, 0.9976, 129.7036,
                                                -0.2570, 0.9663, -0.0131, -43.1047,
                                                -0.9643, -0.2556, 0.0686, 13.1218,
                                                0, 0, 0, 1.0000);

            optimizaer.T_taget = T_target;
            optimizaer.x       = new double[4] {
                -50.0282200688546, -75.3754525301847, 57.2766149563357, 162
            };
            Joints optimized_joints;

            optimized_joints = optimizaer.minimize_error();
            Needle needle = new Needle();

            needle.kinematics.joint = optimized_joints;
            needle.update_needle();
        }
Example #5
0
        public void set_entry_needle(Joints joint)
        {
            double    central_angle = get_central_angle();
            Optimizer optimizer     = new Optimizer();
            Point4D   target        = new Point4D(entry_point.X, entry_point.Y, entry_point.Z, central_angle);

            Console.Write("\noTarget entry: {0}, {1}, {2}, {3}", entry_point.X, entry_point.Y, entry_point.Z, central_angle);
            optimizer.point_target = target;
            optimizer.x            = new double[] { joint.UpperBevel, joint.LowerBevel, joint.Elbow, joint.twist };
            Joints optimized = optimizer.minimize_angle();

            needle_entry.kinematics.joint.UpperBevel = optimized.UpperBevel;
            needle_entry.kinematics.joint.LowerBevel = optimized.LowerBevel;
            needle_entry.kinematics.joint.Elbow      = optimized.Elbow;
            needle_entry.kinematics.joint.twist      = optimized.twist;
            needle_entry.update_needle();

            // setup needle_mid
            needle_mid.kinematics.joint.UpperBevel = needle_entry.kinematics.joint.UpperBevel;
            needle_mid.kinematics.joint.LowerBevel = needle_entry.kinematics.joint.LowerBevel;
            needle_mid.kinematics.joint.Elbow      = needle_entry.kinematics.joint.Elbow;
            needle_mid.kinematics.joint.twist      = needle_entry.kinematics.joint.twist;
            needle_mid.update_needle();
        }