##

ODEPhysics.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 _ODEPHYSICS_HH_
#define _ODEPHYSICS_HH_
#include <tbb/spin_mutex.h>
#include <tbb/concurrent_vector.h>
#include <string>
#include <utility>
#include <boost/thread/thread.hpp>
#include "gazebo/physics/ode/ode_inc.h"
#include "gazebo/physics/ode/ODETypes.hh"
#include "gazebo/physics/PhysicsEngine.hh"
#include "gazebo/physics/Contact.hh"
#include "gazebo/physics/Shape.hh"
#include "gazebo/gazebo_config.h"
#include "gazebo/util/system.hh"
namespace gazebo
{
namespace physics
{
class ODEJointFeedback;
class ODEPhysicsPrivate;
class GZ_PHYSICS_VISIBLE ODEPhysics : public PhysicsEngine
{
public: enum ODEParam
{
SOLVER_TYPE,
GLOBAL_CFM,
GLOBAL_ERP,
SOR_PRECON_ITERS,
PGS_ITERS,
SOR,
CONTACT_MAX_CORRECTING_VEL,
CONTACT_SURFACE_LAYER,
MAX_CONTACTS,
MIN_STEP_SIZE,
INERTIA_RATIO_REDUCTION,
FRICTION_MODEL,
WORLD_SOLVER_TYPE
};
public: explicit ODEPhysics(WorldPtr _world);
public: virtual ~ODEPhysics();
// Documentation inherited
public: virtual void Load(sdf::ElementPtr _sdf);
// Documentation inherited
public: virtual void Init();
// Documentation inherited
public: virtual void Reset();
// Documentation inherited
public: virtual void InitForThread();
// Documentation inherited
public: virtual void UpdateCollision();
// Documentation inherited
public: virtual void UpdatePhysics();
// Documentation inherited
public: virtual void Fini();
// Documentation inherited
public: virtual std::string GetType() const
{ return "ode"; }
// Documentation inherited
public: virtual LinkPtr CreateLink(ModelPtr _parent);
// Documentation inherited
public: virtual CollisionPtr CreateCollision(
const std::string &_shapeType, LinkPtr _parent);
// Documentation inherited
public: virtual ShapePtr CreateShape(const std::string &_shapeType,
CollisionPtr _collision);
// Documentation inherited
public: virtual JointPtr CreateJoint(const std::string &_type,
ModelPtr _parent);
// Documentation inherited
public: virtual void SetGravity(const ignition::math::Vector3d &_gravity);
// Documentation inherited
public: virtual void SetWorldCFM(double cfm);
// Documentation inherited
public: virtual void SetWorldERP(double erp);
// Documentation inherited
public: virtual void SetSORPGSPreconIters(unsigned int iters);
// Documentation inherited
public: virtual void SetSORPGSIters(unsigned int iters);
// Documentation inherited
public: virtual void SetSORPGSW(double w);
// Documentation inherited
public: virtual void SetContactMaxCorrectingVel(double vel);
// Documentation inherited
public: virtual void SetContactSurfaceLayer(double layer_depth);
public: virtual void SetFrictionModel(const std::string &_fricModel);
public: virtual void
SetWorldStepSolverType(const std::string &_worldSolverType);
// Documentation inherited
public: virtual void SetMaxContacts(unsigned int max_contacts);
// Documentation inherited
public: virtual double GetWorldCFM();
// Documentation inherited
public: virtual double GetWorldERP();
// Documentation inherited
public: virtual int GetSORPGSPreconIters();
// Documentation inherited
public: virtual int GetSORPGSIters();
// Documentation inherited
public: virtual double GetSORPGSW();
// Documentation inherited
public: virtual double GetContactMaxCorrectingVel();
public: virtual std::string GetFrictionModel() const;
public: virtual std::string GetWorldStepSolverType() const;
// Documentation inherited
public: virtual double GetContactSurfaceLayer();
// Documentation inherited
public: virtual unsigned int GetMaxContacts();
// Documentation inherited
public: virtual void DebugPrint() const;
// Documentation inherited
public: virtual void SetSeed(uint32_t _seed);
public: virtual bool SetParam(const std::string &_key,
const boost::any &_value);
public: virtual boost::any GetParam(const std::string &_key) const;
public: virtual bool GetParam(const std::string &_key,
boost::any &_value) const;
public: dSpaceID GetSpaceId() const;
public: dWorldID GetWorldId();
public: static void ConvertMass(InertialPtr _interial, void *_odeMass);
public: static void ConvertMass(void *_odeMass, InertialPtr _inertial);
public: static Friction_Model
ConvertFrictionModel(const std::string &_fricModel);
public: static std::string
ConvertFrictionModel(const Friction_Model _fricModel);
public: static std::string
ConvertWorldStepSolverType(const World_Solver_Type _solverType);
public: static World_Solver_Type
ConvertWorldStepSolverType(const std::string &_solverType);
public: virtual std::string GetStepType() const;
public: virtual void SetStepType(const std::string &_type);
public: void Collide(ODECollision *_collision1, ODECollision *_collision2,
dContactGeom *_contactCollisions);
public: void ProcessJointFeedback(ODEJointFeedback *_feedback);
protected: virtual void OnRequest(ConstRequestPtr &_msg);
protected: virtual void OnPhysicsMsg(ConstPhysicsPtr &_msg);
private: static void CollisionCallback(void *_data, dGeomID _o1,
dGeomID _o2);
private: void AddTrimeshCollider(ODECollision *_collision1,
ODECollision *_collision2);
private: void AddCollider(ODECollision *_collision1,
ODECollision *_collision2);
private: ODEPhysicsPrivate *dataPtr;
};
}
}
#endif
gazebo::physics::ODEPhysics::SetSORPGSIters
virtual void SetSORPGSIters(unsigned int iters)
gazebo::physics::ODEPhysics::CreateShape
virtual ShapePtr CreateShape(const std::string &_shapeType, CollisionPtr _collision)
Create a physics::Shape object.
gazebo::physics::ODEPhysics::SetParam
virtual bool SetParam(const std::string &_key, const boost::any &_value)
Documentation inherited.
gazebo::physics::ODEPhysics::Fini
virtual void Fini()
Finilize the physics engine.
PhysicsEngine.hh
gazebo::physics::ODEPhysics::GetWorldStepSolverType
virtual std::string GetWorldStepSolverType() const
Get solver type for world step.
gazebo::physics::ODEPhysics::SetContactSurfaceLayer
virtual void SetContactSurfaceLayer(double layer_depth)
gazebo::physics::ODEPhysics::SetStepType
virtual void SetStepType(const std::string &_type)
Set the step type (quick, world).
gazebo::physics::ODEPhysics::InitForThread
virtual void InitForThread()
Init the engine for threads.
gazebo::physics::ODEPhysics::MAX_CONTACTS
Maximum number of contacts.
Definition: ODEPhysics.hh:79
gazebo::physics::ODEPhysics::GLOBAL_CFM
Constraint force mixing.
Definition: ODEPhysics.hh:58
gazebo::physics::PhysicsEngine
Base class for a physics engine.
Definition: PhysicsEngine.hh:41
gazebo::physics::ODEPhysics::SetWorldStepSolverType
virtual void SetWorldStepSolverType(const std::string &_worldSolverType)
Set world step solver type.
gazebo::physics::ODEPhysics::CONTACT_SURFACE_LAYER
Surface layer depth.
Definition: ODEPhysics.hh:76
gazebo::physics::ODEPhysics::PGS_ITERS
Number of iterations.
Definition: ODEPhysics.hh:67
gazebo::physics::ODEPhysics::CONTACT_MAX_CORRECTING_VEL
Max correcting velocity.
Definition: ODEPhysics.hh:73
gazebo
Forward declarations for the common classes.
Definition: Animation.hh:26
gazebo::physics::ODEPhysics::FRICTION_MODEL
friction model
Definition: ODEPhysics.hh:89
gazebo::physics::ODEPhysics::GetContactSurfaceLayer
virtual double GetContactSurfaceLayer()
gazebo::physics::ODEPhysics::GetMaxContacts
virtual unsigned int GetMaxContacts()
gazebo::physics::ModelPtr
boost::shared_ptr< Model > ModelPtr
Definition: PhysicsTypes.hh:93
gazebo::physics::ODECollision
Base class for all ODE collisions.
Definition: ODECollision.hh:40
gazebo::physics::ODEPhysics::GetWorldId
dWorldID GetWorldId()
Get the world id.
gazebo::physics::ODEPhysics::SetWorldCFM
virtual void SetWorldCFM(double cfm)
system.hh
gazebo::physics::ODEPhysics::SOR
SOR over-relaxation parameter.
Definition: ODEPhysics.hh:70
gazebo::physics::ODEPhysics::SetSeed
virtual void SetSeed(uint32_t _seed)
Set the random number seed for the physics engine.
gazebo::physics::ODEPhysics::ConvertMass
static void ConvertMass(InertialPtr _interial, void *_odeMass)
Convert an ODE mass to Inertial.
gazebo::physics::ODEPhysics::ODEPhysics
ODEPhysics(WorldPtr _world)
Constructor.
gazebo::physics::ODEPhysics::ProcessJointFeedback
void ProcessJointFeedback(ODEJointFeedback *_feedback)
process joint feedbacks.
gazebo::physics::ODEPhysics::GetSORPGSW
virtual double GetSORPGSW()
gazebo::physics::ODEPhysics::SetSORPGSW
virtual void SetSORPGSW(double w)
gazebo::physics::ODEPhysics::~ODEPhysics
virtual ~ODEPhysics()
Destructor.
gazebo::physics::ODEPhysics::INERTIA_RATIO_REDUCTION
Limit ratios of inertias of adjacent links (note that the corresponding SDF tag is "use_dynamic_moi_r...
Definition: ODEPhysics.hh:86
gazebo::physics::ODEPhysics::MIN_STEP_SIZE
Minimum step size.
Definition: ODEPhysics.hh:82
gazebo::physics::ODEPhysics::SOR_PRECON_ITERS
Number of iterations.
Definition: ODEPhysics.hh:64
gazebo::physics::ODEPhysics::SetWorldERP
virtual void SetWorldERP(double erp)
gazebo::physics::ODEPhysics::OnPhysicsMsg
virtual void OnPhysicsMsg(ConstPhysicsPtr &_msg)
virtual callback for gztopic "~/physics".
gazebo::physics::ODEPhysics::GetWorldERP
virtual double GetWorldERP()
gazebo::physics::ODEPhysics::GetStepType
virtual std::string GetStepType() const
Get the step type (quick, world).
gazebo::physics::ODEPhysics::GetSORPGSPreconIters
virtual int GetSORPGSPreconIters()
gazebo::physics::ODEPhysics::Load
virtual void Load(sdf::ElementPtr _sdf)
Load the physics engine.
Shape.hh
gazebo::physics::ODEPhysics::ConvertWorldStepSolverType
static std::string ConvertWorldStepSolverType(const World_Solver_Type _solverType)
Convert a World_Solver_Type enum to a string.
gazebo::physics::ODEPhysics::SetSORPGSPreconIters
virtual void SetSORPGSPreconIters(unsigned int iters)
gazebo::physics::ShapePtr
boost::shared_ptr< Shape > ShapePtr
Definition: PhysicsTypes.hh:141
gazebo::physics::ODEPhysics::WORLD_SOLVER_TYPE
LCP Solver.
Definition: ODEPhysics.hh:92
gazebo::physics::ODEPhysics::GLOBAL_ERP
Error reduction parameter.
Definition: ODEPhysics.hh:61
gazebo::physics::ODEPhysics::GetWorldCFM
virtual double GetWorldCFM()
gazebo::physics::ODEPhysics::GetContactMaxCorrectingVel
virtual double GetContactMaxCorrectingVel()
gazebo::physics::ODEPhysics::UpdateCollision
virtual void UpdateCollision()
Update the physics engine collision.
ODETypes.hh
ODE wrapper forward declarations and typedefs.
gazebo::msgs::Init
GAZEBO_VISIBLE void Init(google::protobuf::Message &_message, const std::string &_id="")
Initialize a message.
gazebo::physics::ODEPhysics::SetContactMaxCorrectingVel
virtual void SetContactMaxCorrectingVel(double vel)
gazebo::physics::LinkPtr
boost::shared_ptr< Link > LinkPtr
Definition: PhysicsTypes.hh:109
gazebo::physics::ODEPhysics::SOLVER_TYPE
Solve type.
Definition: ODEPhysics.hh:55
gazebo::physics::ODEPhysics::GetSpaceId
dSpaceID GetSpaceId() const
Return the world space id.
gazebo::physics::ODEPhysics::SetFrictionModel
virtual void SetFrictionModel(const std::string &_fricModel)
Set friction model type.
gazebo::physics::ODEPhysics::GetSORPGSIters
virtual int GetSORPGSIters()
gazebo::physics::JointPtr
boost::shared_ptr< Joint > JointPtr
Definition: PhysicsTypes.hh:117
gazebo::physics::ODEPhysics::ODEParam
ODEParam
ODE Physics parameter types.
Definition: ODEPhysics.hh:52
Contact.hh
gazebo::physics::CollisionPtr
boost::shared_ptr< Collision > CollisionPtr
Definition: PhysicsTypes.hh:113
gazebo::physics::ODEPhysics::OnRequest
virtual void OnRequest(ConstRequestPtr &_msg)
virtual callback for gztopic "~/request".
gazebo::physics::ODEPhysics::Reset
virtual void Reset()
Rest the physics engine.
gazebo::physics::ODEPhysics::DebugPrint
virtual void DebugPrint() const
Debug print out of the physic engine state.
gazebo::physics::ODEPhysics::ConvertFrictionModel
static Friction_Model ConvertFrictionModel(const std::string &_fricModel)
Convert a string to a Friction_Model enum.
gazebo::physics::ODEPhysics::GetParam
virtual boost::any GetParam(const std::string &_key) const
Documentation inherited.
gazebo::physics::ODEPhysics::SetGravity
virtual void SetGravity(const ignition::math::Vector3d &_gravity)
Set the gravity vector.
gazebo::physics::ODEPhysics::CreateCollision
virtual CollisionPtr CreateCollision(const std::string &_shapeType, LinkPtr _parent)
Create a collision.
gazebo::physics::WorldPtr
boost::shared_ptr< World > WorldPtr
Definition: PhysicsTypes.hh:89
gazebo::physics::ODEPhysics
ODE physics engine.
Definition: ODEPhysics.hh:48
gazebo::physics::ODEPhysics::SetMaxContacts
virtual void SetMaxContacts(unsigned int max_contacts)
\TODO: Remove this function, and replace it with a more generic property map
gazebo::physics::ODEPhysics::CreateLink
virtual LinkPtr CreateLink(ModelPtr _parent)
Create a new body.
gazebo::physics::ODEPhysics::GetType
virtual std::string GetType() const
Return the physics engine type (ode|bullet|dart|simbody).
Definition: ODEPhysics.hh:124
gazebo::physics::InertialPtr
boost::shared_ptr< Inertial > InertialPtr
Definition: PhysicsTypes.hh:157
gazebo::physics::ODEPhysics::CreateJoint
virtual JointPtr CreateJoint(const std::string &_type, ModelPtr _parent)
Create a new joint.
ode_inc.h
gazebo::physics::ODEPhysics::UpdatePhysics
virtual void UpdatePhysics()
Update the physics engine.
gazebo::physics::ODEPhysics::Collide
void Collide(ODECollision *_collision1, ODECollision *_collision2, dContactGeom *_contactCollisions)
Collide two collision objects.
gazebo::physics::ODEPhysics::Init
virtual void Init()
Initialize the physics engine.
gazebo::physics::ODEPhysics::GetFrictionModel
virtual std::string GetFrictionModel() const
Get friction model.