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
24
28#include "gazebo/util/system.hh"
29
30namespace 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
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
default namespace for gazebo
Store state information of a physics::Collision object.
Definition CollisionState.hh:44
Base class for all collision entities.
Definition Collision.hh:39
ModelPtr GetModel() const
Get the model this collision belongs to.
void SetState(const CollisionState &_state)
Set the current collision state.
CollisionState GetState()
Get the collision state.
bool placeable
Flag for placeable.
Definition Collision.hh:202
virtual ignition::math::Vector3d RelativeAngularVel() const
Get the angular velocity of the collision.
ShapePtr shape
Pointer to physics::Shape.
Definition Collision.hh:205
virtual void Fini()
Finalize the collision.
unsigned int GetShapeType() const
Get the shape type.
void FillMsg(msgs::Collision &_msg)
Fill a collision message.
virtual void Init()
Initialize the collision.
LinkPtr GetLink() const
Get the link this collision belongs to.
virtual ~Collision()
Destructor.
void SetPlaceable(const bool _placeable)
Set if this object is moveable.
virtual ignition::math::Vector3d WorldAngularVel() const
Get the angular velocity of the collision in the world frame.
virtual void SetCategoryBits(unsigned int _bits)=0
Set the category bits, used during collision detection.
virtual const ignition::math::Pose3d & WorldPose() const
Get the absolute pose of the entity.
virtual ignition::math::Box BoundingBox() const =0
Get the bounding box for this collision.
SurfaceParamsPtr surface
The surface parameters.
Definition Collision.hh:208
SurfaceParamsPtr GetSurface() const
Get the surface parameters.
Definition Collision.hh:173
virtual ignition::math::Vector3d RelativeLinearVel() const
Get the linear velocity of the collision.
LinkPtr link
The link this collision belongs to.
Definition Collision.hh:199
virtual ignition::math::Vector3d RelativeAngularAccel() const
Get the angular acceleration of the collision.
virtual ignition::math::Vector3d RelativeLinearAccel() const
Get the linear acceleration of the collision.
virtual ignition::math::Vector3d WorldLinearAccel() const
Get the linear acceleration of the collision in the world frame.
bool IsPlaceable() const
Return whether this collision is movable.
void SetCollision(bool _placeable)
Set the encapsulated collision object.
virtual void Load(sdf::ElementPtr _sdf)
Load the collision.
void SetShape(ShapePtr _shape)
Set the shape for this collision.
void SetLaserRetro(float _retro)
Set the laser retro reflectiveness.
virtual void SetCollideBits(unsigned int _bits)=0
Set the collide bits, used during collision detection.
virtual void UpdateParameters(sdf::ElementPtr _sdf)
Update the parameters using new sdf values.
virtual unsigned int GetMaxContacts()
returns number of contacts allowed for this collision.
virtual ignition::math::Vector3d WorldAngularAccel() const
Get the angular acceleration of the collision in the world frame.
float GetLaserRetro() const
Get the laser retro reflectiveness.
virtual ignition::math::Vector3d WorldLinearVel() const
Get the linear velocity of the collision in the world frame.
ShapePtr GetShape() const
Get the collision shape.
Collision(LinkPtr _link)
Constructor.
virtual void SetMaxContacts(unsigned int _maxContacts)
Number of contacts allowed for this collision.
void SetWorldPoseDirty()
Indicate that the world pose should be recalculated.
void SetScale(const ignition::math::Vector3d &_scale)
Set the scale of the collision.
void ProcessMsg(const msgs::Collision &_msg)
Update parameters from a message.
Base class for all physics objects in Gazebo.
Definition Entity.hh:53
boost::shared_ptr< Link > LinkPtr
Definition PhysicsTypes.hh:109
boost::shared_ptr< SurfaceParams > SurfaceParamsPtr
Definition PhysicsTypes.hh:169
boost::shared_ptr< Shape > ShapePtr
Definition PhysicsTypes.hh:141
boost::shared_ptr< Model > ModelPtr
Definition PhysicsTypes.hh:93
Forward declarations for the common classes.
Definition Animation.hh:27