-
Notifications
You must be signed in to change notification settings - Fork 946
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Jog cpp api fixes #1911
Jog cpp api fixes #1911
Conversation
Doxygenize some comments Use public inheritance of JogInterfaceBase
Codecov Report
@@ Coverage Diff @@
## master #1911 +/- ##
=========================================
+ Coverage 50.29% 50.3% +0.01%
=========================================
Files 313 313
Lines 24652 24644 -8
=========================================
- Hits 12398 12397 -1
+ Misses 12254 12247 -7
Continue to review full report at Codecov.
|
@@ -751,17 +750,19 @@ bool JogCalcs::addJointIncrements(sensor_msgs::JointState& output, const Eigen:: | |||
|
|||
void JogCalcs::removeDimension(Eigen::MatrixXd& jacobian, Eigen::VectorXd& delta_x, unsigned int row_to_remove) | |||
{ | |||
unsigned int num_rows = jacobian.rows() - 1; | |||
unsigned int num_cols = jacobian.cols(); | |||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you remove this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, it was commented for debugging. Will restore.
@@ -500,8 +500,7 @@ double JogCalcs::decelerateForSingularity(const Eigen::VectorXd& commanded_veloc | |||
new_theta += pseudo_inverse_ * delta_x; | |||
kinematic_state_->setJointGroupPositions(joint_model_group_, new_theta); | |||
|
|||
jacobian_ = kinematic_state_->getJacobian(joint_model_group_); | |||
Eigen::JacobiSVD<Eigen::MatrixXd> new_svd = Eigen::JacobiSVD<Eigen::MatrixXd>(jacobian_); | |||
Eigen::JacobiSVD<Eigen::MatrixXd> new_svd = Eigen::JacobiSVD<Eigen::MatrixXd>(jacobian); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eigen::JacobiSVD<Eigen::MatrixXd> new_svd = Eigen::JacobiSVD<Eigen::MatrixXd>(jacobian); | |
Eigen::JacobiSVD<Eigen::MatrixXd> new_svd(jacobian); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Fix dim mismatch in decelerateForSingularity
@@ -39,13 +39,13 @@ | |||
|
|||
#include "moveit_jog_arm/jog_cpp_interface.h" | |||
|
|||
// TODO(davetcoleman): rename JogCppApi to JogCppInterface to match file name | |||
// TODO(davetcoleman): rename JogCppInterface to JogCppInterface to match file name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this comment can be removed now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -154,8 +154,8 @@ class JogCalcs | |||
|
|||
JogArmParameters parameters_; | |||
|
|||
// For jacobian calculations | |||
Eigen::MatrixXd jacobian_, pseudo_inverse_, matrix_s_; | |||
// Preallocate for jacobian calculations |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would reword comments since the lines below don't really pre-allocate memory but rather cache results that are calculated once(?) Correct me though if I have misunderstood the way Eigen allocates memory for dynamic matrices.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like pre-allocating memory by creating member variables unless there constructor is non-trivial (eg a RobotState variable). It seems like poor design because you never know how they may be used elsewhere and there is no reason why their values should be preserved. Seems like a use case for a static variable instead..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These variables get updated frequently in a while loop (like, 100 times/second or so) so performance kind of matters. I guess I'm not clear how static variables would be better, but I want to know
I'll make them all local variables until I hear back
edit: Oh, I read up on what static
does to a local variable (stays in scope until exit). OK, I'll make them static local variables
@@ -474,23 +474,24 @@ bool JogCalcs::applyVelocityScaling(const JogArmShared& shared_variables, std::m | |||
|
|||
// Possibly calculate a velocity scaling factor, due to proximity of singularity and direction of motion | |||
double JogCalcs::decelerateForSingularity(const Eigen::VectorXd& commanded_velocity, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this function be renamed? It calculates a velocity scaling factor but it sounds like it commands the manipulator to decelerate when close to singularity. Maybe velocityScalingFactorForSingularity
or something like that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good idea, done
@@ -154,8 +154,8 @@ class JogCalcs | |||
|
|||
JogArmParameters parameters_; | |||
|
|||
// For jacobian calculations | |||
Eigen::MatrixXd jacobian_, pseudo_inverse_, matrix_s_; | |||
// Preallocate for jacobian calculations |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like pre-allocating memory by creating member variables unless there constructor is non-trivial (eg a RobotState variable). It seems like poor design because you never know how they may be used elsewhere and there is no reason why their values should be preserved. Seems like a use case for a static variable instead..
* See cpp_interface_example.cpp | ||
*/ | ||
class JogCppApi : protected JogInterfaceBase | ||
class JogCppInterface : public JogInterfaceBase |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is in moveit_experimental in the master branch, this is okay but in general, it is really bad practice to change public interfaces without deprecating the old one.
* Rename JogCppApi->JogCppInterface to match filename * Use public inheritance of JogInterfaceBase * Fix crash due to different Jacobian dimensions * Clang format, update unit test * Fix dim mismatch in decelerateForSingularity * Revert 'static' for several variables
* Rename JogCppApi->JogCppInterface to match filename * Use public inheritance of JogInterfaceBase * Fix crash due to different Jacobian dimensions * Clang format, update unit test * Fix dim mismatch in decelerateForSingularity * Revert 'static' for several variables
* Rename JogCppApi->JogCppInterface to match filename * Use public inheritance of JogInterfaceBase * Fix crash due to different Jacobian dimensions * Clang format, update unit test * Fix dim mismatch in decelerateForSingularity * Revert 'static' for several variables
This cleans up a few things in jog_arm:
Renames JogCppApi class to JogCppInterface to match the filename
Fix a crash when the dimensions of the Jacobian changed
Doxygenize some comments
Make the inheritance of JogInterfaceBase public. I wanted this so I could call the functions from external C++ code, like this:
jog_interface_ptr_->changeDriftDimensions(...)