All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ContactManager.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2014 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 
18 #ifndef _CONTACTMANAGER_HH_
19 #define _CONTACTMANAGER_HH_
20 
21 #include <vector>
22 #include <string>
23 #include <map>
24 
25 #include <boost/unordered/unordered_set.hpp>
26 #include <boost/unordered/unordered_map.hpp>
27 #include <boost/thread/recursive_mutex.hpp>
28 
30 
33 #include "gazebo/util/system.hh"
34 
35 namespace gazebo
36 {
37  namespace physics
38  {
42  {
45 
48  public: boost::unordered_set<Collision *> collisions;
49 
53  public: std::vector<std::string> collisionNames;
54 
56  public: std::vector<Contact *> contacts;
57  };
58 
61 
66  {
68  public: ContactManager();
69 
71  public: virtual ~ContactManager();
72 
78  public: void Init(WorldPtr _world);
79 
92  public: Contact *NewContact(Collision *_collision1,
93  Collision *_collision2,
94  const common::Time &_time);
95 
97  public: unsigned int GetContactCount() const;
98 
103  public: Contact *GetContact(unsigned int _index) const;
104 
110  public: const std::vector<Contact *> &GetContacts() const;
111 
113  public: void Clear();
114 
116  public: void PublishContacts();
117 
119  public: void ResetCount();
120 
126  public: std::string CreateFilter(const std::string &_topic,
127  const std::vector<std::string> &_collisions);
128 
134  public: std::string CreateFilter(const std::string &_topic,
135  const std::string &_collision);
136 
143  public: std::string CreateFilter(const std::string &_name,
144  const std::map<std::string, physics::CollisionPtr>
145  &_collisions);
146 
149  public: void RemoveFilter(const std::string &_name);
150 
153  public: unsigned int GetFilterCount();
154 
158  public: bool HasFilter(const std::string &_name);
159 
160  private: std::vector<Contact*> contacts;
161 
162  private: unsigned int contactIndex;
163 
165  private: transport::NodePtr node;
166 
168  private: transport::PublisherPtr contactPub;
169 
171  private: WorldPtr world;
172 
175  private: boost::unordered_map<std::string, ContactPublisher *>
176  customContactPublishers;
177 
179  private: boost::recursive_mutex *customMutex;
180  };
182  }
183 }
184 #endif