-
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
API to use OMPL Planners within the new planner framework #466
Conversation
Codecov Report
@@ Coverage Diff @@
## master #466 +/- ##
==========================================
- Coverage 77.61% 77.58% -0.03%
==========================================
Files 260 262 +2
Lines 6588 6669 +81
==========================================
+ Hits 5113 5174 +61
- Misses 1475 1495 +20
|
public: | ||
/// Constructor. | ||
/// | ||
/// \param[in] planner The OMPL planner to use. |
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.
This planner
is not in the constructor arguments. I guess you wanted to describe the template type of this class. Let's move this to the class docstring something like:
/// \tparam PlannerType The OMPL planner to use.
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 line should be deleted now?
#include <ompl/base/ScopedState.h> | ||
#include <ompl/base/SpaceInformation.h> | ||
#include <ompl/base/goals/GoalRegion.h> | ||
#include <ompl/geometric/PathSimplifier.h> |
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: Third party headers should come first and then the project headers (see this)
|
||
#include "aikido/planner/ompl/detail/OMPLConfigurationToConfigurationPlanner-impl.hpp" | ||
|
||
#endif // AIKIDO_PLANNER_SNAPCONFIGURATIONTOCONFIGURATIONPLANNER_HPP_ |
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.
#endif // AIKIDO_PLANNER_SNAPCONFIGURATIONTOCONFIGURATIONPLANNER_HPP_ | |
#endif // AIKIDO_PLANNER_OMPL_OMPLCONFIGURATIONTOCONFIGURATIONPLANNER_HPP_ |
src/robot/util.cpp
Outdated
// createTestableBounds(space), | ||
// createProjectableBounds(space), | ||
// timelimit, | ||
// collisionResolution); |
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: Let's remove old code
std::move(dmetric), | ||
std::move(sampler), | ||
mBoundsConstraint, | ||
std::move(mBoundsProjector)); |
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.
We don't need to have mBoundsProjector
as a member variable because it's been moved. It seems we could convert this as a local variable in this constructor implementation.
include/aikido/planner/ompl/detail/OMPLConfigurationToConfigurationPlanner-impl.hpp
Outdated
Show resolved
Hide resolved
include/aikido/planner/ompl/detail/OMPLConfigurationToConfigurationPlanner-impl.hpp
Show resolved
Hide resolved
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!
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.
Thanks for the PR! I have one major question. The OMPLPlanner
constructor takes an interpolator
, dmetric
, sampler
, boundsConstraint
, boundsProjector
. However, it seems that we're inconsistent with which of those are stored as fields in the OMPLPlanner
class, versus which of those are only used as local variables in the constructor to create the OMPL Planner
.
My understanding is that this is because we need mInterpolator
(to reconstruct an AIKIDO Interpolated
) and mBoundsConstraint
(to create the TestableIntersection
with the problem's constraint). However, it seems that one way to resolve this is to modify GeometricStateSpace
and add getters for all of the above. That way, we don't need any of them stored as fields: we can just get them directly from the state information. What do you think?
public: | ||
/// Constructor. | ||
/// | ||
/// \param[in] planner The OMPL planner to use. |
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 line should be deleted now?
/// Plans a trajectory from start state to goal state by using an interpolator | ||
/// to interpolate between them. | ||
/// | ||
/// The planner returns success if the resulting trajectory satisfies |
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 think this is accurate: this function always returns the trajectory, which is null if planning fails.
::ompl::base::PlannerPtr getOMPLPlanner(); | ||
|
||
/// Sets interpolator used to produce the output trajectory. | ||
void setInterpolator(statespace::ConstInterpolatorPtr interpolator); |
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 documentation for interpolator
.
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.
Is this function being used? What's the use case for wanting to change the interpolator after construction, without changing the other fields?
statespace::ConstInterpolatorPtr mInterpolator; | ||
|
||
private: | ||
// TODO (avk): Should we make the problem take std::vector<TestablePtr>? |
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 would we want a vector of Testable
s?
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 was also a little uncomfortable with needing to have an mBoundsConstraint
to reconstruct the contraint during planning and was wondering if we could have a vector of testables passed in the problem instead of a single testable.
#define AIKIDO_PLANNER_OMPL_DETAIL_OMPLCONFIGURATIONTOCONFIGURATION_IMPL_HPP_ | ||
|
||
#include "aikido/planner/ompl/OMPLConfigurationToConfigurationPlanner.hpp" | ||
|
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 we try to avoid empty lines in the includes?
const auto metaskeletonStatespace | ||
= std::dynamic_pointer_cast<const MetaSkeletonStateSpace>(mStateSpace); | ||
|
||
if (!metaskeletonStatespace |
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 found this logic somewhat confusing because it wasn't clear to me when all of the conditions would be satisfied. I think this might be clearer:
if (metaSkeletonStateSpace)
{
if (!sampler) ...
if (!mBoundsConstraint) ...
if (!boundsProjector) ...
}
else
{
if (!sampler || !boundsConstraint || !boundsProjector)
{
throw ...
}
}
auto sspace = ...
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.
sigh
// Geometric State space | ||
auto sspace = ompl_make_shared<GeometricStateSpace>( | ||
mStateSpace, | ||
std::make_shared<aikido::statespace::GeodesicInterpolator>(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.
Shouldn't this use mInterpolator
? (Again, still not clear why that's a field and not just a local variable.)
// Plan | ||
mPlanner->setProblemDefinition(pdef); | ||
mPlanner->setup(); | ||
auto solved = mPlanner->solve(1); |
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.
Shouldn't 1
be timelimit
or something?
{ | ||
// Only states belonging geometric statespaces are supported. | ||
assert( | ||
dynamic_cast<aikido::planner::ompl::GeometricStateSpace::StateType*>( |
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.
Is it possible for a PathGeometric
to have non-GeometricStateSpace::StateType
? If so, is it possible for a PathGeometric
to have a mixture of StateType
s (i.e. does this dynamic_cast
need to happen every time)?
std::move(boundsProjection), | ||
0.1); | ||
auto traj = planner->plan(problem); | ||
EXPECT_TRUE(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.
What?
Really good idea about modifying |
Co-Authored-By: aditya-vk <adityavk711@gmail.com>
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.
Almost there! I have a few minor nits we should address, but I think we can merge once those are in. Thanks for the great changes!
aikido::statespace::ConstInterpolatorPtr getInterpolator() const; | ||
|
||
/// Return the bounds constraint for the statespace. Used to specify | ||
/// constraints |
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.
This is wrapped weirdly.
/// Return the bounds constraint for the statespace. Used to specify | ||
/// constraints | ||
/// to the OMPL planner. | ||
aikido::constraint::TestablePtr getBoundsConstraint() const; |
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.
Is there a reason for this not to be ConstTestablePtr
to match the statespace and interpolator?
/// \param[in] stateSpace State space that this planner associated with. | ||
/// \param[in] rng Random number generator to create the state sampler. | ||
/// \param[in] interpolator Interpolator used to interpolate between two | ||
/// states. GeodesicInterpolator is used by default. | ||
/// \param[in] dmetric A valid distance metric defined on the StateSpace. | ||
/// Distance metric relevant to the statespace is used by default. | ||
/// \param[in] sampler A Sampleable that can sample states from the | ||
/// StateSpace. Warning: Many OMPL planners internally assume this sampler |
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 we remove this warning? I think it'd be a good idea to keep (and perhaps denote with a \note
to make it show up nicely in the docs).
/// otherwise. The reason for the failure is stored in the \c result output | ||
/// parameter. | ||
/// If successful, the planner returns a valid trajectory. If not, it | ||
/// returns a \c nullptr. The corresponding message is stored in result. |
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 a combination of the old and new versions is the most descriptive/accurate. How about something like:
If successful, the planner returns a trajectory that satisfies the constraint. If not, it returns a \c nullptr and the reason for the failure is stored in the \c result.
double GeometricStateSpace::getMaxDistanceBetweenValidityChecks() const | ||
{ | ||
return mMaxDistanceBetweenValidityChecks; | ||
} | ||
} |
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 we usually have a newline before the closing braces for the namespaces. Also, // namespace XXX
?
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 great to me. Just one nitpick.
for (std::size_t idx = 0; idx < path->getStateCount(); ++idx) | ||
{ | ||
const auto* st | ||
= static_cast<aikido::planner::ompl::GeometricStateSpace::StateType*>( |
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: Let's add an assertion for checking the type using dynamic_cast.
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. For now, I don't much of a preference on this, since we are only working with geometric planners/statespaces. But I guess when we later extend our support, we might be dealing with other state types.
Thanks!
* dirty init for OMPL + AIKIDO under new API * new ompl api header * ompl planner implementation * use the new ompl api and test * update ompl planner implementation; bugfix for replanning * test planner specific params * pass rng * clean up tests, clear() after solving problem * remove vscode files * make format * address JS's comments * address minor comments from brian * testing the new feature Co-Authored-By: aditya-vk <adityavk711@gmail.com> * WIP: Added a bunch of TODOs to address * add getter methods * use the member varaibles from statespace * follow the new geometric statespace constructor * use new API * add new param to constructors in tests * cleanup and add doscstrings * unsigned int vs size_t * cleanup of geometric statespace * add some tests in geomteric statespace * correct for changes in geomteric statespace class * termination condition changed * address travis error * Format code * typo fix Co-Authored-By: aditya-vk <adityavk711@gmail.com> * typo fix Co-Authored-By: aditya-vk <adityavk711@gmail.com> * address comments * style change * update changelog * added an assertion before the static cast
This PR enables using the OMPL planners via AIKIDO for any of the
ConfigurationToConfiguration
problems. This should allow us to plan for exact/approximate solutions for configuration(s)/TSR problems.There are a few TODOs in the PR, one of which would be part of another PR perhaps(?) since they are in relation to statespaces and contraints.
Before creating a pull request
make format
Before merging a pull request
CHANGELOG.md