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 Nate Koenig
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 "common/Event.hh"
29 #include "common/CommonTypes.hh"
30 
31 #include "physics/PhysicsTypes.hh"
33 #include "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 
176  public: template<typename T>
178  {return contact.Connect(_subscriber);}
179 
183  {contact.Disconnect(_conn);}
184 
186  public: void FillCollisionMsg(msgs::Collision &_msg) GAZEBO_DEPRECATED;
187 
190  public: void FillMsg(msgs::Collision &_msg);
191 
194  public: void ProcessMsg(const msgs::Collision &_msg);
195 
198  public: inline SurfaceParamsPtr GetSurface() const
199  {return this->surface;}
200 
203  private: msgs::Visual CreateCollisionVisual();
204 
206  protected: LinkPtr link;
207 
209  protected: bool placeable;
210 
212  protected: ShapePtr shape;
213 
215  private: bool contactsEnabled;
216 
218  private: event::EventT<void (const std::string &,
219  const Contact &)> contact;
220 
222  private: SurfaceParamsPtr surface;
223 
225  private: float laserRetro;
226 
227  private: CollisionState state;
228  };
230  }
231 }
232 #endif