ContactManager.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2015 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
std::vector< std::string > collisionNames
Definition: ContactManager.hh:53
Base class for all collision entities.
Definition: Collision.hh:44
Forward declarations for transport.
A contact between two collisions.
Definition: Contact.hh:54
default namespace for gazebo
A custom contact publisher created for each contact filter in the Contact Manager.
Definition: ContactManager.hh:41
std::vector< Contact * > contacts
A list of contacts associated to the collisions.
Definition: ContactManager.hh:56
transport::PublisherPtr publisher
Contact message publisher.
Definition: ContactManager.hh:44
boost::shared_ptr< World > WorldPtr
Definition: PhysicsTypes.hh:78
boost::shared_ptr< Node > NodePtr
Definition: TransportTypes.hh:57
GAZEBO_VISIBLE void Init(google::protobuf::Message &_message, const std::string &_id="")
Initialize a message.
boost::shared_ptr< Publisher > PublisherPtr
Definition: TransportTypes.hh:49
boost::unordered_set< Collision * > collisions
Pointers of collisions monitored by contact manager for contacts.
Definition: ContactManager.hh:48
Aggregates all the contact information generated by the collision detection engine.
Definition: ContactManager.hh:65
#define GAZEBO_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system.hh:48
A Time class, can be used to hold wall- or sim-time.
Definition: Time.hh:43