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 2012 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 
29 
32 
33 namespace gazebo
34 {
35  namespace physics
36  {
40  {
43 
46  public: boost::unordered_set<Collision *> collisions;
47 
51  public: std::vector<std::string> collisionNames;
52 
54  public: std::vector<Contact *> contacts;
55  };
56 
59 
64  {
66  public: ContactManager();
67 
69  public: virtual ~ContactManager();
70 
76  public: void Init(WorldPtr _world);
77 
90  public: Contact *NewContact(Collision *_collision1,
91  Collision *_collision2,
92  const common::Time &_time);
93 
95  public: unsigned int GetContactCount() const;
96 
101  public: Contact *GetContact(unsigned int _index) const;
102 
108  public: const std::vector<Contact *> &GetContacts() const;
109 
111  public: void Clear();
112 
114  public: void PublishContacts();
115 
117  public: void ResetCount();
118 
124  public: std::string CreateFilter(const std::string &_topic,
125  const std::vector<std::string> &_collisions);
126 
132  public: std::string CreateFilter(const std::string &_topic,
133  const std::string &_collision);
134 
141  public: std::string CreateFilter(const std::string &_name,
142  const std::map<std::string, physics::CollisionPtr>
143  &_collisions);
144 
145  private: std::vector<Contact*> contacts;
146 
147  private: unsigned int contactIndex;
148 
150  private: transport::NodePtr node;
151 
153  private: transport::PublisherPtr contactPub;
154 
156  private: WorldPtr world;
157 
160  private: boost::unordered_map<std::string, ContactPublisher *>
161  customContactPublishers;
162  };
164  }
165 }
166 #endif