-
Notifications
You must be signed in to change notification settings - Fork 30
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
Add satisfiable tolerance parameter to TSR constructor #180
Conversation
I think we could simply pass the tolerance to |
@jslee02 isSatisfied() is inherited from a base class Testable. |
👍 I thought other |
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 you resolve the build errors?
Also, it would be nice to have a pair of setter and getter for the tolerance.
include/aikido/constraint/TSR.hpp
Outdated
@@ -44,7 +44,8 @@ class TSR : public Sampleable, | |||
const Eigen::Isometry3d& _T0_w = Eigen::Isometry3d::Identity(), | |||
const Eigen::Matrix<double, 6, 2>& _Bw = | |||
Eigen::Matrix<double, 6, 2>::Zero(), | |||
const Eigen::Isometry3d& _Tw_e = Eigen::Isometry3d::Identity()); | |||
const Eigen::Isometry3d& _Tw_e = Eigen::Isometry3d::Identity(), | |||
const double& _satisfiableTolerance = 1e-6); |
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.
Nit: Passing const reference for primitive type is pointless. Please change to double
.
include/aikido/constraint/TSR.hpp
Outdated
@@ -57,7 +58,8 @@ class TSR : public Sampleable, | |||
TSR(const Eigen::Isometry3d& _T0_w = Eigen::Isometry3d::Identity(), | |||
const Eigen::Matrix<double, 6, 2>& _Bw = | |||
Eigen::Matrix<double, 6, 2>::Zero(), | |||
const Eigen::Isometry3d& _Tw_e = Eigen::Isometry3d::Identity()); | |||
const Eigen::Isometry3d& _Tw_e = Eigen::Isometry3d::Identity(), | |||
const double& _satisfiableTolerance = 1e-6); |
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.
ditto
include/aikido/constraint/TSR.hpp
Outdated
private: | ||
std::unique_ptr<util::RNG> mRng; | ||
std::shared_ptr<statespace::SE3> mStateSpace; | ||
|
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.
Nit: Could we remove this empty line?
src/constraint/TSR.cpp
Outdated
: mT0_w(_T0_w) | ||
, mBw(_Bw) | ||
, mTw_e(_Tw_e) | ||
, mRng(std::move(_rng)) | ||
, mStateSpace(std::make_shared<SE3>()) | ||
, mSatisfiableTolerance(_satisfiableTolerance) |
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.
Initialize mSatisfiableTolerance
before mRng
and mStateSpace
to resolve the warning.
src/constraint/TSR.cpp
Outdated
: mT0_w(_T0_w) | ||
, mBw(_Bw) | ||
, mTw_e(_Tw_e) | ||
, mRng(std::unique_ptr<util::RNG>( | ||
new util::RNGWrapper<std::default_random_engine>(0))) | ||
, mStateSpace(std::make_shared<SE3>()) | ||
, mSatisfiableTolerance(_satisfiableTolerance) |
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.
ditto
src/constraint/TSR.cpp
Outdated
@@ -109,6 +112,7 @@ TSR::TSR(const TSR& other) | |||
, mTw_e(other.mTw_e) | |||
, mRng(std::move(other.mRng->clone())) | |||
, mStateSpace(std::make_shared<SE3>()) | |||
, mSatisfiableTolerance(other.mSatisfiableTolerance) |
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.
ditto
src/constraint/TSR.cpp
Outdated
@@ -120,6 +124,7 @@ TSR::TSR(TSR&& other) | |||
, mTw_e(other.mTw_e) | |||
, mRng(std::move(other.mRng)) | |||
, mStateSpace(std::make_shared<SE3>()) | |||
, mSatisfiableTolerance(other.mSatisfiableTolerance) |
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.
ditto
@jslee02 I addressed all your comments. Why does the order matter? |
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.
Looks good to me! A few minor style updates and docstring requested.
include/aikido/constraint/TSR.hpp
Outdated
@@ -44,7 +44,8 @@ class TSR : public Sampleable, | |||
const Eigen::Isometry3d& _T0_w = Eigen::Isometry3d::Identity(), | |||
const Eigen::Matrix<double, 6, 2>& _Bw = | |||
Eigen::Matrix<double, 6, 2>::Zero(), | |||
const Eigen::Isometry3d& _Tw_e = Eigen::Isometry3d::Identity()); | |||
const Eigen::Isometry3d& _Tw_e = Eigen::Isometry3d::Identity(), | |||
const double _satisfiableTolerance = 1e-6); |
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.
Nit: const
is meaningless for primitive types please change this to double _satisfiableTolerance = 1e-6
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.
Need docstring for the new variable.
include/aikido/constraint/TSR.hpp
Outdated
@@ -57,7 +58,8 @@ class TSR : public Sampleable, | |||
TSR(const Eigen::Isometry3d& _T0_w = Eigen::Isometry3d::Identity(), | |||
const Eigen::Matrix<double, 6, 2>& _Bw = | |||
Eigen::Matrix<double, 6, 2>::Zero(), | |||
const Eigen::Isometry3d& _Tw_e = Eigen::Isometry3d::Identity()); | |||
const Eigen::Isometry3d& _Tw_e = Eigen::Isometry3d::Identity(), | |||
const double _satisfiableTolerance = 1e-6); |
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.
ditto
include/aikido/constraint/TSR.hpp
Outdated
@@ -112,6 +114,10 @@ class TSR : public Sampleable, | |||
bool project(const statespace::StateSpace::State* _s, | |||
statespace::StateSpace::State* _out) const override; | |||
|
|||
double getSatisfiableTolerance(); | |||
|
|||
void setSatisfiableTolerance(const double satisfiableTolerance); |
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.
Nit: missing docstring
include/aikido/constraint/TSR.hpp
Outdated
@@ -112,6 +114,10 @@ class TSR : public Sampleable, | |||
bool project(const statespace::StateSpace::State* _s, | |||
statespace::StateSpace::State* _out) const override; | |||
|
|||
double getSatisfiableTolerance(); |
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.
Nit: missing docstring
src/constraint/TSR.cpp
Outdated
@@ -79,10 +79,12 @@ class TSRSampleGenerator : public SampleGenerator | |||
|
|||
//============================================================================= | |||
TSR::TSR(std::unique_ptr<util::RNG> _rng, const Eigen::Isometry3d& _T0_w, | |||
const Eigen::Matrix<double, 6, 2>& _Bw, const Eigen::Isometry3d& _Tw_e) | |||
const Eigen::Matrix<double, 6, 2>& _Bw, const Eigen::Isometry3d& _Tw_e, | |||
const double _satisfiableTolerance) |
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.
ditto
src/constraint/TSR.cpp
Outdated
@@ -91,10 +93,11 @@ TSR::TSR(std::unique_ptr<util::RNG> _rng, const Eigen::Isometry3d& _T0_w, | |||
|
|||
//============================================================================= | |||
TSR::TSR(const Eigen::Isometry3d& _T0_w, const Eigen::Matrix<double, 6, 2>& _Bw, | |||
const Eigen::Isometry3d& _Tw_e) | |||
const Eigen::Isometry3d& _Tw_e, const double _satisfiableTolerance) |
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.
ditto
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.
The name mSatisfiableTolerance
should be changed to mTestableTolerance
, as this tolerance is being used for methods inherited from the Testable
class.
While this PR is good in that it makes the arbitrary eps
in the existing isSatisfied
method into a member variable, I'm not sure that this is the right metric. I believe the previous use of eps
was just there as a placeholder. In Vector6d
representation of TSR, the first three are translation, whole the last three are for rotation. If we're to do a fix, shouldn't mTestableTolerance
be a Vector6d
with some default value? @mkoval @jslee02 any thoughts?
Also, I am not sure whether set
and get
for the tolerance is necessary. Is there a strong need to change this once a TSR is created?
include/aikido/constraint/TSR.hpp
Outdated
@@ -44,7 +44,8 @@ class TSR : public Sampleable, | |||
const Eigen::Isometry3d& _T0_w = Eigen::Isometry3d::Identity(), | |||
const Eigen::Matrix<double, 6, 2>& _Bw = | |||
Eigen::Matrix<double, 6, 2>::Zero(), | |||
const Eigen::Isometry3d& _Tw_e = Eigen::Isometry3d::Identity()); | |||
const Eigen::Isometry3d& _Tw_e = Eigen::Isometry3d::Identity(), | |||
const double _satisfiableTolerance = 1e-6); |
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.
Need docstring for the new variable.
include/aikido/constraint/TSR.hpp
Outdated
@@ -112,6 +114,14 @@ class TSR : public Sampleable, | |||
bool project(const statespace::StateSpace::State* _s, | |||
statespace::StateSpace::State* _out) const override; | |||
|
|||
/// Get the staisfiable tolerance for isSatisfiable. | |||
/// \param[out] _out Satisfialble tolerance, double. | |||
double getSatisfiableTolerance(); |
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.
Change this to getTestableTolerance()
. Although, I wonder why these set and get methods are necessary. Why do we want to change the tolerance once a TSR is created?
include/aikido/constraint/TSR.hpp
Outdated
double getSatisfiableTolerance(); | ||
|
||
/// Set the staisfiable tolerance for isSatisfiable. | ||
/// \param _satisfiableTolerance Satisfiable tolerance to set. |
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.
Typo. Though not sure why we need this method.
include/aikido/constraint/TSR.hpp
Outdated
private: | ||
/// Tolerance for checking satisfiability | ||
double mSatisfiableTolerance; |
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.
Consider changing this to Eigen::Vector6d
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.
Yes, I also think Eigen::Vector6d makes more sense.
I have addressed @gilwoolee 's comments. |
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 am conflicted about whether the tolerance parameter should be a double
or a Vector6d
. On one hand, @gilwoolee raises a valid point that the elements have different units that may have dissimilar scales. On the other hand, this tolerance parameter should only be used to deal with numerical precision issues that most often occur with point TSRs: the actual tolerance is encoded in Bw
.
I slightly prefer the Vector6d
option, but I don't feel strongly either way. Maybe @siddhss5 can break the tie?
@@ -44,7 +44,8 @@ class TSR : public Sampleable, | |||
const Eigen::Isometry3d& _T0_w = Eigen::Isometry3d::Identity(), |
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.
Add a docstring for _testableTolerance
.
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.
Fixed
include/aikido/constraint/TSR.hpp
Outdated
@@ -44,7 +44,8 @@ class TSR : public Sampleable, | |||
const Eigen::Isometry3d& _T0_w = Eigen::Isometry3d::Identity(), | |||
const Eigen::Matrix<double, 6, 2>& _Bw = | |||
Eigen::Matrix<double, 6, 2>::Zero(), | |||
const Eigen::Isometry3d& _Tw_e = Eigen::Isometry3d::Identity()); | |||
const Eigen::Isometry3d& _Tw_e = Eigen::Isometry3d::Identity(), | |||
const double _testableTolerance = 1e-6); |
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.
Don't mark arguments that are passed by value as const
in function declarations.
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.
Fixed
include/aikido/constraint/TSR.hpp
Outdated
@@ -57,7 +58,8 @@ class TSR : public Sampleable, | |||
TSR(const Eigen::Isometry3d& _T0_w = Eigen::Isometry3d::Identity(), | |||
const Eigen::Matrix<double, 6, 2>& _Bw = | |||
Eigen::Matrix<double, 6, 2>::Zero(), | |||
const Eigen::Isometry3d& _Tw_e = Eigen::Isometry3d::Identity()); | |||
const Eigen::Isometry3d& _Tw_e = Eigen::Isometry3d::Identity(), | |||
const double _testableTolerance = 1e-6); |
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.
Don't mark arguments that are passed by value as const
in function declarations.
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.
Fixed
@@ -57,7 +58,8 @@ class TSR : public Sampleable, | |||
TSR(const Eigen::Isometry3d& _T0_w = Eigen::Isometry3d::Identity(), |
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.
Add a docstring for _testableTolerance
.
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.
added.
include/aikido/constraint/TSR.hpp
Outdated
|
||
/// Set the testable tolerance used in isSatisfiable. | ||
/// \param _testableTolerance Testable tolerance to set. | ||
void setTestableTolerance(const double _testableTolerance); |
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.
Don't mark arguments that are passed by value as const
in function declarations.
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.
Fixed
As a third option, we could provide either way by providing |
Based on what @mkoval said, I'm still not convinced that we need |
I don't have a compelling reason to have the getters/setters but also not to have. One use case I can think of now is doing planning changing the error tolerance when it's failed to see if the failure is because of it. I'm fine either leaving them or not. |
No description provided.