Collision.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 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 #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 
70  public: void SetCollision(bool _placeable);
71 
74  public: void SetPlaceable(const bool _placeable);
75 
79  public: bool IsPlaceable() const;
80 
83  public: virtual void SetCategoryBits(unsigned int _bits) = 0;
84 
87  public: virtual void SetCollideBits(unsigned int _bits) = 0;
88 
91  public: void SetLaserRetro(float _retro);
92 
95  public: float GetLaserRetro() const;
96 
99  public: LinkPtr GetLink() const;
100 
103  public: ModelPtr GetModel() const;
104 
107  public: virtual math::Box GetBoundingBox() const = 0;
108 
112  public: unsigned int GetShapeType() const;
113 
116  public: void SetShape(ShapePtr _shape);
117 
120  public: ShapePtr GetShape() const;
121 
124  public: void SetScale(const math::Vector3 &_scale);
125 
128  public: virtual math::Vector3 GetRelativeLinearVel() const;
129 
133  public: virtual math::Vector3 GetWorldLinearVel() const;
134 
137  public: virtual math::Vector3 GetRelativeAngularVel() const;
138 
141  public: virtual math::Vector3 GetWorldAngularVel() const;
142 
145  public: virtual math::Vector3 GetRelativeLinearAccel() const;
146 
150  public: virtual math::Vector3 GetWorldLinearAccel() const;
151 
154  public: virtual math::Vector3 GetRelativeAngularAccel() const;
155 
159  public: virtual math::Vector3 GetWorldAngularAccel() const;
160 
163  public: CollisionState GetState();
164 
167  public: void SetState(const CollisionState &_state);
168 
171  public: void FillMsg(msgs::Collision &_msg);
172 
175  public: void ProcessMsg(const msgs::Collision &_msg);
176 
179  public: inline SurfaceParamsPtr GetSurface() const
180  {return this->surface;}
181 
185  public: virtual void SetMaxContacts(unsigned int _maxContacts);
186 
190  public: virtual unsigned int GetMaxContacts();
191 
195  public: void SetWorldPoseDirty();
196 
197  // Documentation inherited.
198  public: virtual const math::Pose &GetWorldPose() const;
199 
202  private: msgs::Visual CreateCollisionVisual();
203 
205  protected: LinkPtr link;
206 
208  protected: bool placeable;
209 
211  protected: ShapePtr shape;
212 
215 
217  private: float laserRetro;
218 
220  private: CollisionState state;
221 
223  private: unsigned int maxContacts;
224 
226  private: uint32_t collisionVisualId;
227 
229  private: mutable bool worldPoseDirty;
230  };
232  }
233 }
234 #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:211
SurfaceParamsPtr surface
The surface parameters.
Definition: Collision.hh:214
Mathematical representation of a box and related functions.
Definition: Box.hh:35
LinkPtr link
The link this collision belongs to.
Definition: Collision.hh:205
bool placeable
Flag for placeable.
Definition: Collision.hh:208
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:179