Added SNS Acceleration IK Solver Interface with UnitTest#102
Added SNS Acceleration IK Solver Interface with UnitTest#102robodreamer wants to merge 4 commits intoRethinkRobotics-opensource:indigo-develfrom
Conversation
- added sns acceleration ik class and SNS_Base_Acc type - added Jacobian dot computation - created unit test with sawyer model
chris-smith
left a comment
There was a problem hiding this comment.
Not sure I know the code well enough to provide useful suggestions RE your note...
|
|
||
| if (n_tasks != ntasks) { | ||
| n_tasks = ntasks; | ||
| Eigen::VectorXd ddq = Eigen::VectorXd::Zero(n_dof); |
There was a problem hiding this comment.
unnecessary? Or is this supposed to set a member variable?
There was a problem hiding this comment.
It is a member variable. I followed the original code (SNS velocity solvers)'s style, so it is hard to tell whether it is a local variable or not. We should revisit all these code once and revise the style..
| // for the minimum bound | ||
| max = -maxJointAcceleration(i); | ||
| if (m_usePositionLimits) { | ||
| step = 2 * (jointLimit_low(i) - actualJointConfiguration(i) - actualJointVelocities(i)*loop_period) / (loop_period * loop_period); |
There was a problem hiding this comment.
is this taken from something specific I'm not aware of? worth a comment?
There was a problem hiding this comment.
It is based on the equations in the original paper. I will add a comment.
| const KDL::JntArray& q_bias, | ||
| const std::vector<std::string>& biasNames, | ||
| const KDL::JntArray& q_acc_bias, | ||
| KDL::JntArray& qddot_out) |
There was a problem hiding this comment.
should output variable be a pointer? That looks like the convention
There was a problem hiding this comment.
Yes. I followed the original code style, which is not necessarily good but it seemed to require a large amount of additional code changes once changed.
forrest-rm
left a comment
There was a problem hiding this comment.
Overall, it looks mostly good.
| // The control loop period in seconds | ||
| void setLoopPeriod(double period) { loop_period = period; } | ||
|
|
||
| // SNS Acceleration IK |
There was a problem hiding this comment.
This function needs more documentation for inputs and outputs
There was a problem hiding this comment.
Overall, more documentation is still needed.
|
|
||
| // SNS Acceleration IK | ||
| int getJointAcceleration(Eigen::VectorXd *jointAcceleration, const std::vector<TaskAcc> &sot, | ||
| const Eigen::VectorXd &jointConfiguration, const Eigen::VectorXd &jointVelocities); |
There was a problem hiding this comment.
Check alignment with previous line
| int getJointAcceleration(Eigen::VectorXd *jointAcceleration, const std::vector<TaskAcc> &sot, | ||
| const Eigen::VectorXd &jointConfiguration, const Eigen::VectorXd &jointVelocities); | ||
|
|
||
| std::vector<double> getTasksScaleFactor() |
There was a problem hiding this comment.
The getters should be const functions:
getTaskScaleFactor() const {
| Eigen::ArrayXd ddotQmax; // higher joint velocity bound | ||
| std::vector<double> scaleFactors; | ||
|
|
||
| // variables for base acc ik solver |
There was a problem hiding this comment.
It looks like most of these variables are only used in one function. They should not be member variables.
There was a problem hiding this comment.
That is right. I moved them inside the function now.
|
|
||
| SnsAccIkBase::uPtr baseIkSolver; | ||
|
|
||
| SnsIkBase::ExitCode exitCode; |
| @@ -189,9 +189,12 @@ SnsIkBase::ExitCode SnsIkBase::computeTaskScalingFactor(const Eigen::MatrixXd& J | |||
| Eigen::ArrayXd jntScaleFactorArr(nJnt_); | |||
There was a problem hiding this comment.
What does "Arr" stand for?
There was a problem hiding this comment.
It just indicates that the variable type is an Eigen array instead of a vector. It is the convention that was used in Matt's initial sns ik code.
sns_ik_lib/src/sns_ik_base.cpp
Outdated
| if (jntIsFree[i]) { | ||
| jntScaleFactorArr(i) = SnsIkBase::findScaleFactor(lowMargin(i), uppMargin(i), a(i)); | ||
| if (jntScaleFactorArr(i) == 1 && (jointOut(i) < (qLow_(i) - SnsIkBase::BOUND_TOLERANCE) || jointOut(i) > (qUpp_(i) + SnsIkBase::BOUND_TOLERANCE))) | ||
| jntScaleFactorArr(i) = 1e-3; |
| results.solveTime += tmp.solveTime; | ||
| results.fkLinErr += tmp.fkLinErr; | ||
| results.fkAngErr += tmp.fkAngErr; | ||
| ASSERT_LE(tmp.fkLinErr, ACC_IK_TEST_FK_LIN_TOL); |
There was a problem hiding this comment.
Should these asserts also happen when iTest == 0? If so, move them out of the else statement.
| // Run the test: | ||
| /* | ||
| * Note: This seems to cause a segfault in ubuntu 16.04 with Eigen 3.3.4, but it | ||
| * works fine in Ubuntu 14.04 with Eigen 3.2.0. FIXME |
There was a problem hiding this comment.
Is there a issue on github for this?
There was a problem hiding this comment.
I just created an issue for this.
sns_ik_lib/test/sns_ik_acc_test.cpp
Outdated
| *************************************************************************************************/ | ||
|
|
||
| /* | ||
| * Run the benchmark test on all five versions of the acceleration solver. |
There was a problem hiding this comment.
There's only one acc solver right now....
- removed unnecessary variables in jacobian dot computation - removed hard-coded numbers - enabled sns acc ik by default (only called upon request) - other cleanups
forrest-rm
left a comment
There was a problem hiding this comment.
Overall, it looks fairly good. I just had a few questions.
| Eigen::ArrayXd ddotQmax; // higher joint velocity bound | ||
| std::vector<double> scaleFactors; | ||
|
|
||
| // variables for base acc ik solver |
| // The control loop period in seconds | ||
| void setLoopPeriod(double period) { loop_period = period; } | ||
|
|
||
| // SNS Acceleration IK |
There was a problem hiding this comment.
Overall, more documentation is still needed.
| // check whether the acceleration limits are correctly shaped | ||
| if (ddotQmin(i) > ddotQmax(i)) { | ||
| if (ddotQmin(i) > 0) { | ||
| ROS_ERROR_STREAM("Lower limit has been reversed for J"<< i <<"!\n"<< "jointLimit_Low: " << jointLimit_low(i) |
There was a problem hiding this comment.
Need additional indentation
There was a problem hiding this comment.
Should this return an error code and/or revert to the previous values?
|
|
||
| // define some constants | ||
| static const size_t CARTESIAN_DOF = 6; | ||
| static const size_t NUM_LINKS = 9; // the number of links in robot kinematic chain |
There was a problem hiding this comment.
Why is this hard-coded and will this break things if the the DOF is different?
NOTE: Acc IK solver was created as another type of Vel IK solver,
I am trying to figure out a better way to do this, so any suggestions
are more than welcome! But this code works and it passes unit test.