-
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
Planning adapters #437
Planning adapters #437
Conversation
Add ConfigurationToTSRPlanner. Add DART version of ConfigurationToConfigurationPlanner.
…rationToTSR adapter.
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 looks good! My main feedback is that it would be nice to have a base class for all of the DART planners, since we copy getMetaSkeletonStateSpace()
and getMetaSkeleton()
a lot. We could save this for a future PR too, depending on what others think.
We also don't enforce the adaptors at all- I don't think anything prevents you from using the wrong adaptor (i.e. PlannerAdaptor
on a planner that doesn't contain a MetaSkeleton
). Maybe we could add a flag for whether something is a DART planner to enforce this? This should probably be in a future PR though.
namespace planner { | ||
namespace dart { | ||
|
||
/// Adapts a non-DART DelegatePlanner to solve the single problem 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.
I think the name of this class should be a little more clear about what it does- maybe ConvertToDartPlannerAdapter
?
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 have also the similar impression, but couldn't come up with a better 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.
Planner_to_DartPlanner
? PlannerAdapter
could be called DartPlanner_to_DartPlanner
if you think that's better?
while (generator->canSample()) | ||
{ | ||
// Sample from TSR | ||
{ |
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.
Out of curiosity, why is this in braces?
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.
Adding the braces creates a temporary scope, so all of the local variables in that scope will be destructed when it ends. A std::lock_guard
releases the mutex when it's destructed.
👍
This sounds good to me. We could save this for furture though. In that case, it'd be good to create an issue to track 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.
Overall looks good to me. One high level comment and minor comments that are made in the code.
I think we need dart::ConfigurationToConfiguration
to distinguish it from non-DART config-to-config problem so that dart::ConfigurationToConfigurationPlanner
's solvable problem type becomes dart::ConfigurationToConfiguration
but not non-DART config-to-config.
::dart::dynamics::ConstBodyNodePtr endEffectorBodyNode, | ||
const statespace::StateSpace::State* startState, | ||
std::size_t maxSamples, | ||
const statespace::dart::MetaSkeletonStateSpace::State* startState, |
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: Grouping the goal related arguments would make sense so that the argument order becomes startState
-> maxSamples
-> goalTSR
or startState
-> goalTSR
-> maxSamples
.
// Note: SolvableProblem is defined in SingleProblemPlanner. | ||
|
||
/// Return this planner's MetaSkeletonStateSpace. | ||
statespace::dart::ConstMetaSkeletonStateSpacePtr getMetaSkeletonStateSpace(); |
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: This function should be const since it returns a pointer to a const object.
throw std::invalid_argument("MetaSkeleton has 0 degrees of freedom."); | ||
|
||
auto skeleton = mMetaSkeleton->getDof(0)->getSkeleton(); | ||
for (size_t i = 1; i < mMetaSkeleton->getNumDofs(); ++i) |
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: std::size_t
for (std::size_t i = 0; i < mMetaSkeleton->getNumBodyNodes(); ++i) | ||
{ | ||
if (mMetaSkeleton->getBodyNode(i)->getName() | ||
== problem.getEndEffectorBodyNode()->getName()) |
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 the equality check should be done over the pointer instead of their names. A MetaSkeleton
could have multiple body nodes of the same 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.
My thought was that BodyNode
that the ConfigurationToTSR
problem was constructed with could be from a different Skeleton
than the one that the delegate planner's MetaSkeleton
refers to. This might happen if we try multiple planners in parallel and therefore have several Skeleton
copies that are being used. In this case, I think the BodyNode
pointers would not be the same, but the names would be.
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.
That makes sense.
MetaSkeleton
has a function that returns all the BodyNode
s that has the queried name. How about we use that function and prints a warning if it's more than one?
InverseKinematicsSampleable ikSampleable( | ||
mMetaSkeletonStateSpace, | ||
mMetaSkeleton, | ||
std::const_pointer_cast<TSR>(problem.getGoalTSR()), |
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 you make a note here saying this const-casting should be removed once InverseKinematicsSampleable
is changed to take const constraints?
@@ -0,0 +1,35 @@ | |||
#include "aikido/planner/dart/DartPlannerAdapter.hpp" | |||
|
|||
using aikido::statespace::dart::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.
Technically, -impl.hpp
is also a header file so using using namespace ~
can pollute the namespaces. Please remove this.
@@ -2,7 +2,7 @@ | |||
#define AIKIDO_PLANNER_DART_CONFIGURATIONTOCONFIGURATIONPLANNER_HPP_ | |||
|
|||
#include "aikido/planner/ConfigurationToConfiguration.hpp" | |||
#include "aikido/planner/SingleProblemPlanner.hpp" | |||
#include "aikido/planner/dart/DartSingleProblemPlanner.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.
Can we rename dart::DartSingleProblemPlanner
to dart::SingleProblemPlanner
? We already have the dart
namespace, so I think repeating it is unnecessary 🙂
[skip ci]
Remove DartPlannerAdapter class in favor of supporting conversion from non-DART planners to DART planners in PlannerAdapter class.
…github.com/personalrobotics/aikido into enhancement/brianhou/metaskeleton-planners Conflicts: include/aikido/planner/dart/detail/DartPlannerAdapter-impl.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.
Looks good to me! Just one nitpick.
// Create an IK solver with MetaSkeleton DOFs | ||
auto matchingNodes = mMetaSkeleton->getBodyNodes( | ||
problem.getEndEffectorBodyNode()->getName()); | ||
if (matchingNodes.size() == 0) |
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: Checking emptiness is generally faster or equal to comparing the size. So let's change this to if (!matchingNodes.empty())
.
* Add MetaSkeleton to ConfigurationToEndEffectorOffsetPlanner. * Add more DART planners. Add ConfigurationToTSRPlanner. Add DART version of ConfigurationToConfigurationPlanner. * Add max samples to ConfigurationToTSR problem. * Implement single-problem PlannerAdapter class. * Implement single-problem DartPlannerAdapter class. * Add initial implementation of ConfigurationToConfiguration_to_ConfigurationToTSR adapter. * Format code. * Update ConfigurationToEndEffectorPose to MetaSkeletonStateSpace. * Write DartSingleProblemPlanner. Change ConfigurationToConfigurationPlanner. * Update the other two DART planners to use DartSingleProblemPlanner. * Rename dart::DartSingleProblemPlanner to dart::SingleProblemPlanner. * Fix formatting. [skip ci] * Update PlannerAdapter. Remove DartPlannerAdapter class in favor of supporting conversion from non-DART planners to DART planners in PlannerAdapter class. * Respond to nits from JS. * Make SequenceMetaPlanner use CompositePlanner constructor. * Respond to final nit from JS. * Update CHANGELOG * Add that line back in CHANGELOG.md
Re-implementation of #425.
Main changes:
MetaSkeleton
argument to the constructor of all "DART planners" inplanner::dart
. All DART planners now also definegetMetaSkeletonStateSpace
andgetMetaSkeleton
to make adapters possible. These methods are currently re-implemented in each planner, but they could (should?) be moved into adart::SingleProblemPlanner
class that all DART planners inherit from.dart::DartPlannerAdapter
class for converting planners that don't contain aMetaSkeleton
(i.e.SnapConfigurationToConfigurationPlanner
) into their corresponding DART planner (in this case,dart::ConfigurationToConfigurationPlanner
). This correspondence isn't enforced anywhere, but maybe some fancy template code could do so?dart::PlannerAdapter
class is essentially the same single-problem adapter from [WIP] Planning adapters #425, but only operates on DART planners that contain aMetaSkeleton
. We can't adapt a planner that doesn't contain aMetaSkeleton
into one that should.ConfigurationToConfiguration
toConfigurationToTSR
. It does a fewconst_cast
s, which we should look hard at to make sure that they're absolutely necessary.The pipeline to use a
SnapConfigurationToConfigurationPlanner
as adart::ConfigurationToTSRPlanner
now takes an extra step:The new intermediate step is necessary to adapt the non-DART
SnapConfigurationToConfigurationPlanner
into a DARTConfigurationToConfigurationPlanner
.Issues raised during this PR:
Planner
s have anRNG
? This is needed to create a bounds sampler for theIKSampleable
, so it might be convenient to include this with allPlanner
s in case an adapter needs it.Before creating a pull request
make format
Before merging a pull request
CHANGELOG.md