##

ODEPlaneShape.hh
Go to the documentation of this file.
/*
* Copyright (C) 2012 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef GAZEBO_PHYSICS_ODE_ODEPLANESHAPE_HH_
#define GAZEBO_PHYSICS_ODE_ODEPLANESHAPE_HH_
#include "gazebo/physics/PlaneShape.hh"
#include "gazebo/physics/ode/ODEPhysics.hh"
#include "gazebo/util/system.hh"
namespace gazebo
{
namespace physics
{
class GZ_PHYSICS_VISIBLE ODEPlaneShape : public PlaneShape
{
public: explicit ODEPlaneShape(CollisionPtr _parent)
: PlaneShape(_parent) {}
public: virtual ~ODEPlaneShape() {}
// Documentation inherited
public: virtual void CreatePlane()
{
PlaneShape::CreatePlane();
ODECollisionPtr oParent;
oParent =
boost::dynamic_pointer_cast<ODECollision>(this->collisionParent);
ignition::math::Pose3d pose = oParent->WorldPose();
double altitude = pose.Pos().Z();
ignition::math::Vector3d n = this->Normal();
if (oParent->GetCollisionId() == nullptr)
oParent->SetCollision(dCreatePlane(oParent->GetSpaceId(),
n.X(), n.Y(), n.Z(), altitude), false);
else
dGeomPlaneSetParams(oParent->GetCollisionId(),
n.X(), n.Y(), n.Z(), altitude);
}
// Documentation inherited
public: virtual void SetAltitude(const ignition::math::Vector3d &_pos)
{
PlaneShape::SetAltitude(_pos);
ODECollisionPtr odeParent;
odeParent =
boost::dynamic_pointer_cast<ODECollision>(this->collisionParent);
dVector4 vec4;
dGeomPlaneGetParams(odeParent->GetCollisionId(), vec4);
// Compute "altitude": scalar product of position and normal
vec4[3] = vec4[0] * _pos.X() + vec4[1] * _pos.Y() + vec4[2] * _pos.Z();
dGeomPlaneSetParams(odeParent->GetCollisionId(), vec4[0], vec4[1],
vec4[2], vec4[3]);
}
};
}
}
#endif
gazebo::physics::PlaneShape::Normal
ignition::math::Vector3d Normal() const
Get the plane normal.
gazebo
Forward declarations for the common classes.
Definition: Animation.hh:26
gazebo::physics::ODECollisionPtr
boost::shared_ptr< ODECollision > ODECollisionPtr
Definition: ODETypes.hh:39
system.hh
PlaneShape.hh
gazebo::physics::PlaneShape
Collision for an infinite plane.
Definition: PlaneShape.hh:37
gazebo::physics::ODEPlaneShape::ODEPlaneShape
ODEPlaneShape(CollisionPtr _parent)
Constructor.
Definition: ODEPlaneShape.hh:36
gazebo::physics::PlaneShape::SetAltitude
virtual void SetAltitude(const ignition::math::Vector3d &_pos)
Set the altitude of the plane.
gazebo::physics::ODEPlaneShape
An ODE Plane shape.
Definition: ODEPlaneShape.hh:32
gazebo::physics::Shape::collisionParent
CollisionPtr collisionParent
This shape's collision parent.
Definition: Shape.hh:73
ODEPhysics.hh
gazebo::physics::PlaneShape::CreatePlane
virtual void CreatePlane()
Create the plane.
gazebo::physics::ODEPlaneShape::CreatePlane
virtual void CreatePlane()
Create the plane.
Definition: ODEPlaneShape.hh:43
gazebo::physics::CollisionPtr
boost::shared_ptr< Collision > CollisionPtr
Definition: PhysicsTypes.hh:113
gazebo::physics::ODEPlaneShape::SetAltitude
virtual void SetAltitude(const ignition::math::Vector3d &_pos)
Set the altitude of the plane.
Definition: ODEPlaneShape.hh:61
gazebo::physics::ODEPlaneShape::~ODEPlaneShape
virtual ~ODEPlaneShape()
Destructor.
Definition: ODEPlaneShape.hh:40