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

Add methods for removing groups in NonColliding. #247

Merged
merged 7 commits into from
Oct 24, 2017

Conversation

brianhou
Copy link
Contributor

@brianhou brianhou commented Oct 22, 2017


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

@brianhou brianhou added this to the Aikido 0.2.0 milestone Oct 22, 2017
@brianhou brianhou requested a review from jslee02 October 22, 2017 23:25
@codecov
Copy link

codecov bot commented Oct 23, 2017

Codecov Report

Merging #247 into master will increase coverage by 0.01%.
The diff coverage is 73.33%.

@@            Coverage Diff             @@
##           master     #247      +/-   ##
==========================================
+ Coverage    70.9%   70.92%   +0.01%     
==========================================
  Files         173      173              
  Lines        5118     5118              
  Branches      809      809              
==========================================
+ Hits         3629     3630       +1     
+ Misses       1001     1000       -1     
  Partials      488      488
Impacted Files Coverage Δ
include/aikido/constraint/NonColliding.hpp 100% <ø> (ø) ⬆️
src/constraint/NonColliding.cpp 86.66% <73.33%> (ø) ⬆️
src/planner/ompl/CRRT.cpp 63.95% <0%> (+0.58%) ⬆️

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.

It's not directly related to the changes of this PR, but, for the consistency, it would be nice to rename all the private member variable names to have the prefix m and begin with capital letters like mGroupsToPairwiseCheck.

CHANGELOG.md Outdated
@@ -2,6 +2,10 @@

### 0.2.0 (201X-XX-XX)

* Constraint

* Add methods for removing groups from NonColliding constraints. [#247](https://github.com/personalrobotics/aikido/pull/247)
Copy link
Member

Choose a reason for hiding this comment

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

Nit: The current convention is to use past tense for the leading verb.

@@ -50,10 +50,21 @@ class NonColliding : public Testable
std::shared_ptr<dart::collision::CollisionGroup> _group1,
std::shared_ptr<dart::collision::CollisionGroup> _group2);

/// Remove collision check between group1 and group2.
/// \param group1 First collision group.
Copy link
Member

Choose a reason for hiding this comment

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

Nit: The parameter names in this docstring are not consistent with the actual parameter names. I believe the convention is not to use a leading underscore for parameter names, but it seems this file doesn't comply. Let's fix this later as wholesale.

return;
}

// Check for reverse pair
Copy link
Member

Choose a reason for hiding this comment

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

I think we could remove this double checking by storing the groups in a pair (e.g., ascending or descending in the pointer addresses). For this, we should:

  • change addPairwiseCheck(...) to add group pair in ascending order something like:
  if (_group1 < _group2)
    groupsToPairwiseCheck.emplace_back(std::move(_group1), std::move(_group2));
  else
    groupsToPairwiseCheck.emplace_back(std::move(_group2), std::move(_group1));
  • change removePairwiseCheck(...) to find the ascending-ordered group pair

More importantly, I think we could use std::unordered_set instead of std::vector for better performance in adding and removing because we don't need random access, and the order of pairs is not important. In case we switch to std::unordered_set we might directly use std::unordered_set::erase without finding the pair.

auto it
= std::find(groupsToSelfCheck.begin(), groupsToSelfCheck.end(), _group);
if (it != groupsToSelfCheck.end())
groupsToSelfCheck.erase(it);
Copy link
Member

Choose a reason for hiding this comment

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

I think groupsToSelfCheck also can be std::unordered_set for the same reason with groupsToPairwiseCheck.

@brianhou brianhou merged commit 1196fd0 into master Oct 24, 2017
@brianhou brianhou deleted the enhancement/brianhou/remove-NonColliding branch October 24, 2017 22:43
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.

2 participants