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

[WIP] return Colliding Bodies' Names if user given state is in collision #235

Closed
wants to merge 9 commits into from

Conversation

aditya-vk
Copy link
Contributor

@aditya-vk aditya-vk commented Oct 9, 2017

This PR forces the planning procedure to terminate if the user provided start state is in collision and prints the body nodes that are in collision.

WIP: Needs tests.


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

@codecov
Copy link

codecov bot commented Oct 9, 2017

Codecov Report

Merging #235 into master will not change coverage.
The diff coverage is 66.66%.

@@          Coverage Diff           @@
##           master    #235   +/-   ##
======================================
  Coverage    70.8%   70.8%           
======================================
  Files         172     172           
  Lines        5059    5059           
  Branches      802     802           
======================================
  Hits         3582    3582           
  Misses        993     993           
  Partials      484     484
Impacted Files Coverage Δ
include/aikido/constraint/Testable.hpp 100% <ø> (ø) ⬆️
...lude/aikido/constraint/uniform/RnBoxConstraint.hpp 100% <ø> (ø) ⬆️
src/constraint/uniform/SE2BoxConstraint.cpp 73.07% <ø> (ø) ⬆️
src/constraint/Satisfied.cpp 94.73% <ø> (ø) ⬆️
...constraint/uniform/detail/RnBoxConstraint-impl.hpp 69.07% <ø> (ø) ⬆️
include/aikido/constraint/TestableIntersection.hpp 100% <ø> (ø) ⬆️
include/aikido/constraint/Satisfied.hpp 100% <ø> (ø) ⬆️
include/aikido/constraint/TSR.hpp 100% <ø> (ø) ⬆️
include/aikido/constraint/FrameTestable.hpp 100% <ø> (ø) ⬆️
...ude/aikido/constraint/CartesianProductTestable.hpp 100% <ø> (ø) ⬆️
... and 14 more

@aditya-vk aditya-vk changed the title [WIP] return Colliding Bodies' Names if user given state is in collision return Colliding Bodies' Names if user given state is in collision Oct 10, 2017
Copy link
Member

@mkoval mkoval left a comment

Choose a reason for hiding this comment

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

This is a pretty gross way of returning the information. Instead, I suggest adding an optional output parameter to the base isSatisfied() interface that is populated with debugging information if provided.

This is a little tricky to implement because each implementation of Testable would populate different fields. Here is my best suggestion:

  1. Add a base class for Testable diagnostic information that is printable, to enable parity with the functionality that you have here:

    class TestableOutcome {
    public:
      bool is_satisfied() const = 0;
      virtual std::string to_string() const = 0;
    };
  2. Modify isSatisfied() to have an optional TestableOutcome output parameter:

    bool isSatisfied(const aikido::statespace::StateSpace::State* _state,
                     TestableOutcome* _outcome = nullptr);
  3. Implement a concrete subclass of TestableOutcome for each Testable constraint, e.g.:

    class NonCollidingOutcome : public virtual TestableOutcome {
      // implementation of is_satisfied() and to_string()
    }
  4. Add a pure virtual overload of isSatisfied() to the Testable base class to make it possible to call (2) without knowing the concrete type of TestableOutcome that must be passed in as the output parameter:

    bool isSatisfied(const aikido::statespace::StateSpace::State* _state,
                     std::unique_ptr<TestableOutcome>* _outcome = nullptr);

Given this architecture, this is how you would print the debugging information that you have today:

NonCollidingOutcome outcome;
noncolliding_testable.isSatisfied(state, &outcome);
std::cout << outcome.to_string() << std::endl;

If you don't know the type of Testable at compile time, you could use (4) to do this:

std::unique_ptr<TestableOutcome> outcome;
testable.isSatisfied(state, &outcome);
std::cout << outcome->to_string() << std::endl;

The key advantage of this API is that it provides programmatic access to the information that is currently printed to stdout. This is critical to implement good backtracking strategies for multi-step planning algorithms like MAGI.

@@ -14,8 +14,10 @@ class Testable
virtual ~Testable() = default;

/// Returns true if state satisfies this constraint.
/// \param _givenState: true if state is user-provided
Copy link
Member

