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

Fix issues discovered during demo. #442

Merged
merged 64 commits into from
Jul 11, 2018
Merged

Fix issues discovered during demo. #442

merged 64 commits into from
Jul 11, 2018

Conversation

sniyaz
Copy link

@sniyaz sniyaz commented Jun 6, 2018

This PR adresses issues related to the new Planner. These issues were discovered while trying to use the new code with the soda demo.

Summary of Changes

  1. Change Problem derivative classes relative to the demo to use ScopedState internally to prevent dangling pointers.

  2. Add a ConfigurationToConfigurationPlanner in the DART planner space that takes a MetaSkeleton.

  3. Add ConfigurationToConfiguration_to_ConfigurationToConfiguration adapter that turns the standard ConfigurationToConfiguration planner into the DART one.

  4. Remove start states from DART Problem classes. This is because the start state should be taken form the MetaSkeleton, and it's why 2 and 3 are necessary.

  5. Make direction passed to ConfigurationToEndEffectorOffset constructor a boost::optional. If it's empty, getDirection returns the current direction of the end effector body node (needed to make planning straight with VFP possible in the demo).

  6. Add getTrajectoryPostProcessor method to ConcreteRobot class. We need this in libherb.

  7. ConfigurationToConfiguration_to_ConfigurationToTSR has been fixed by taking an RNG in the constructor and using this when creating the sampler. The plan() method now checks whether the problem's bodynode is in the skeleton the MetaSkeleton corresponds to (in cases where the hand is not in the MetaSkeleton itself, such as with HERB).


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

…urn bodyNode direction if passed direction was zero vector.
…at problems can store a cloned, scoped version of the passed state.
@sniyaz sniyaz changed the title Fixes discovered during DEMO. Fix issues discovered during demo. Jun 6, 2018
@sniyaz sniyaz requested review from gilwoolee, jslee02 and brianhou June 6, 2018 02:21
@sniyaz
Copy link
Author

sniyaz commented Jun 29, 2018

I fixed the nits, but I'm trying to fix a build issue with Clan/OSX on Travis.

@brianhou
Copy link
Contributor

Hmm, it looks like a potentially weird dependency issue with dart/nlopt/libccd? Here's the error message (which is repeated several times):

CMake Error in src/common/CMakeLists.txt:
Imported target "dart-optimizer-nlopt" includes non-existent path
"/usr/local/Cellar/libccd/2.0_2/include"
in its INTERFACE_INCLUDE_DIRECTORIES. Possible reasons include:

  • The path was deleted, renamed, or moved to another location.
  • An install or uninstall procedure did not complete successfully.
  • The installation package was faulty and references files it does not
    provide.

@sniyaz
Copy link
Author

sniyaz commented Jul 1, 2018

Yeah, after some googling a CMake file in DART may be the issue? Did we change which version of DART gets used in the OSX test environment?

jslee02
jslee02 previously approved these changes Jul 1, 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.

The macOS failure seems not related to the changes of this PR.

Could you please check if the master branch also fails to build on macOS? If so, let's create an issue to track it and merge this PR as it is.

@jslee02
Copy link
Member

jslee02 commented Jul 1, 2018

I believe the macOS build failure is due to that the bottles of dartsim haven't been updated after libccd updated. This should be fixed once Homebrew/homebrew-core#29620 is merged.

@@ -44,6 +49,9 @@ class Planner
protected:
/// State space associated with this planner.
statespace::ConstStateSpacePtr mStateSpace;

/// RNG the planner uses.
std::unique_ptr<common::RNG> mRng;
Copy link
Contributor

Choose a reason for hiding this comment

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

If we're taking in a raw RNG pointer, do we need to store this as a unique_ptr?

Copy link
Author

Choose a reason for hiding this comment

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

I think we could store is as either, since this is hidden from the user. I picked a unique pointer for convenience, since I create a default RNG if one isn't given, and unique pointers handle memory management once the Planner object is destructed (if my understadning of C++ is correct, which it might not be 😅). Otherwise I think we'd need a custom destructor, since we'd malloc a new RNG.

