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 #ifndef GAZEBO_PHYSICS_COLLISION_HH_
18 #define GAZEBO_PHYSICS_COLLISION_HH_
19 
20 #include <string>
21 #include <vector>
22 
23 #include "gazebo/common/Event.hh"
24 
27 #include "gazebo/physics/Entity.hh"
28 #include "gazebo/util/system.hh"
29 
30 namespace gazebo
31 {
32  namespace physics
33  {
36 
38  class GZ_PHYSICS_VISIBLE Collision : public Entity
39  {
42  public: explicit Collision(LinkPtr _link);
43 
45  public: virtual ~Collision();
46 
48  public: virtual void Fini();
49 
52  public: virtual void Load(sdf::ElementPtr _sdf);
53 
55  public: virtual void Init();
56 
59  public: virtual void UpdateParameters(sdf::ElementPtr _sdf);
60 
63  public: void SetCollision(bool _placeable);
64 
68  public: bool IsPlaceable() const;
69 
72  public: virtual void SetCategoryBits(unsigned int _bits) = 0;
73 
76  public: virtual void SetCollideBits(unsigned int _bits) = 0;
77 
80  public: void SetLaserRetro(float _retro);
81 
84  public: float GetLaserRetro() const;
85 
88  public: LinkPtr GetLink() const;
89 
92  public: ModelPtr GetModel() const;
93 
96  public: virtual ignition::math::Box BoundingBox() const = 0;
97 
101  public: unsigned int GetShapeType() const;
102 
105  public: void SetShape(ShapePtr _shape);
106 
109  public: ShapePtr GetShape() const;
110 
114  public: void SetScale(const math::Vector3 &_scale) GAZEBO_DEPRECATED(8.0);
115 
118  public: void SetScale(const ignition::math::Vector3d &_scale);
119 
123  public: virtual math::Vector3 GetRelativeLinearVel() const
124  GAZEBO_DEPRECATED(8.0);
125 
128  public: virtual ignition::math::Vector3d RelativeLinearVel() const;
129 
134  public: virtual math::Vector3 GetWorldLinearVel() const
135  GAZEBO_DEPRECATED(8.0);
136 
140  public: virtual ignition::math::Vector3d WorldLinearVel() const;
141 
145  public: virtual math::Vector3 GetRelativeAngularVel() const
146  GAZEBO_DEPRECATED(8.0);
147 
150  public: virtual ignition::math::Vector3d RelativeAngularVel() const;
151 
155  public: virtual math::Vector3 GetWorldAngularVel() const
156  GAZEBO_DEPRECATED(8.0);
157 
160  public: virtual ignition::math::Vector3d WorldAngularVel() const;
161 
165  public: virtual math::Vector3 GetRelativeLinearAccel() const
166  GAZEBO_DEPRECATED(8.0);
167 
170  public: virtual ignition::math::Vector3d RelativeLinearAccel() const;
171 
176  public: virtual math::Vector3 GetWorldLinearAccel() const
177  GAZEBO_DEPRECATED(8.0);
178 
182  public: virtual ignition::math::Vector3d WorldLinearAccel() const;
183 
187  public: virtual math::Vector3 GetRelativeAngularAccel() const
188  GAZEBO_DEPRECATED(8.0);
189 
192  public: virtual ignition::math::Vector3d RelativeAngularAccel() const;
193 
198  public: virtual math::Vector3 GetWorldAngularAccel() const
199  GAZEBO_DEPRECATED(8.0);
200 
204  public: virtual ignition::math::Vector3d WorldAngularAccel() const;
205 
208  public: CollisionState GetState();
209 
212  public: void SetState(const CollisionState &_state);
213 
216  public: void FillMsg(msgs::Collision &_msg);
217 
220  public: void ProcessMsg(const msgs::Collision &_msg);
221 
224  public: inline SurfaceParamsPtr GetSurface() const
225  {return this->surface;}
226 
230  public: virtual void SetMaxContacts(unsigned int _maxContacts);
231 
235  public: virtual unsigned int GetMaxContacts();
236 
240  public: void SetWorldPoseDirty();
241 
242  // Documentation inherited.
244  public: virtual const math::Pose GetWorldPose() const
245  GAZEBO_DEPRECATED(8.0);
246 
247  // Documentation inherited.
248  public: virtual const ignition::math::Pose3d &WorldPose() const;
249 
252  private: msgs::Visual CreateCollisionVisual();
253 
255  protected: LinkPtr link;
256 
258  protected: bool placeable;
259 
261  protected: ShapePtr shape;
262 
265 
267  private: float laserRetro;
268 
270  private: CollisionState state;
271 
273  private: unsigned int maxContacts;
274 
276  private: uint32_t collisionVisualId;
277 
279  private: mutable bool worldPoseDirty;
280  };
282  }
283 }
284 #endif
boost::shared_ptr< Link > LinkPtr
Definition: PhysicsTypes.hh:109
Forward declarations for the common classes.
Definition: Animation.hh:33
Encapsulates a position and rotation in three space.
Definition: Pose.hh:42
Base class for all collision entities.
Definition: Collision.hh:38
The Vector3 class represents the generic vector containing 3 elements.
Definition: Vector3.hh:44
ShapePtr shape
Pointer to physics::Shape.
Definition: Collision.hh:261
SurfaceParamsPtr surface
The surface parameters.
Definition: Collision.hh:264
LinkPtr link
The link this collision belongs to.
Definition: Collision.hh:255
bool placeable
Flag for placeable.
Definition: Collision.hh:258
default namespace for gazebo
boost::shared_ptr< SurfaceParams > SurfaceParamsPtr
Definition: PhysicsTypes.hh:169
SurfaceParamsPtr GetSurface() const
Get the surface parameters.
Definition: Collision.hh:224
Base class for all physics objects in Gazebo.
Definition: Entity.hh:56
#define GAZEBO_DEPRECATED(version)
Definition: system.hh:302
boost::shared_ptr< Shape > ShapePtr
Definition: PhysicsTypes.hh:141
boost::shared_ptr< Model > ModelPtr
Definition: PhysicsTypes.hh:93
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:44