##

BulletPhysics.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.
*
*/
/* Desc: The Bullet physics engine wrapper
* Author: Nate Koenig
* Date: 11 June 2009
*/
#ifndef BULLETPHYSICS_HH
#define BULLETPHYSICS_HH
#include <string>
#include <boost/thread/thread.hpp>
#include <boost/thread/mutex.hpp>
#include "gazebo/physics/bullet/bullet_inc.h"
#include "gazebo/physics/PhysicsEngine.hh"
#include "gazebo/physics/Collision.hh"
#include "gazebo/physics/Shape.hh"
#include "gazebo/util/system.hh"
namespace gazebo
{
namespace physics
{
class Entity;
class XMLConfigNode;
class Mass;
class GZ_PHYSICS_VISIBLE BulletPhysics : public PhysicsEngine
{
public: enum BulletParam
{
SOLVER_TYPE,
GLOBAL_CFM,
GLOBAL_ERP,
PGS_ITERS,
SOR,
CONTACT_SURFACE_LAYER,
MAX_CONTACTS,
MIN_STEP_SIZE
};
public: explicit BulletPhysics(WorldPtr _world);
public: virtual ~BulletPhysics();
// 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 "bullet"; }
// Documentation inherited
public: virtual LinkPtr CreateLink(ModelPtr _parent);
// Documentation inherited
public: virtual CollisionPtr CreateCollision(const std::string &_type,
LinkPtr _body);
// Documentation inherited
public: virtual JointPtr CreateJoint(const std::string &_type,
ModelPtr _parent);
// Documentation inherited
public: virtual ShapePtr CreateShape(const std::string &_shapeType,
CollisionPtr _collision);
// public: virtual PhysicsRaySensor *CreateRaySensor(Link *body);
// Documentation inherited
protected: virtual void OnRequest(ConstRequestPtr &_msg);
// Documentation inherited
protected: virtual void OnPhysicsMsg(ConstPhysicsPtr &_msg);
public: virtual void ConvertMass(InertialPtr _inertial,
void *_engineMass);
public: virtual void ConvertMass(void *_engineMass,
InertialPtr _inertial);
// Documentation inherited
public: virtual void SetGravity(const ignition::math::Vector3d &_gravity);
// Documentation inherited
public: virtual void SetWorldCFM(double _cfm);
// Documentation inherited
public: virtual double GetWorldCFM();
// Documentation inherited
public: virtual void SetSeed(uint32_t _seed);
public: btDynamicsWorld *GetDynamicsWorld() const
{return this->dynamicsWorld;}
public: virtual void DebugPrint() const;
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;
// Documentation inherited
public: virtual void SetSORPGSIters(unsigned int iters);
private: btBroadphaseInterface *broadPhase;
private: btDefaultCollisionConfiguration *collisionConfig;
private: btCollisionDispatcher *dispatcher;
private: btSequentialImpulseConstraintSolver *solver;
private: btDiscreteDynamicsWorld *dynamicsWorld;
private: common::Time lastUpdateTime;
private: std::string solverType;
};
}
}
#endif
gazebo::physics::BulletPhysics::UpdatePhysics
virtual void UpdatePhysics()
Update the physics engine.
gazebo::physics::BulletPhysics::CreateShape
virtual ShapePtr CreateShape(const std::string &_shapeType, CollisionPtr _collision)
Create a physics::Shape object.
gazebo::physics::BulletPhysics::CreateLink
virtual LinkPtr CreateLink(ModelPtr _parent)
Create a new body.
PhysicsEngine.hh
gazebo::physics::BulletPhysics::OnPhysicsMsg
virtual void OnPhysicsMsg(ConstPhysicsPtr &_msg)
virtual callback for gztopic "~/physics".
gazebo::physics::BulletPhysics::SOR
SOR over-relaxation parameter.
Definition: BulletPhysics.hh:68
gazebo::physics::BulletPhysics::SetSORPGSIters
virtual void SetSORPGSIters(unsigned int iters)
gazebo::physics::PhysicsEngine
Base class for a physics engine.
Definition: PhysicsEngine.hh:41
gazebo::physics::BulletPhysics::DebugPrint
virtual void DebugPrint() const
Debug print out of the physic engine state.
gazebo
Forward declarations for the common classes.
Definition: Animation.hh:26
Collision.hh
gazebo::physics::BulletPhysics::PGS_ITERS
Number of iterations.
Definition: BulletPhysics.hh:65
gazebo::common::Time
A Time class, can be used to hold wall- or sim-time. stored as sec and nano-sec.
Definition: Time.hh:47
gazebo::physics::BulletPhysics
Bullet physics engine.
Definition: BulletPhysics.hh:49
gazebo::physics::ModelPtr
boost::shared_ptr< Model > ModelPtr
Definition: PhysicsTypes.hh:93
gazebo::physics::BulletPhysics::UpdateCollision
virtual void UpdateCollision()
Update the physics engine collision.
gazebo::physics::BulletPhysics::BulletParam
BulletParam
Bullet physics parameter types.
Definition: BulletPhysics.hh:53
gazebo::physics::BulletPhysics::GetParam
virtual boost::any GetParam(const std::string &_key) const
Documentation inherited.
gazebo::physics::BulletPhysics::Fini
virtual void Fini()
Finilize the physics engine.
gazebo::physics::BulletPhysics::ConvertMass
virtual void ConvertMass(InertialPtr _inertial, void *_engineMass)
Convert a bullet mass to a gazebo Mass.
gazebo::physics::BulletPhysics::CreateJoint
virtual JointPtr CreateJoint(const std::string &_type, ModelPtr _parent)
Create a new joint.
system.hh
bullet_inc.h
gazebo::physics::BulletPhysics::SetParam
virtual bool SetParam(const std::string &_key, const boost::any &_value)
Documentation inherited.
gazebo::physics::BulletPhysics::Init
virtual void Init()
Initialize the physics engine.
gazebo::physics::BulletPhysics::BulletPhysics
BulletPhysics(WorldPtr _world)
Constructor.
gazebo::physics::BulletPhysics::InitForThread
virtual void InitForThread()
Init the engine for threads.
gazebo::physics::BulletPhysics::SetWorldCFM
virtual void SetWorldCFM(double _cfm)
gazebo::physics::BulletPhysics::OnRequest
virtual void OnRequest(ConstRequestPtr &_msg)
Create a physics based ray sensor.
Shape.hh
gazebo::physics::BulletPhysics::CreateCollision
virtual CollisionPtr CreateCollision(const std::string &_type, LinkPtr _body)
Create a collision.
gazebo::physics::BulletPhysics::Load
virtual void Load(sdf::ElementPtr _sdf)
Load the physics engine.
gazebo::physics::BulletPhysics::SetSeed
virtual void SetSeed(uint32_t _seed)
Set the random number seed for the physics engine.
gazebo::physics::ShapePtr
boost::shared_ptr< Shape > ShapePtr
Definition: PhysicsTypes.hh:141
gazebo::physics::BulletPhysics::GetType
virtual std::string GetType() const
Return the physics engine type (ode|bullet|dart|simbody).
Definition: BulletPhysics.hh:108
gazebo::physics::BulletPhysics::Reset
virtual void Reset()
Rest the physics engine.
gazebo::msgs::Init
GAZEBO_VISIBLE void Init(google::protobuf::Message &_message, const std::string &_id="")
Initialize a message.
gazebo::physics::BulletPhysics::GLOBAL_CFM
Constraint force mixing.
Definition: BulletPhysics.hh:59
gazebo::physics::LinkPtr
boost::shared_ptr< Link > LinkPtr
Definition: PhysicsTypes.hh:109
gazebo::physics::BulletPhysics::SOLVER_TYPE
Solve type.
Definition: BulletPhysics.hh:56
gazebo::physics::BulletPhysics::GLOBAL_ERP
Error reduction parameter.
Definition: BulletPhysics.hh:62
gazebo::physics::BulletPhysics::MAX_CONTACTS
Maximum number of contacts.
Definition: BulletPhysics.hh:74
gazebo::physics::BulletPhysics::CONTACT_SURFACE_LAYER
Surface layer depth.
Definition: BulletPhysics.hh:71
gazebo::physics::JointPtr
boost::shared_ptr< Joint > JointPtr
Definition: PhysicsTypes.hh:117
gazebo::physics::BulletPhysics::GetDynamicsWorld
btDynamicsWorld * GetDynamicsWorld() const
Register a joint with the dynamics world.
Definition: BulletPhysics.hh:156
gazebo::physics::CollisionPtr
boost::shared_ptr< Collision > CollisionPtr
Definition: PhysicsTypes.hh:113
gazebo::physics::BulletPhysics::SetGravity
virtual void SetGravity(const ignition::math::Vector3d &_gravity)
Set the gravity vector.
gazebo::physics::BulletPhysics::MIN_STEP_SIZE
Minimum step size.
Definition: BulletPhysics.hh:77
gazebo::physics::WorldPtr
boost::shared_ptr< World > WorldPtr
Definition: PhysicsTypes.hh:89
gazebo::physics::InertialPtr
boost::shared_ptr< Inertial > InertialPtr
Definition: PhysicsTypes.hh:157
gazebo::physics::BulletPhysics::~BulletPhysics
virtual ~BulletPhysics()
Destructor.
gazebo::physics::BulletPhysics::GetWorldCFM
virtual double GetWorldCFM()