Robowflex  v0.1
Making MoveIt Easy
acm.cpp
Go to the documentation of this file.
1 #include <robowflex_dart/acm.h>
3 
4 using namespace robowflex::darts;
5 
6 ///
7 /// ACM
8 ///
9 
10 ACM::ACM(const Structure *structure)
11  : structure_(structure), filter_(std::make_shared<dart::collision::BodyNodeCollisionFilter>())
12 {
13 }
14 
16 {
17  auto key = makeKey(a, b);
18  if (acm_.find(key) == acm_.end())
19  {
20  acm_.emplace(key);
21  filter_->addBodyNodePairToBlackList(getBodyNode(key.first), getBodyNode(key.second));
22  }
23 }
24 
26 {
27  auto key = makeKey(a, b);
28  auto it = acm_.find(key);
29  if (it != acm_.end())
30  {
31  filter_->removeBodyNodePairFromBlackList(getBodyNode(key.first), getBodyNode(key.second));
32  acm_.erase(it);
33  }
34 }
35 
37 {
38  return filter_;
39 }
40 
42 {
43  return filter_;
44 }
45 
47 {
48  return structure_;
49 }
50 
52 {
53  return acm_;
54 }
55 
57 {
58  return acm_;
59 }
60 
62 {
63  if (a < b)
64  return std::make_pair(a, b);
65 
66  return std::make_pair(b, a);
67 }
68 
69 dart::dynamics::BodyNode *ACM::getBodyNode(const std::string &key)
70 {
71  return structure_->getSkeletonConst()->getBodyNode(key);
72 }
const std::set< std::pair< std::string, std::string > > & getDisabledPairsConst() const
Get the pairs of frames that have collision disabled.
Definition: acm.cpp:56
std::set< std::pair< std::string, std::string > > & getDisabledPairs()
Get the pairs of frames that have collision disabled.
Definition: acm.cpp:51
std::shared_ptr< dart::collision::BodyNodeCollisionFilter > filter_
Collision filter.
Definition: acm.h:104
const Structure * structure_
Structure this ACM is for.
Definition: acm.h:102
std::shared_ptr< dart::collision::BodyNodeCollisionFilter > getFilter()
Get the Dart collision filter corresponding to this ACM.
Definition: acm.cpp:36
void disableCollision(const std::string &a, const std::string &b)
Disable collisions between body frames a and b.
Definition: acm.cpp:15
const std::shared_ptr< dart::collision::BodyNodeCollisionFilter > & getFilterConst() const
Get the Dart collision filter corresponding to this ACM.
Definition: acm.cpp:41
dart::dynamics::BodyNode * getBodyNode(const std::string &key)
Get the body node in the structure corresponding to the body frame name.
Definition: acm.cpp:69
ACM(const Structure *structure)
Constructor.
Definition: acm.cpp:10
std::pair< std::string, std::string > makeKey(const std::string &a, const std::string &b) const
Create a unique key for two frame names.
Definition: acm.cpp:61
std::set< std::pair< std::string, std::string > > acm_
Disabled collision pairs.
Definition: acm.h:103
void enableCollision(const std::string &a, const std::string &b)
Enable collisions between body frames a and b.
Definition: acm.cpp:25
const Structure * getStructure() const
Get the structure this ACM is for.
Definition: acm.cpp:46
Wrapper class for a dart::dynamics::Skeleton.
Definition: structure.h:53
const dart::dynamics::SkeletonPtr & getSkeletonConst() const
Get the underlying skeleton for the structure.
Definition: structure.cpp:113
T emplace(T... args)
T end(T... args)
T erase(T... args)
T find(T... args)
T make_pair(T... args)
DART-based robot modeling and planning.
Definition: acm.h:16