Collision.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2016 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 #include "gazebo/util/system.hh"
35 
36 namespace gazebo
37 {
38  namespace physics
39  {
42 
44  class GZ_PHYSICS_VISIBLE Collision : public Entity
45  {
48  public: explicit Collision(LinkPtr _link);
49 
51  public: virtual ~Collision();
52 
54  public: virtual void Fini();
55 
58  public: virtual void Load(sdf::ElementPtr _sdf);
59 
61  public: virtual void Init();
62 
65  public: virtual void UpdateParameters(sdf::ElementPtr _sdf);
66 
69  public: void SetCollision(bool _placeable);
70 
74  public: bool IsPlaceable() const;
75 
78  public: virtual void SetCategoryBits(unsigned int _bits) = 0;
79 
82  public: virtual void SetCollideBits(unsigned int _bits) = 0;
83 
86  public: void SetLaserRetro(float _retro);
87 
90  public: float GetLaserRetro() const;
91 
94  public: LinkPtr GetLink() const;
95 
98  public: ModelPtr GetModel() const;
99 
102  public: virtual math::Box GetBoundingBox() const = 0;
103 
107  public: unsigned int GetShapeType() const;
108 
111  public: void SetShape(ShapePtr _shape);
112 
115  public: ShapePtr GetShape() const;
116 
119  public: void SetScale(const math::Vector3 &_scale);
120 
123  public: virtual math::Vector3 GetRelativeLinearVel() const;
124 
128  public: virtual math::Vector3 GetWorldLinearVel() const;
129 
132  public: virtual math::Vector3 GetRelativeAngularVel() const;
133 
136  public: virtual math::Vector3 GetWorldAngularVel() const;
137 
140  public: virtual math::Vector3 GetRelativeLinearAccel() const;
141 
145  public: virtual math::Vector3 GetWorldLinearAccel() const;
146 
149  public: virtual math::Vector3 GetRelativeAngularAccel() const;
150 
154  public: virtual math::Vector3 GetWorldAngularAccel() const;
155 
158  public: CollisionState GetState();
159 
162  public: void SetState(const CollisionState &_state);
163 
166  public: void FillMsg(msgs::Collision &_msg);
167 
170  public: void ProcessMsg(const msgs::Collision &_msg);
171 
174  public: inline SurfaceParamsPtr GetSurface() const
175  {return this->surface;}
176 
180  public: virtual void SetMaxContacts(unsigned int _maxContacts);
181 
185  public: virtual unsigned int GetMaxContacts();
186 
190  public: void SetWorldPoseDirty();
191 
192  // Documentation inherited.
193  public: virtual const math::Pose &GetWorldPose() const;
194 
197  private: msgs::Visual CreateCollisionVisual();
198 
200  protected: LinkPtr link;
201 
203  protected: bool placeable;
204 
206  protected: ShapePtr shape;
207 
210 
212  private: float laserRetro;
213 
215  private: CollisionState state;
216 
218  private: unsigned int maxContacts;
219 
221  private: uint32_t collisionVisualId;
222 
224  private: mutable bool worldPoseDirty;
225  };
227  }
228 }
229 #endif
boost::shared_ptr< Link > LinkPtr
Definition: PhysicsTypes.hh:100
Forward declarations for the common classes.
Definition: Animation.hh:33
Encapsulates a position and rotation in three space.
Definition: Pose.hh:37
Base class for all collision entities.
Definition: Collision.hh:44
The Vector3 class represents the generic vector containing 3 elements.
Definition: Vector3.hh:39
ShapePtr shape
Pointer to physics::Shape.
Definition: Collision.hh:206
SurfaceParamsPtr surface
The surface parameters.
Definition: Collision.hh:209
Mathematical representation of a box and related functions.
Definition: Box.hh:35
LinkPtr link
The link this collision belongs to.
Definition: Collision.hh:200
bool placeable
Flag for placeable.
Definition: Collision.hh:203
default namespace for gazebo
boost::shared_ptr< SurfaceParams > SurfaceParamsPtr
Definition: PhysicsTypes.hh:160
Base class for all physics objects in Gazebo.
Definition: Entity.hh:58
boost::shared_ptr< Shape > ShapePtr
Definition: PhysicsTypes.hh:132
boost::shared_ptr< Model > ModelPtr
Definition: PhysicsTypes.hh:88
GAZEBO_VISIBLE void Init(google::protobuf::Message &_message, const std::string &_id="")
Initialize a message.
Store state information of a physics::Collision object.
Definition: CollisionState.hh:42
SurfaceParamsPtr GetSurface() const
Get the surface parameters.
Definition: Collision.hh:174