: Problem(stateSpace, std::move(constraint))
, mMetaSkeletonStateSpace(stateSpace)
, mMetaSkeleton(std::move(metaSkeleton))
, mStartState(std::move(mMetaSkeletonStateSpace->createState()))
Copy link
Contributor

Choose a reason for hiding this comment

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

@jslee02 Are these explicit std::moves for mStartState and mGoalState necessary? Based on my limited understanding of rvalues, those expressions might already be rvalues and therefore std::move is unnecessary?

Copy link
Author

Choose a reason for hiding this comment

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

Yeah, I agree with this. @jslee02 can you confirm?

// instance variable to avoid dangling pointers.
if (mMetaSkeleton)
{
auto startState = mMetaSkeletonStateSpace->createState();
Copy link
Contributor

Choose a reason for hiding this comment

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

Could this just be

if (mMetaSkeleton)
  mMetaSkeletonStateSpace->getState(mMetaSkeleton.get(), mStartState);

It seems that mStartState is already a MetaSkeletonStateSpace::ScopedState, so I'm not sure why mStateSpace needs to be used here.

namespace dart {

class ConfigurationToConfiguration_to_ConfigurationToConfiguration
: public PlannerAdapter<aikido::planner::
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: I think aikido:: is unnecessary here?

@@ -57,30 +63,27 @@ ConfigurationToConfiguration_to_ConfigurationToTSR::plan(
auto ik = InverseKinematics::create(endEffectorBodyNode);
ik->setDofs(mMetaSkeleton->getDofs());

// Convert TSR constraint into IK constraint
// Get the start state form the MetaSkeleton, since this is a DART planner.
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo: form -> from

@@ -16,27 +17,85 @@ namespace dart {
class ConfigurationToEndEffectorOffset : public Problem
Copy link
Contributor

Choose a reason for hiding this comment

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

We should augment this documentation here with the types of constructors that are supported.

// instance variable to avoid dangling pointers.
if (mMetaSkeleton)
{
auto startState = mMetaSkeletonStateSpace->createState();
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above?

// limits, as well as the passed constraint.
/// \param[in] metaSkeleton The MetaSkeleton whose limits must be respected.
std::shared_ptr<aikido::planner::TrajectoryPostProcessor>
getTrajectoryPostProcessor(
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm fine with this for now, but in light of the discussion from #443 it seems that maybe it doesn't make sense to have this here? I think we should probably set up the postprocessor in the concrete robot constructor, similar to how we set up the metaplanner.

statespace::dart::ConstMetaSkeletonStateSpacePtr stateSpace,
::dart::dynamics::ConstMetaSkeletonPtr metaSkeleton,
const statespace::dart::MetaSkeletonStateSpace::State* goalState,
constraint::ConstTestablePtr constraint);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we allow nullptr for constraint and make it default to Satisfied if nullptr is passed?

Copy link
Author

Choose a reason for hiding this comment

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

It looks like the default Problem class handles this:

if (!mConstraint)

Copy link
Member

@jslee02 jslee02 Jul 7, 2018

Choose a reason for hiding this comment

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

@sniyaz That's true. I think all we need to do here is just to pass nullptr as the default value to constraint.

ConfigurationToConfigurationPlanner>
{
public:
ConfigurationToConfiguration_to_ConfigurationToConfiguration(
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add docstring to this. :)

@@ -10,12 +10,14 @@ namespace planner {
namespace dart {

class ConfigurationToConfiguration_to_ConfigurationToTSR
: public PlannerAdapter<ConfigurationToConfigurationPlanner,
: public PlannerAdapter<aikido::planner::
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: same as @brianhou 's comment above, aikido::planner wouldn't be necessary here.

///
/// \param[in] stateSpace State space.
/// param[in] metaSkeleton MetaSkeleton that getStartState will return the
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: typo. \param[in]

, mDistance(signedDistance)
{
if (direction.squaredNorm() == 0)
if (mDirection.get().squaredNorm() == 0)
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this be <= 1e-3 or something that's not exactly zero?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is only here because normalizing a zero vector throws an error. I don't think it's wrong to pass in a small-magnitude vector and use that resulting direction, so I think comparing exactly to zero is fine. However, I think it might be better to use .isZero() rather than .squaredNorm() == 0.

, mDirection(direction)
, mDistance(signedDistance)
{
if (mDirection.get().squaredNorm() == 0)
Copy link
Contributor

Choose a reason for hiding this comment

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

Same question as above.

jslee02
jslee02 previously approved these changes Jul 7, 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.

Left a few nit comments. Almost there. 😄

/// end-effector BodyNode's current direction.
///
/// \param[in] stateSpace State space.
/// param[in] metaSkeleton MetaSkeleton that getStartState will return the
Copy link
Member

Choose a reason for hiding this comment

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

Nit: \param[in]

@@ -47,26 +111,34 @@ class ConfigurationToEndEffectorOffset : public Problem
/// while maintaining the current orientation.
::dart::dynamics::ConstBodyNodePtr getEndEffectorBodyNode() const;

/// Returns the start state.
/// Return the start state to plan from, either set on construction or
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Returns

const statespace::dart::MetaSkeletonStateSpace::State* startState,
::dart::dynamics::ConstBodyNodePtr endEffectorBodyNode,
double signedDistance,
constraint::ConstTestablePtr constraint);
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Let's pass nullptr to constraint as the default value for the same reason.

/// Returns the direction of motion specified in the world frame. Note that
/// if no direction was passed, the current direction of the end effector body
/// node is returned.
const Eigen::Vector3d getDirection() const;
Copy link
Member

Choose a reason for hiding this comment

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

Nit: No point to return const value.

///
/// \param[in] stateSpace State space.
/// param[in] metaSkeleton MetaSkeleton that getStartState will return the
Copy link
Member

Choose a reason for hiding this comment

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

Nit: \param[in]

::dart::dynamics::ConstBodyNodePtr endEffectorBodyNode,
const Eigen::Isometry3d& goalPose,
constraint::ConstTestablePtr constraint);
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Let's pass nullptr to constraint as the default value for the same reason.

const statespace::dart::MetaSkeletonStateSpace::State* startState,
::dart::dynamics::ConstBodyNodePtr endEffectorBodyNode,
const Eigen::Isometry3d& goalPose,
constraint::ConstTestablePtr constraint);
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Let's pass nullptr to constraint as the default value for the same reason.

::dart::dynamics::ConstBodyNodePtr endEffectorBodyNode,
std::size_t maxSamples,
constraint::dart::ConstTSRPtr goalTSR,
constraint::ConstTestablePtr constraint);
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Let's pass nullptr to constraint as the default value for the same reason.

const statespace::dart::MetaSkeletonStateSpace::State* startState,
::dart::dynamics::ConstBodyNodePtr endEffectorBodyNode,
std::size_t maxSamples,
constraint::dart::ConstTSRPtr goalTSR,
constraint::ConstTestablePtr constraint);
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Let's pass nullptr to constraint as the default value for the same reason.

@@ -46,22 +68,30 @@ class ConfigurationToTSR : public Problem
/// Returns the maximum number of TSR samples to plan to.
std::size_t getMaxSamples() const;

/// Returns the start state.
/// Return the start state to plan from, either set on construction or
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Returns

gilwoolee
gilwoolee previously approved these changes Jul 9, 2018
@sniyaz sniyaz dismissed stale reviews from gilwoolee and jslee02 via 204cd21 July 10, 2018 23:34
@sniyaz sniyaz added this to the Aikido 0.3.0 milestone Jul 10, 2018
@brianhou
Copy link
Contributor

It looks like the only failures are due to the pending Homebrew PR, so I'm going to merge this. Thanks for all the changes!

@brianhou brianhou merged commit f05e40b into master Jul 11, 2018
@brianhou brianhou deleted the sniyaz/new_demo branch July 11, 2018 20:03
Ponzel added a commit that referenced this pull request Jul 17, 2018
gilwoolee pushed a commit that referenced this pull request Jan 21, 2019
* Test with COnfitoConf and seems to work!

* Add getTrajectoryPostProcessor() method to ConcreteRobot class.

* Make ConfigurationToEndEffectorOffset and ConfigurationToTSR problems also use ScopedState internally.

* HACK: Make ConfigurationToEndEffectorOffset getDirection() method return bodyNode direction if passed direction was zero vector.

* Fix ConfigurationToConfiguration_to_ConfigurationToTSR adapter now that problems can store a cloned, scoped version of the passed state.

* HACK: Fix hack for returning current BN direction in Offset problem (for moving straight).

* HACK: Get around HERB hand BN not being in arm metaSkeleton, and nullptr RNG.

* HACK: Update hacks to work with MAGI.

* HACK: Got left out of last commit.

* HACK: Cap samples in DART TSR adapter. Use better random seed.

* Make getTrajectoryPostProcessor take needed args.

* Make getTrajectoryPostProcessor take constraint checking params.

* Do BN check in TSR adapter correctly by using the skeleton.

* Add RNG to ConfigurationToConfiguration_to_ConfigurationToTSR.

* Remove startState from DART problems. Need to fix tests.

* Add DART ConfigurationToConfigurationPlanner.

* Add new adapter that turns non-DART ConfTOConf planner into a DART one.

* Update tests for removing startState from DART problems.

* Run make format on last commit.

* Fix tests from adding RNG to TSR adapter.

* Fix naming ambiguity that made TSR adapter not build.

* Use boost:none instead of zero vector to get straight direction in offset problem.

* Make Offset problem take optional as reference.

* Clean up Offset problem comments and restore zero vector check.

* Remove TSR adapter hack to prevent inf loops.

* HACK BODY NODE FALLS OFF

* HACK HACK HACK.

* HACK HACK JH

* HACK: IKJDSHFKJDSHFKJDSHFKDSHFLJDHFSKJHDSFKJDHF

* Revert "HACK: IKJDSHFKJDSHFKJDSHFKDSHFLJDHFSKJHDSFKJDHF"

This reverts commit 40482d3.

* Revert "HACK HACK JH"

This reverts commit 42cd655.

* Revert "HACK HACK HACK."

This reverts commit 85eee66.

* Revert "HACK BODY NODE FALLS OFF"

This reverts commit 40b1207.

* Update ConfigurationToEndEffectorOffset to use multiple constructors.

* Update getStartState in ConfigurationToEndEffectorOffset.

* Update ConfigurationToEndEffectorPose to use two constructors and restore getStartState. Fix state passing in ConfigurationToEndEffectorOffset.

* Update ConfigurationToTSR to use multiple constructors and restore getStartState.

* Update TSR adapter to just use getStartState().

* Pass start state to VFP.

* Revert "Update TSR adapter to just use getStartState()."

This reverts commit 976b443.

* UpdateDART planning problems to not return dangling pointers with getStateState().

* Draft dart/ConfigurationToConfiguration.hpp

* Draft dart/ConfigurationToConfiguration.cpp

* Make adapter use right ConfigToConfig Problem.

* Trim fat in new getTrajectoryPostProcessor method.

* Fix tests with what we have now.

* Run make format.

* Make Planner take RNG.

* Add rng arg to SingleProblemPlanner and ConfigurationToConfigurationPlanner constructors to enable future OMPL planners to take RNG.

* Use delegate RNG in TSR adapter. Make tests build again.

* Move getEndEffectorDirection into robot/util

* Create planner/dart/util and put getEndEffectorDirection there instead.

* Change Planner to take raw RNG pointer, and getRng to return this raw pointer.

* Respond to nits.

* Fix RNG destruction in Planner class.

* Repond to latest review comments.

* Remove some std::moves to fix RVO build issue with OSX.

* Nab one std::move missed by the last commit..

* Use getState in DART planning problems.

* Remove uneeded aikido::'s in ConfigurationToConfiguration_to_ConfigurationToConfiguration.

* Run make format.

* Respond to all but one of Gilwoo's nits.

* Respond to some more nits.
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.

6 participants