@@ -6,6 +6,8 @@ BaseController::BaseController()
6
6
updateFreq = 10 ;
7
7
qEpsilon = 1e-5 ;
8
8
maxTimestep = 1e4 ;
9
+ lambda_zero = 1000 ;
10
+ manipul_th = 0.01 ;
9
11
PGain = 5e-3 ;
10
12
}
11
13
@@ -66,38 +68,26 @@ bool BaseController::PathPlanning(TendonRobot & robot, const Eigen::MatrixXd & t
66
68
J_body.col (i) = J_bi;
67
69
}
68
70
69
- /* single segment */
70
- // assert(J_body.cols() == 3);
71
- // Eigen::MatrixXd J_body_pos = J_body.block(3, 0, 3, 3); // Position part only
72
- // Eigen::MatrixXd J_body_inv = J_body_pos.inverse();
73
-
74
- /* 6dof robot, 6dof pose, using Damped Least Squares Method */
75
- // Note: Not calculating inverse directly, because Jacobian is in singularity for z-axis rotation at initial pose
76
- // Citation for damping factor calculation method:
77
- // Y. Nakamura and H. Hanafusa, Inverse kinematics solutions with singularity robustness for robot manipulator control
71
+ /* 6-DOF pose using Damped Least Squares Method
72
+ * Not calculating inverse directly, because Jacobian is always in singularity for z-axis rotation due to parallel tendon routing
73
+ * Therefore, want to damp this DOF
74
+ * This method works for 6-DOF or redundant robot
75
+ * Citation for damping factor calculation method:
76
+ * Y. Nakamura and H. Hanafusa, Inverse kinematics solutions with singularity robustness for robot manipulator control
77
+ */
78
78
Eigen::MatrixXd JJT = J_body * J_body.transpose ();
79
79
// Note: use SVD to calculate determinant because determinant() is not working properly near singularity
80
- // double JJT_det = JJT.determinant();
81
80
Eigen::JacobiSVD<Eigen::MatrixXd> svd (JJT);
82
81
Eigen::VectorXd JJT_singVals = svd.singularValues ();
83
82
RoundValues (JJT_singVals, 1e-6 ); // Round the values to 1e-6 to prevent the case of very_large_double * very_small_double
84
83
double JJT_det = JJT_singVals.prod ();
85
84
double manipul = sqrt (JJT_det); // Manipulability measure
86
- double manipul_th = 0.01 ; // Manipulability threshold
87
85
double lambda = 0.0 ; // Damping factor
88
- double lambda_zero = 1000 ; // Maximum damping factor
89
86
if (manipul < manipul_th)
90
87
lambda = lambda_zero * pow ((1 - manipul / manipul_th), 2 );
91
- Eigen::MatrixXd J_body_pseudo = J_body.transpose () *
92
- (JJT + lambda * Eigen::Matrix<double ,6 ,6 >::Identity ()).inverse (); // Right Pseudo Inverse
93
-
94
- /* 6dof robot, 5dof pose, skip z-axis rotation */
95
- // Eigen::MatrixXd J_body_5dof(5, 6);
96
- // J_body_5dof.block(0, 0, 2, 6) = J_body.block(0, 0, 2, 6);
97
- // J_body_5dof.block(2, 0, 3, 6) = J_body.block(3, 0, 3, 6);
98
- // Eigen::MatrixXd J_body_pseudo = J_body_5dof.transpose() * (J_body_5dof * J_body_5dof.transpose()).inverse(); // Right Pseudo Inverse
99
- /* redundant 12dof (or 9dof) robot */
100
- // Eigen::MatrixXd J_body_pseudo = J_body.transpose() * (J_body * J_body.transpose()).inverse(); // Right Pseudo Inverse
88
+ Eigen::Matrix<double ,6 ,6 > modDampingMat = Eigen::Matrix<double ,6 ,6 >::Zero ();
89
+ modDampingMat (2 , 2 ) = 1 ; // Only damp the z-axis rotation
90
+ Eigen::MatrixXd J_body_pseudo = J_body.transpose () * (JJT + lambda * modDampingMat).inverse (); // Right Pseudo Inverse
101
91
102
92
Eigen::Matrix4d T_body_desired = T_cur.inverse () * T_target;
103
93
double theta;
@@ -106,22 +96,8 @@ bool BaseController::PathPlanning(TendonRobot & robot, const Eigen::MatrixXd & t
106
96
twist << S_skew (2 ,1 ), S_skew (0 ,2 ), S_skew (1 ,0 ), // omega components
107
97
S_skew (0 ,3 ), S_skew (1 ,3 ), S_skew (2 ,3 ); // v components
108
98
twist *= theta; // S is normalized, multiply by theta to get twist
109
-
110
- /* single segment */
111
- // Eigen::VectorXd twist_v = twist.tail(3);
112
- // Eigen::VectorXd q_dot = J_body_inv * twist_v;
113
99
114
- /* 6dof robot, 6dof pose */
115
100
Eigen::VectorXd q_dot = J_body_pseudo * twist;
116
-
117
- /* 6dof robot, 5dof pose, skip z-axis rotation */
118
- // Eigen::VectorXd twist_5dof(5);
119
- // twist_5dof.head(2) = twist.head(2);
120
- // twist_5dof.tail(3) = twist.tail(3);
121
- // Eigen::VectorXd q_dot = J_body_pseudo * twist_5dof;
122
- /* redundant 12dof (or 9dof) robot */
123
- // Eigen::VectorXd q_dot = J_body_pseudo * twist;
124
-
125
101
q_cur = q_cur + q_dot * PGain; // TODO: Time step length?
126
102
UnpackRobotConfig (robot, numTendon, q_cur, curTendonLengthChange, curSegLength);
127
103
T_cur = robot.CalcTipPose (curTendonLengthChange, curSegLength);
0 commit comments