ODEPlaneShape.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2015 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 _ODEPLANESHAPE_HH_
18 #define _ODEPLANESHAPE_HH_
19 
22 #include "gazebo/util/system.hh"
23 
24 namespace gazebo
25 {
26  namespace physics
27  {
30  {
33  public: explicit ODEPlaneShape(CollisionPtr _parent)
34  : PlaneShape(_parent) {}
35 
37  public: virtual ~ODEPlaneShape() {}
38 
39  // Documentation inherited
40  public: virtual void CreatePlane()
41  {
43  ODECollisionPtr oParent;
44  oParent =
45  boost::dynamic_pointer_cast<ODECollision>(this->collisionParent);
46  math::Pose pose = oParent->GetWorldPose();
47  double altitude = pose.pos.z;
48  math::Vector3 n = this->GetNormal();
49  if (oParent->GetCollisionId() == NULL)
50  oParent->SetCollision(dCreatePlane(oParent->GetSpaceId(),
51  n.x, n.y, n.z, altitude), false);
52  else
53  dGeomPlaneSetParams(oParent->GetCollisionId(),
54  n.x, n.y, n.z, altitude);
55  }
56 
57  // Documentation inherited
58  public: virtual void SetAltitude(const math::Vector3 &_pos)
59  {
61  ODECollisionPtr odeParent;
62  odeParent =
63  boost::dynamic_pointer_cast<ODECollision>(this->collisionParent);
64 
65  dVector4 vec4;
66 
67  dGeomPlaneGetParams(odeParent->GetCollisionId(), vec4);
68 
69  // Compute "altitude": scalar product of position and normal
70  vec4[3] = vec4[0] * _pos.x + vec4[1] * _pos.y + vec4[2] * _pos.z;
71 
72  dGeomPlaneSetParams(odeParent->GetCollisionId(), vec4[0], vec4[1],
73  vec4[2], vec4[3]);
74  }
75  };
76  }
77 }
78 #endif
Encapsulates a position and rotation in three space.
Definition: Pose.hh:40
virtual void SetAltitude(const math::Vector3 &_pos)
Set the altitude of the plane.
The Vector3 class represents the generic vector containing 3 elements.
Definition: Vector3.hh:43
virtual ~ODEPlaneShape()
Destructor.
Definition: ODEPlaneShape.hh:37
Base class for all ODE collisions.
Definition: ODECollision.hh:39
ODEPlaneShape(CollisionPtr _parent)
Constructor.
Definition: ODEPlaneShape.hh:33
double x
X location.
Definition: Vector3.hh:302
double z
Z location.
Definition: Vector3.hh:308
boost::shared_ptr< Collision > CollisionPtr
Definition: PhysicsTypes.hh:94
virtual void SetAltitude(const math::Vector3 &_pos)
Set the altitude of the plane.
Definition: ODEPlaneShape.hh:58
An ODE Plane shape.
Definition: ODEPlaneShape.hh:29
Vector3 pos
The position.
Definition: Pose.hh:243
virtual void CreatePlane()
Create the plane.
Definition: ODEPlaneShape.hh:40
virtual void CreatePlane()
Create the plane.
#define NULL
Definition: CommonTypes.hh:30
boost::shared_ptr< ODECollision > ODECollisionPtr
Definition: ODETypes.hh:36
Collision for an infinite plane.
Definition: PlaneShape.hh:41
#define GAZEBO_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system.hh:48
double y
Y location.
Definition: Vector3.hh:305