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 
24 #include <boost/unordered/unordered_set.hpp>
25 #include <boost/unordered/unordered_map.hpp>
26 
28 
31 
32 namespace gazebo
33 {
34  namespace physics
35  {
39  {
42 
45  public: boost::unordered_set<Collision *> collisions;
46 
50  public: std::vector<std::string> collisionNames;
51 
53  public: std::vector<Contact *> contacts;
54  };
55 
58 
63  {
65  public: ContactManager();
66 
68  public: virtual ~ContactManager();
69 
75  public: void Init(WorldPtr _world);
76 
89  public: Contact *NewContact(Collision *_collision1,
90  Collision *_collision2,
91  const common::Time &_time);
92 
94  public: unsigned int GetContactCount() const;
95 
100  public: Contact *GetContact(unsigned int _index) const;
101 
107  public: const std::vector<Contact *> &GetContacts() const;
108 
110  public: void Clear();
111 
113  public: void PublishContacts();
114 
116  public: void ResetCount();
117 
123  public: std::string CreateFilter(const std::string &_topic,
124  const std::vector<std::string> &_collisions);
125 
131  public: std::string CreateFilter(const std::string &_topic,
132  const std::string &_collision);
133 
134  private: std::vector<Contact*> contacts;
135 
136  private: unsigned int contactIndex;
137 
139  private: transport::NodePtr node;
140 
142  private: transport::PublisherPtr contactPub;
143 
145  private: WorldPtr world;
146 
149  private: boost::unordered_map<std::string, ContactPublisher *>
150  customContactPublishers;
151  };
153  }
154 }
155 #endif