se2ez
collision.cpp
Go to the documentation of this file.
1 #include <se2ez/core/collision.h>
2 
3 using namespace se2ez;
4 
5 ///
6 /// ACM
7 ///
8 
9 void ACM::disable(const std::string &a, const std::string &b)
10 {
11  const auto &item = (a < b) ? std::make_pair(a, b) : std::make_pair(b, a);
12  disabled_.emplace(item);
13 }
14 
15 void ACM::enable(const std::string &a, const std::string &b)
16 {
17  const auto &item = (a < b) ? std::make_pair(a, b) : std::make_pair(b, a);
18  const auto &it = disabled_.find(item);
19 
20  if (it != disabled_.end())
21  disabled_.erase(it);
22 }
23 
24 bool ACM::collide(const std::string &a, const std::string &b) const
25 {
26  if (a != b)
27  {
28  const auto &item = (a < b) ? std::make_pair(a, b) : std::make_pair(b, a);
29  const auto &it = disabled_.find(item);
30  return it == disabled_.end();
31  }
32 
33  return false;
34 }
35 
36 void ACM::clear()
37 {
38  disabled_.clear();
39 }
40 
41 ///
42 /// Collision Manager
43 ///
44 
46 {
47  point = point + normal;
48  normal = -normal;
49 }
50 
51 CollisionManager::CollisionManager() : acm_(std::make_shared<ACM>())
52 {
53 }
54 
56 {
57  acm_ = acm;
58 }
59 
61 {
62  return acm_;
63 }
An allowed collision map / matrix for the robot. Stores what frames are allowed to collide with each ...
Definition: collision.h:38
T end(T... args)
virtual ACMPtr getACM()
Gets the current ACM.
Definition: collision.cpp:60
CollisionManager()
Constructor.
Definition: collision.cpp:51
T erase(T... args)
T make_pair(T... args)
T clear(T... args)
A shared pointer wrapper for se2ez::ACM.
T find(T... args)
std::set< std::pair< std::string, std::string > > disabled_
Set of all disabled frame pairs.
Definition: collision.h:65
ACMPtr acm_
ACM for collision manager.
Definition: collision.h:140
T emplace(T... args)
virtual void setACM(const ACMPtr &acm)
Sets a new ACM to use.
Definition: collision.cpp:55
Main namespace.
Definition: collision.h:11
void flip()
Flips the direction of the normal and swaps the endpoint.
Definition: collision.cpp:45
void clear()
Clears all entries within the ACM.
Definition: collision.cpp:36
bool collide(const std::string &a, const std::string &b) const
Returns true if frame a and frame b can collide.
Definition: collision.cpp:24
void enable(const std::string &a, const std::string &b)
Enable collision checking between frame a and b.
Definition: collision.cpp:15
void disable(const std::string &a, const std::string &b)
Disable collision checking between frame a and b.
Definition: collision.cpp:9