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 
64  public: void SetCollision(bool _placeable);
65 
68  public: void SetPlaceable(const 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 ignition::math::Box BoundingBox() const = 0;
102 
106  public: unsigned int GetShapeType() const;
107 
110  public: void SetShape(ShapePtr _shape);
111 
114  public: ShapePtr GetShape() const;
115 
118  public: void SetScale(const ignition::math::Vector3d &_scale);
119 
122  public: virtual ignition::math::Vector3d RelativeLinearVel() const;
123 
127  public: virtual ignition::math::Vector3d WorldLinearVel() const;
128 
131  public: virtual ignition::math::Vector3d RelativeAngularVel() const;
132 
135  public: virtual ignition::math::Vector3d WorldAngularVel() const;
136 
139  public: virtual ignition::math::Vector3d RelativeLinearAccel() const;
140 
144  public: virtual ignition::math::Vector3d WorldLinearAccel() const;
145 
148  public: virtual ignition::math::Vector3d RelativeAngularAccel() const;
149 
153  public: virtual ignition::math::Vector3d WorldAngularAccel() const;
154 
157  public: CollisionState GetState();
158 
161  public: void SetState(const CollisionState &_state);
162 
165  public: void FillMsg(msgs::Collision &_msg);
166 
169  public: void ProcessMsg(const msgs::Collision &_msg);
170 
173  public: inline SurfaceParamsPtr GetSurface() const
174  {return this->surface;}
175 
179  public: virtual void SetMaxContacts(unsigned int _maxContacts);
180 
184  public: virtual unsigned int GetMaxContacts();
185 
189  public: void SetWorldPoseDirty();
190 
191  // Documentation inherited.
192  public: virtual const ignition::math::Pose3d &WorldPose() const;
193 
196  private: msgs::Visual CreateCollisionVisual();
197 
199  protected: LinkPtr link;
200 
202  protected: bool placeable;
203 
205  protected: ShapePtr shape;
206 
209 
211  private: float laserRetro = 0.0;
212 
214  private: CollisionState state;
215 
217  private: unsigned int maxContacts;
218 
220  private: uint32_t collisionVisualId;
221 
223  private: mutable bool worldPoseDirty;
224  };
226  }
227 }
228 #endif
boost::shared_ptr< Link > LinkPtr
Definition: PhysicsTypes.hh:109
Base class for all collision entities.
Definition: Collision.hh:38
ShapePtr shape
Pointer to physics::Shape.
Definition: Collision.hh:205
SurfaceParamsPtr surface
The surface parameters.
Definition: Collision.hh:208
LinkPtr link
The link this collision belongs to.
Definition: Collision.hh:199
bool placeable
Flag for placeable.
Definition: Collision.hh:202
default namespace for gazebo
boost::shared_ptr< SurfaceParams > SurfaceParamsPtr
Definition: PhysicsTypes.hh:169
SurfaceParamsPtr GetSurface() const
Get the surface parameters.
Definition: Collision.hh:173
Base class for all physics objects in Gazebo.
Definition: Entity.hh:52
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:43