Ejemplo n.º 1
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 };
            }
        }
 public Trajectory()
 {
     t = 0;
     head = new Matrix3D();
     needle_entry = new Needle();
     needle_exit = new Needle();
     needle_mid = new Needle();
     interpolation = new Interpolation(); // might be deleted
     optimizer = new Optimizer();
 }
        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();
        }
 // needle center for the needle frame and a point
 public Joints update_trajectory(Joints joint)
 {
     // not used
     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);
     optimizer.point_target = target;
     optimizer.x = new double[] { joint.UpperBevel, joint.LowerBevel, joint.Elbow, joint.twist };
     Joints optimized = optimizer.minimize_angle();
     return optimized;
     //Vector3D projected_exit_point = project_point(exit_point, needle_normal, needle_point);
     //Matrix3D head = calculate_needle_tip(entry_point, projected_exit_point, needle_normal);
 }
Ejemplo n.º 5
0
 //based on head frame
 public void update_needle(Matrix3D desired)
 {
     Optimizer optimizer = new Optimizer();
     optimizer.T_taget = desired;
     optimizer.x = new double[4] { kinematics.joint.UpperBevel, kinematics.joint.LowerBevel, kinematics.joint.Elbow, kinematics.joint.twist };
     Joints optimized_joints = optimizer.minimize_error();
     kinematics.joint.UpperBevel = optimized_joints.UpperBevel;
     kinematics.joint.LowerBevel = optimized_joints.LowerBevel;
     kinematics.joint.Elbow = optimized_joints.Elbow;
     kinematics.joint.twist = optimized_joints.twist;
     update_needle();
 }