Skip to content
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

Refactor VFP with new Planner API #426

Merged
merged 17 commits into from
May 22, 2018
Merged

Refactor VFP with new Planner API #426

merged 17 commits into from
May 22, 2018

Conversation

sniyaz
Copy link

@sniyaz sniyaz commented May 17, 2018

This PR has changes that use the new Planner API to refactor VFP.

Right now I've only refactored planToEndEffectorOffset by creating the new VectorFieldConfigurationToEndEffectorOffsetPlanner class. While these changes are looked over, I'll refactor planToEndEffectorPose as well.

Summary of changes

  1. Create new ConfigurationToEndEffectorOffsetPlanner class for the ConfigurationToEndEffectorOffset Problem.

  2. Create VectorFieldConfigurationToEndEffectorOffsetPlanner class that extends the above and calls the old planToEndEffectorOffset method in VectorFieldPlanner.

TODOs

  1. We need to figure out to handle the startState provided by ConfigurationToEndEffectorOffset. The old VFP code gets the current configuration from the metaSkeleton, so right now I just ignore this instance variable.

  2. The old VFP code took minDistance and maxDistance for planToEndEffectorOffset. I provide these by taking a tolerance around the signedDistance provided by ConfigurationToEndEffectorOffset, but we should discuss whether this is appropriate (I also need to handle the negative case).


Before creating a pull request

  • Document new methods and classes
  • Format code with make format

Before merging a pull request

  • Set version target by selecting a milestone on the right side
  • Summarize this change in CHANGELOG.md
  • Add unit test(s) for this change

@sniyaz
Copy link
Author

sniyaz commented May 18, 2018

This is blocking on #429 right now. Once that gets merged, I'll rebase the actual Planner API changes from this PR on top of that one, and we should be good! 😄

@brianhou brianhou changed the base branch from master to VFP_const May 18, 2018 02:35
@brianhou brianhou changed the base branch from VFP_const to master May 18, 2018 02:35
auto metaskeletonStateSpace
= std::dynamic_pointer_cast<const MetaSkeletonStateSpace>(mStateSpace);
if (!metaskeletonStateSpace)
throw std::invalid_argument("mStateSpace is not MetaSkeletonStateSpace!");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is better to check this in the constructor

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For sure! My thinking is that this would require two casts: one in the constructor to check, and one when it's actually used. Are we OK with this?

Copy link
Author

@sniyaz sniyaz May 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NVM, this is moot with the discussion below since the type is enforced by the constructor argument now.

/// \param[out] result Information about success or failure.
/// \return Trajectory or \c nullptr if planning failed.
/// \throw If \c problem is not ConfigurationToEndEffectorOffset.
/// \throw If \c result is not ConfigurationToEndEffectorOffset::Result.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that these two validations are not yet added in the implementation.


#include "aikido/planner/ConfigurationToEndEffectorOffset.hpp"
#include "aikido/planner/ConfigurationToEndEffectorOffsetPlanner.hpp"
#include "aikido/planner/vectorfield/VectorFieldPlanner.hpp"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: It's not necessary to include this header here. Please move to the source.

///
/// \param[in] stateSpace State space that this planner associated with.
explicit ConfigurationToEndEffectorOffsetPlanner(
statespace::ConstStateSpacePtr stateSpace);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This planner only works for MetaSkeletonStateSpace. Please change this class to:

  • take ConstMetaSkeletonStateSpace in the constructor
  • have a getter getMetaSkeletonStateSpace() that returns the ConstStatespacePtr by static-casting it to ConstMetaSkeletonStateSpacePtr.
    to prevent passing incorrect state space in compile time.

/// checking.
/// \param[in] timelimit timeout in seconds.
VectorFieldConfigurationToEndEffectorOffsetPlanner(
statespace::ConstStateSpacePtr stateSpace,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change to take ConstMetaSkeletonStateSpacePtr for the same reason above.

double initialStepSize,
double jointLimitTolerance,
double constraintCheckResolution,
std::chrono::duration<double> timelimit);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parameters that are not planner specific parameters should move to the problem class. @dqyi11 Could you verify all the parameters are planner specific?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with the current scope of parameters defined in the problem class, which is consistent with the design in prpy. https://github.com/personalrobotics/prpy/blob/master/tests/planning/methods/PlanToEndEffectorOffset.py
All these parameters are planner-specific. Though some of them are used in both vector field planner and CRRT planner, they can be set very differently (for example constraintCheckResolution). distanceTolerance, positionTolerance and angularTolerance are also not strictly aligned in planning end-effector offset between using vector field planner and CRRT planner.

@sniyaz sniyaz changed the title [WIP] Refactor VFP with new Planner API Refactor VFP with new Planner API May 19, 2018
@codecov
Copy link

codecov bot commented May 21, 2018

Codecov Report

Merging #426 into master will increase coverage by 0.27%.
The diff coverage is 76.92%.

@@            Coverage Diff             @@
##           master     #426      +/-   ##
==========================================
+ Coverage   79.76%   80.03%   +0.27%     
==========================================
  Files         231      235       +4     
  Lines        5986     6002      +16     
==========================================
+ Hits         4775     4804      +29     
+ Misses       1211     1198      -13
Impacted Files Coverage Δ
...ikido/planner/ConfigurationToEndEffectorOffset.hpp 100% <ø> (+100%) ⬆️
src/planner/ConfigurationToEndEffectorOffset.cpp 73.68% <ø> (+73.68%) ⬆️
...lanner/ConfigurationToEndEffectorOffsetPlanner.cpp 100% <100%> (ø)
...lanner/ConfigurationToEndEffectorOffsetPlanner.hpp 100% <100%> (ø)
src/planner/vectorfield/VectorFieldPlanner.cpp 78.18% <100%> (+3.18%) ⬆️
...orFieldConfigurationToEndEffectorOffsetPlanner.hpp 100% <100%> (ø)
...orFieldConfigurationToEndEffectorOffsetPlanner.cpp 68.42% <68.42%> (ø)
... and 3 more

@sniyaz
Copy link
Author

sniyaz commented May 21, 2018

I think the start state should be the last thing to figure out now.

@jslee02 I had to use a dynamic_pointer_cast to go from ConstStatespacePtr ---> ConstMetaSkeletonStateSpacePtr. Apparently you can't use static_cast to downcast when virtual inheritance is involved? There's definitely a chance I'm wrong on this, so LMK.

problem.getConstraint(),
problem.getDirection(),
// TODO: Need to handle case when negative.
problem.getDistance() - mDistanceTolerance,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is better to check whether that problem.getDistance() - mDistanceTolerance and problem.getDistance() + mDistanceTolerance have the same sign...

@sniyaz
Copy link
Author

sniyaz commented May 22, 2018

I've handled the startState issue by setting the metaSkeleton to the startState given in the ConfigurationToEndEffectorOffset problem class. This is done by changing the old VFP code to take a startState and setting it in that function.

I've also made the stateSpace and startState arguments to that class constructor more restrictive, since ConfigurationToEndEffectorOffset problems can only be used with MetaSkeletonStateSpace.

jslee02
jslee02 previously approved these changes May 22, 2018
Copy link
Member

@jslee02 jslee02 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

dqyi11
dqyi11 previously approved these changes May 22, 2018
@jslee02 jslee02 dismissed stale reviews from dqyi11 and themself via 3865bb0 May 22, 2018 22:19
@jslee02 jslee02 merged commit 24618c5 into master May 22, 2018
@jslee02 jslee02 deleted the VFP_refactor branch May 22, 2018 22:19
gilwoolee pushed a commit that referenced this pull request Jan 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants