-
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 wrapper for OMPL path simplifier #164
Changes from 11 commits
7e7172a
da97649
49d032f
7ec1b60
d3783e1
57abcec
837caa9
37e3dbb
2b1a6c7
fd14e5f
f82bfed
779d179
225c699
46a5120
166759f
874a2dd
5ff612c
8d431e1
c7a046b
d55d408
8be6466
ceaa06f
f5bb657
66bd650
e08b4a1
940da32
7b5d658
f1901cf
6312ab1
8cb2e83
5bd3daf
92b0a1e
86a7b89
acb021d
68d7120
f760795
38e468c
31d2a22
e5a52ec
0312178
97eab29
43f89c5
73f50b7
e7599f7
10e37cb
8d89279
125361c
4db3011
e206885
1e1d282
210325f
15e9ec0
390e25f
d528ae0
8b66810
33a0277
a0cbfab
7968bb6
b8b9281
5255dd1
753671d
f795e46
f37b9c0
05da04a
aa9f54a
447b75f
0cbd2c2
884ca31
039e97d
6244af2
0e84e01
d66fe87
e31e1d2
79329bd
d69aec4
7fe0a65
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,9 @@ | |
#include <ompl/base/ProblemDefinition.h> | ||
#include <ompl/base/SpaceInformation.h> | ||
#include <ompl/base/goals/GoalRegion.h> | ||
#include <ompl/base/ScopedState.h> | ||
|
||
#include <ompl/geometric/PathSimplifier.h> | ||
|
||
namespace aikido { | ||
namespace planner { | ||
|
@@ -241,10 +244,45 @@ trajectory::InterpolatedPtr planOMPL(const ::ompl::base::PlannerPtr &_planner, | |
statespace::InterpolatorPtr _interpolator, | ||
double _maxPlanTime); | ||
|
||
|
||
/// Take in an aikido trajectory and simplify it using OMPL methods | ||
/// \param _statespace The StateSpace that the planner must plan within | ||
/// \param _interpolator An Interpolator defined on the StateSpace. This is used | ||
/// to interpolate between two points within the space. | ||
/// \param _dmetric A valid distance metric defined on the StateSpace | ||
/// \param _sampler A Sampleable that can sample states from the | ||
/// StateSpace. Warning: Many OMPL planners internally assume this sampler | ||
/// samples uniformly. Care should be taken when using a non-uniform sampler. | ||
/// \param _validityConstraint A constraint used to test validity during | ||
/// planning. This should include collision checking and any other constraints | ||
/// that must be satisfied for a state to be considered valid. | ||
/// \param _boundsConstraint A constraint used to determine whether states | ||
/// encountered during planning fall within any bounds specified on the | ||
/// StateSpace. In addition to the _validityConstraint, this must also be | ||
/// satsified for a state to be considered valid. | ||
/// \param _boundsProjector A Projectable that projects a state back within | ||
/// valid bounds defined on the StateSpace | ||
/// \param _maxPlanTime The maximum time to allow the planner to search for a | ||
/// solution | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: Specify units (i.e. seconds). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed this parameter actually. Forgot to take it out of the comment as well. But will add a similar parameter for the timeout as suggested in your other comments. |
||
/// \param _maxDistanceBtwValidityChecks The maximum distance (under dmetric) between | ||
/// validity checking two successive points on a tree extension | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: Is "tree extension" meaningful for a shortcutting algorithm? |
||
/// \param _originalTraj The untimed trajectory obtained from the planner, | ||
/// needs simplifying. | ||
trajectory::InterpolatedPtr simplifyOMPL(statespace::StateSpacePtr _stateSpace, | ||
statespace::InterpolatorPtr _interpolator, | ||
distance::DistanceMetricPtr _dmetric, | ||
constraint::SampleablePtr _sampler, | ||
constraint::TestablePtr _validityConstraint, | ||
constraint::TestablePtr _boundsConstraint, | ||
constraint::ProjectablePtr _boundsProjector, | ||
double _maxDistanceBtwValidityChecks, | ||
trajectory::InterpolatedPtr _originalTraj); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd prefer to return an |
||
|
||
|
||
} // namespace ompl | ||
} // namespace planner | ||
} // namespace aikido | ||
|
||
#include "detail/Planner-impl.hpp" | ||
|
||
#endif | ||
#endif |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -317,6 +317,68 @@ trajectory::InterpolatedPtr planCRRTConnect( | |
std::move(_interpolator), _maxPlanTime); | ||
} | ||
|
||
//============================================================================= | ||
trajectory::InterpolatedPtr simplifyOMPL(statespace::StateSpacePtr _stateSpace, | ||
statespace::InterpolatorPtr _interpolator, | ||
distance::DistanceMetricPtr _dmetric, | ||
constraint::SampleablePtr _sampler, | ||
constraint::TestablePtr _validityConstraint, | ||
constraint::TestablePtr _boundsConstraint, | ||
constraint::ProjectablePtr _boundsProjector, | ||
double _maxDistanceBtwValidityChecks, | ||
trajectory::InterpolatedPtr _originalTraj) | ||
{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Still missing a check that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nevermind, I see now that |
||
|
||
// Step 1: Generate the space information of OMPL type | ||
auto si = getSpaceInformation( | ||
_stateSpace, _interpolator, std::move(_dmetric), std::move(_sampler), | ||
std::move(_validityConstraint), std::move(_boundsConstraint), | ||
std::move(_boundsProjector), _maxDistanceBtwValidityChecks); | ||
|
||
// Get the state space | ||
auto sspace = ompl_static_pointer_cast<GeometricStateSpace>( | ||
si->getStateSpace()); | ||
|
||
|
||
// Step 2: Convert the AIKIDO trajectory to Geometric Path | ||
::ompl::geometric::PathGeometric *path = new ::ompl::geometric::PathGeometric(si); | ||
|
||
for (size_t idx = 0; idx < _originalTraj->getNumWaypoints(); ++idx) | ||
{ | ||
auto ompl_state = sspace->allocState(_originalTraj->getWaypoint(idx)); | ||
path->append(ompl_state); | ||
sspace->freeState(ompl_state); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This code is duplicated from |
||
|
||
// Step 3: Use the OMPL methods to simplify the path | ||
::ompl::geometric::PathSimplifierPtr simplifier; | ||
simplifier.reset(new ::ompl::geometric::PathSimplifier(si)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is supfluous to use a |
||
bool const shortened = simplifier->shortcutPath(*path, 1, 1, 1.0, 0.005); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make Also, note that the current hard-coded settings are (in my opinion) nonsensical. Setting Another option is to leave |
||
|
||
// Step 4: Convert the simplified geomteric path to AIKIDO untimed trajectory | ||
if(shortened) | ||
{ | ||
auto returnTraj = std::make_shared<trajectory::Interpolated>( | ||
std::move(_stateSpace), std::move(_interpolator)); | ||
|
||
for (size_t idx = 0; idx < path->getStateCount(); ++idx) | ||
{ | ||
const auto *st = | ||
static_cast<GeometricStateSpace::StateType *>( | ||
path->getState(idx)); | ||
// Arbitrary timing | ||
returnTraj->addWaypoint(idx, st->mState); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This code should also be moved to a helper function. See my comment above about what it could be named and where it could live. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This comment has been addressed. |
||
return returnTraj; | ||
} | ||
else | ||
{ | ||
return _originalTraj; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Returning This is a bit of a moot point because:
|
||
} | ||
|
||
} | ||
|
||
//============================================================================= | ||
} // ns aikido | ||
} // ns planner | ||
} // ns ompl | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add a unit tests for It would also be nice to add tests for the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh that's fine! I shall work on it! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added tests for trajectory conversion functions. Converted an interpolated trajectory back and forth and ensured it had not changed. That should suffice, yes? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: The order of namespace is inverse. It should be: } // namespace ompl
} // namespace planner
} // namespace aikido |
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.
Minor Nit: I don't know if this is actually true. As far as I know, most randomized algorithms require that the distribution has non-zero probability of sampling all configurations (i.e. have support over all of configuration space). There is nothing special about the uniform distribution. In fact, what it means to be "uniform" depends on your choice of measure.
@siddhss5 Is what I said above true? 😅
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! The only requirement is that the sampler densely sample configuration space.