Skip to content

Commit f46f598

Browse files
committed
Code clean-up
1 parent 6ad5c41 commit f46f598

File tree

4 files changed

+12
-15
lines changed

4 files changed

+12
-15
lines changed

mainwindow.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ private slots:
5151

5252
BaseController* controller;
5353
int maxFrameNum; // Maximum number of frame updates per path planning calculation
54-
int frameFreq; // Frame update frequency;
54+
int frameFreq; // Frame update frequency
5555
VtkVisualizer* visualizer;
5656

5757
bool ReadFromXMLFile(QString const& fileName);

robot_controller.cpp

+7-5
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@ bool BaseController::PathPlanningUpdate(TendonRobot & robot, const Eigen::Matrix
3232
int numTendon = targetTendonLengthChange.cols();
3333
int qCount = 0;
3434
for (int j = 0; j < robot.getNumSegment(); j++) { // Pack segment parameter matrices to q
35+
Eigen::VectorXd initTendonLengthChange = robot.getSegments()[j].getCurTendonLengthChange();
3536
for (int i = 0; i < numTendon - 1; i++) {
36-
q_cur(qCount) = robot.getSegments()[j].getCurTendonLengthChange(i);
37+
q_cur(qCount) = initTendonLengthChange(i);
3738
qCount++;
3839
}
3940
q_cur(qCount) = robot.getSegments()[j].getCurExtLength();
@@ -83,7 +84,10 @@ bool BaseController::PathPlanningUpdate(TendonRobot & robot, const Eigen::Matrix
8384
J_body.col(i) = J_bi;
8485
}
8586

86-
/* Left Pseudo Inverse with Joint Limit */
87+
/* Damped Left Pseudo Inverse with Joint Limit
88+
* Reference for damped pseudo inverse: A.S. Deo, I.D. Walker: Overview of damped least-squares methods for inverse kinematics of robot manipulators, P46
89+
* Reference for joint limit cost function: S. Lilge, J. Burgner-Kahrs: Enforcing Shape Constraints during Motion of Concentric Tube Continuum Robots, P3
90+
*/
8791
Eigen::MatrixXd JTJ = J_body.transpose() * J_body;
8892
Eigen::MatrixXd weightMat = jointLimitWeight * Eigen::MatrixXd::Identity(numDOF, numDOF); // Damping for JTJ matrix inverse close to singularity
8993
Eigen::VectorXd negGradCostJointLimit = Eigen::VectorXd::Zero(numDOF); // v: cost function for joint limit task
@@ -196,9 +200,7 @@ void BaseController::UnpackRobotConfig(TendonRobot & robot, int numTendon, const
196200
void BaseController::RoundValues(Eigen::VectorXd & vals, double precision)
197201
{
198202
double multiplier = 1.0 / precision;
199-
// Eigen::VectorXi valsScaled = (vals * multiplier).array().round();
200-
// vals = valsScaled.cast<double>() * precision;
201-
for (int i = 0; i < vals.size(); i++) { // TODO: method without using loop
203+
for (int i = 0; i < vals.size(); i++) {
202204
long valScaled = static_cast<long>(vals[i] * multiplier);
203205
vals[i] = static_cast<double>(valScaled) * precision;
204206
}

tendon_robot.cpp

+2-7
Original file line numberDiff line numberDiff line change
@@ -268,14 +268,9 @@ double TendonRobot::ConstCurvSegment::getPhi()
268268
return m_twistAngle;
269269
}
270270

271-
double TendonRobot::ConstCurvSegment::getCurTendonLengthChange(int tendCount)
271+
Eigen::VectorXd TendonRobot::ConstCurvSegment::getCurTendonLengthChange()
272272
{
273-
if (tendCount < m_numTendon) {
274-
return m_tendonLengthChange[tendCount];
275-
}
276-
else {
277-
return 0; // TODO: out of range handle
278-
}
273+
return m_tendonLengthChange;
279274
}
280275

281276
double TendonRobot::ConstCurvSegment::getCurExtLength()

tendon_robot.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class TendonRobot
4444
double getDiskThickness();
4545
double getPhi();
4646

47-
double getCurTendonLengthChange(int tendCount);
47+
Eigen::VectorXd getCurTendonLengthChange();
4848
double getCurExtLength();
4949
double getCurSegLength();
5050
Eigen::Matrix4d & getSegTipPose();
@@ -78,7 +78,7 @@ class TendonRobot
7878

7979
public:
8080
int getNumSegment();
81-
std::vector<ConstCurvSegment> & getSegments(); // TODO: const
81+
std::vector<ConstCurvSegment> & getSegments();
8282

8383
private:
8484
int m_numSegment; // j

0 commit comments

Comments
 (0)