Choose a reason for hiding this comment

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

What does this mean? Isn't _state always user provided? 😕

Copy link
Member

Choose a reason for hiding this comment

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

Nit: We don't use : (semicolon) for a parameter docstring.

Copy link
Member

Choose a reason for hiding this comment

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

I guess _state is set to false when the checking state is provided by a planner, and, in that case, we don't want to terminate the planning due (could reject the sample though).

I think we don't need _givenState parameter for enforcing the planner to terminate. It's actually done by the caller (see this). _givenState is just using to determine whether a concrete Testable prints.

I agree with @mkoval that changing the way of receiving debug information.

@aditya-vk
Copy link
Contributor Author

aditya-vk commented Oct 10, 2017

Great suggestions! Loved the point about the programmatic access.
Yeah, this is quite messy but was a quick hack-around to unblock some of the planning issues we were facing with pantry-loading demo (for instance, planner returns an invalid start state due to fingers colliding with each other when the hand closes around the glass but we had no access to this information previously). Created a PR so this issue can be tracked and completed appropriately soon. I should've probably left it as WIP.

@aditya-vk aditya-vk changed the title return Colliding Bodies' Names if user given state is in collision [WIP] return Colliding Bodies' Names if user given state is in collision Oct 10, 2017
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.

There are many "unused parameter" warnings due to _givenState. Currently, Travis CI doesn't test the working branch so it couldn't catch this. Please double check if all the warnings and errors (if any) on a local computer.

@@ -24,6 +24,11 @@ trajectory::InterpolatedPtr planOMPL(
double _maxPlanTime,
double _maxDistanceBtwValidityChecks)
{

Copy link
Member

Choose a reason for hiding this comment

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

Nit: Please remove unnecessary this whitespace

@@ -73,6 +78,10 @@ trajectory::InterpolatedPtr planOMPL(
double _maxPlanTime,
double _maxDistanceBtwValidityChecks)
{

Copy link
Member

Choose a reason for hiding this comment

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

Nit: Please remove unnecessary this whitespace

@@ -17,6 +17,10 @@ trajectory::InterpolatedPtr planSnap(
const std::shared_ptr<aikido::constraint::Testable>& constraint,
aikido::planner::PlanningResult& planningResult)
{

Copy link
Member

Choose a reason for hiding this comment

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

Nit: Please remove unnecessary this whitespace

@@ -218,6 +218,10 @@ trajectory::InterpolatedPtr planCRRT(
double _maxDistanceBtwProjections,
double _minStepsize)
{

Copy link
Member

Choose a reason for hiding this comment

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

Nit: Please remove unnecessary this whitespace

@@ -303,6 +307,10 @@ trajectory::InterpolatedPtr planCRRTConnect(
double _minStepsize,
double _minTreeConnectionDistance)
{

Copy link
Member

Choose a reason for hiding this comment

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

Nit: Please remove unnecessary this whitespace

@@ -14,8 +14,10 @@ class Testable
virtual ~Testable() = default;

/// Returns true if state satisfies this constraint.
/// \param _givenState: true if state is user-provided
Copy link
Member

Choose a reason for hiding this comment

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

Nit: We don't use : (semicolon) for a parameter docstring.

@@ -14,8 +14,10 @@ class Testable
virtual ~Testable() = default;

/// Returns true if state satisfies this constraint.
/// \param _givenState: true if state is user-provided
Copy link
Member

Choose a reason for hiding this comment

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

I guess _state is set to false when the checking state is provided by a planner, and, in that case, we don't want to terminate the planning due (could reject the sample though).

I think we don't need _givenState parameter for enforcing the planner to terminate. It's actually done by the caller (see this). _givenState is just using to determine whether a concrete Testable prints.

I agree with @mkoval that changing the way of receiving debug information.

@brianhou
Copy link
Contributor

I think we'll wind up rewriting this entirely per @mkoval's suggestion, so I'm just going to close this PR. The branch will still be somewhat useful until we have the new implementation, though.

@brianhou brianhou closed this Oct 12, 2017
@sniyaz sniyaz mentioned this pull request Nov 26, 2017
5 tasks
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