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() override;
49 
52  public: virtual void Load(sdf::ElementPtr _sdf) override;
53 
55  public: virtual void Init() override;
56 
59  public: virtual void UpdateParameters(sdf::ElementPtr _sdf) override;
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::AxisAlignedBox BoundingBox() const
102  override = 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 ignition::math::Vector3d &_scale);
120 
123  public: virtual ignition::math::Vector3d RelativeLinearVel() const
124  override;
125 
129  public: virtual ignition::math::Vector3d WorldLinearVel() const
130  override;
131 
134  public: virtual ignition::math::Vector3d RelativeAngularVel() const
135  override;
136 
139  public: virtual ignition::math::Vector3d WorldAngularVel() const
140  override;
141 
144  public: virtual ignition::math::Vector3d RelativeLinearAccel() const
145  override;
146 
150  public: virtual ignition::math::Vector3d WorldLinearAccel() const
151  override;
152 
155  public: virtual ignition::math::Vector3d RelativeAngularAccel() const
156  override;
157 
161  public: virtual ignition::math::Vector3d WorldAngularAccel() const
162  override;
163 
166  public: CollisionState GetState();
167 
170  public: void SetState(const CollisionState &_state);
171 
174  public: void FillMsg(msgs::Collision &_msg);
175 
178  public: void ProcessMsg(const msgs::Collision &_msg);
179 
182  public: inline SurfaceParamsPtr GetSurface() const
183  {return this->surface;}
184 
188  public: virtual void SetMaxContacts(unsigned int _maxContacts);
189 
193  public: virtual unsigned int GetMaxContacts();
194 
198  public: void SetWorldPoseDirty();
199 
200  // Documentation inherited.
201  public: virtual const ignition::math::Pose3d &WorldPose() const
202  override;
203 
204  // Documentation inherited.
205  public: virtual std::optional<sdf::SemanticPose> SDFSemanticPose()
206  const override;
207 
210  private: msgs::Visual CreateCollisionVisual();
211 
213  protected: LinkPtr link;
214 
216  protected: bool placeable;
217 
219  protected: ShapePtr shape;
220 
223 
225  private: float laserRetro = 0.0;
226 
228  private: CollisionState state;
229 
231  private: unsigned int maxContacts;
232 
234  private: uint32_t collisionVisualId;
235 
237  private: mutable bool worldPoseDirty;
238 
240  private: const sdf::Collision *collisionSDFDom = nullptr;
241  };
243  }
244 }
245 #endif
boost::shared_ptr< Link > LinkPtr
Definition: PhysicsTypes.hh:110
Forward declarations for the common classes.
Definition: Animation.hh:26
Base class for all collision entities.
Definition: Collision.hh:38
ShapePtr shape
Pointer to physics::Shape.
Definition: Collision.hh:219
SurfaceParamsPtr surface
The surface parameters.
Definition: Collision.hh:222
LinkPtr link
The link this collision belongs to.
Definition: Collision.hh:213
bool placeable
Flag for placeable.
Definition: Collision.hh:216
default namespace for gazebo
boost::shared_ptr< SurfaceParams > SurfaceParamsPtr
Definition: PhysicsTypes.hh:170
Base class for all physics objects in Gazebo.
Definition: Entity.hh:52
boost::shared_ptr< Shape > ShapePtr
Definition: PhysicsTypes.hh:142
boost::shared_ptr< Model > ModelPtr
Definition: PhysicsTypes.hh:94
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
SurfaceParamsPtr GetSurface() const
Get the surface parameters.
Definition: Collision.hh:182