All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Collision.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 /* Desc: Collision class
18  * Author: Nate Koenig
19  * Date: 13 Feb 2006
20  */
21 
22 #ifndef _COLLISION_HH_
23 #define _COLLISION_HH_
24 
25 #include <string>
26 #include <vector>
27 
28 #include "gazebo/common/Event.hh"
30 
33 #include "gazebo/physics/Entity.hh"
34 
35 namespace gazebo
36 {
37  namespace physics
38  {
41 
43  class Collision : public Entity
44  {
47  public: explicit Collision(LinkPtr _link);
48 
50  public: virtual ~Collision();
51 
53  public: virtual void Fini();
54 
57  public: virtual void Load(sdf::ElementPtr _sdf);
58 
60  public: virtual void Init();
61 
64  public: virtual void UpdateParameters(sdf::ElementPtr _sdf);
65 
68  public: void SetCollision(bool _placeable);
69 
73  public: bool IsPlaceable() const;
74 
77  public: virtual void SetCategoryBits(unsigned int _bits) = 0;
78 
81  public: virtual void SetCollideBits(unsigned int _bits) = 0;
82 
85  public: void SetLaserRetro(float _retro);
86 
89  public: float GetLaserRetro() const;
90 
93  public: LinkPtr GetLink() const;
94 
97  public: ModelPtr GetModel() const;
98 
101  public: virtual math::Box GetBoundingBox() const = 0;
102 
106  public: unsigned int GetShapeType();
107 
110  public: void SetShape(ShapePtr _shape);
111 
114  public: ShapePtr GetShape() const;
115 
118  public: void SetContactsEnabled(bool _enable);
119 
122  public: bool GetContactsEnabled() const;
123 
127  public: void AddContact(const Contact &_contact);
128 
131  public: virtual math::Vector3 GetRelativeLinearVel() const;
132 
136  public: virtual math::Vector3 GetWorldLinearVel() const;
137 
140  public: virtual math::Vector3 GetRelativeAngularVel() const;
141 
144  public: virtual math::Vector3 GetWorldAngularVel() const;
145 
148  public: virtual math::Vector3 GetRelativeLinearAccel() const;
149 
153  public: virtual math::Vector3 GetWorldLinearAccel() const;
154 
157  public: virtual math::Vector3 GetRelativeAngularAccel() const;
158 
162  public: virtual math::Vector3 GetWorldAngularAccel() const;
163 
166  public: CollisionState GetState();
167 
170  public: void SetState(const CollisionState &_state);
171 
173  public: template<typename T>
175  {return contact.Connect(_subscriber);}
176 
179  {contact.Disconnect(_conn);}
180 
183  public: void FillMsg(msgs::Collision &_msg);
184 
187  public: void ProcessMsg(const msgs::Collision &_msg);
188 
191  public: inline SurfaceParamsPtr GetSurface() const
192  {return this->surface;}
193 
197  public: virtual void SetMaxContacts(double _maxContacts);
198 
202  public: virtual int GetMaxContacts();
203 
206  private: msgs::Visual CreateCollisionVisual();
207 
209  protected: LinkPtr link;
210 
212  protected: bool placeable;
213 
215  protected: ShapePtr shape;
216 
218  private: bool contactsEnabled;
219 
221  private: event::EventT<void (const std::string &,
222  const Contact &)> contact;
223 
225  private: SurfaceParamsPtr surface;
226 
228  private: float laserRetro;
229 
231  private: CollisionState state;
232 
234  private: int maxContacts;
235  };
237  }
238 }
239 #endif