##

SimbodyPhysics.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_SIMBODY_SIMBODYPHYSICS_HH
#define GAZEBO_PHYSICS_SIMBODY_SIMBODYPHYSICS_HH
#include <string>
#include <boost/thread/thread.hpp>
#include <boost/thread/mutex.hpp>
#include "gazebo/physics/PhysicsEngine.hh"
#include "gazebo/physics/Collision.hh"
#include "gazebo/physics/Shape.hh"
#include "gazebo/physics/simbody/SimbodyTypes.hh"
#include "gazebo/physics/simbody/simbody_inc.h"
#include "gazebo/util/system.hh"
namespace gazebo
{
namespace physics
{
class GZ_PHYSICS_VISIBLE SimbodyPhysics : public PhysicsEngine
{
public: explicit SimbodyPhysics(WorldPtr _world);
public: virtual ~SimbodyPhysics();
// Documentation inherited
public: virtual void Load(sdf::ElementPtr _sdf);
// Documentation inherited
public: virtual void Init();
// Documentation inherited
public: virtual void Reset();
public: void InitModel(const physics::ModelPtr _model);
// 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;
// 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: SimTK::MultibodySystem *GetDynamicsWorld() const;
// Documentation inherited
public: virtual void SetGravity(const ignition::math::Vector3d &_gravity);
// Documentation inherited
public: virtual void DebugPrint() const;
// Documentation inherited
public: virtual void SetSeed(uint32_t _seed);
// Documentation inherited
public: virtual ModelPtr CreateModel(BasePtr _parent);
public: static SimTK::Quaternion QuadToQuad(
const ignition::math::Quaterniond &_q);
public: static ignition::math::Quaterniond QuadToQuadIgn(
const SimTK::Quaternion &_q);
public: static SimTK::Vec3 Vector3ToVec3(
const ignition::math::Vector3d &_v);
public: static ignition::math::Vector3d Vec3ToVector3Ign(
const SimTK::Vec3 &_v);
public: static SimTK::Transform Pose2Transform(
const ignition::math::Pose3d &_pose);
public: static ignition::math::Pose3d Transform2PoseIgn(
const SimTK::Transform &_xAB);
public: static SimTK::Transform GetPose(sdf::ElementPtr _element);
public: static std::string GetTypeString(unsigned int _type);
public: static std::string GetTypeString(physics::Base::EntityType _type);
// Documentation inherited
protected: virtual void OnRequest(ConstRequestPtr &_msg);
// Documentation inherited
protected: virtual void OnPhysicsMsg(ConstPhysicsPtr &_msg);
private: void CreateMultibodyGraph(
SimTK::MultibodyGraphMaker& _mbgraph, const physics::ModelPtr _model);
private: void InitSimbodySystem();
private: void AddStaticModelToSimbodySystem(
const physics::ModelPtr _model);
private: void AddDynamicModelToSimbodySystem(
const SimTK::MultibodyGraphMaker &_mbgraph,
const physics::ModelPtr _model);
private: void AddCollisionsToLink(const physics::SimbodyLink *_link,
SimTK::MobilizedBody &_mobod, SimTK::ContactCliqueId _modelClique);
public: SimTK::MultibodySystem system;
public: SimTK::SimbodyMatterSubsystem matter;
public: SimTK::GeneralForceSubsystem forces;
public: SimTK::Force::Gravity gravity;
public: SimTK::Force::DiscreteForces discreteForces;
public: SimTK::ContactTrackerSubsystem tracker;
public: SimTK::CompliantContactSubsystem contact;
public: SimTK:: Integrator *integ;
public: bool simbodyPhysicsInitialized;
public: bool simbodyPhysicsStepped;
// Documentation inherited
public: virtual boost::any GetParam(const std::string &_key) const;
// Documentation inherited
public: virtual bool GetParam(const std::string &_key,
boost::any &_value) const;
// Documentation inherited
public: virtual bool SetParam(const std::string &_key,
const boost::any &_value);
private: double contactMaterialStiffness;
private: double contactMaterialDissipation;
private: double contactMaterialPlasticCoefRestitution;
private: double contactMaterialPlasticImpactVelocity;
private: double contactMaterialStaticFriction;
private: double contactMaterialDynamicFriction;
private: double contactMaterialViscousFriction;
private: double contactImpactCaptureVelocity;
private: double contactStictionTransitionVelocity;
private: SimTK::MultibodySystem *dynamicsWorld;
private: common::Time lastUpdateTime;
private: double stepTimeDouble;
private: std::string solverType;
private: std::string integratorType;
};
}
}
#endif
gazebo::physics::SimbodyLink
Simbody Link class.
Definition: SimbodyLink.hh:38
PhysicsEngine.hh
gazebo::physics::SimbodyPhysics::DebugPrint
virtual void DebugPrint() const
Debug print out of the physic engine state.
gazebo::physics::SimbodyPhysics::discreteForces
SimTK::Force::DiscreteForces discreteForces
Definition: SimbodyPhysics.hh:214
gazebo::physics::SimbodyPhysics::matter
SimTK::SimbodyMatterSubsystem matter
Definition: SimbodyPhysics.hh:211
gazebo::physics::SimbodyPhysics::Vec3ToVector3Ign
static ignition::math::Vector3d Vec3ToVector3Ign(const SimTK::Vec3 &_v)
Convert SimTK::Vec3 to ignition::math::Vector3d.
gazebo::physics::SimbodyPhysics::GetType
virtual std::string GetType() const
Return the physics engine type (ode|bullet|dart|simbody).
gazebo::physics::PhysicsEngine
Base class for a physics engine.
Definition: PhysicsEngine.hh:41
gazebo
Forward declarations for the common classes.
Definition: Animation.hh:26
Collision.hh
gazebo::physics::SimbodyPhysics::SetParam
virtual bool SetParam(const std::string &_key, const boost::any &_value)
Set a parameter of the physics engine.
gazebo::physics::SimbodyPhysics::CreateModel
virtual ModelPtr CreateModel(BasePtr _parent)
Create a new model.
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::SimbodyPhysics::Init
virtual void Init()
Initialize the physics engine.
gazebo::physics::SimbodyPhysics::integ
SimTK::Integrator * integ
Definition: SimbodyPhysics.hh:217
gazebo::physics::ModelPtr
boost::shared_ptr< Model > ModelPtr
Definition: PhysicsTypes.hh:93
gazebo::physics::SimbodyPhysics::GetParam
virtual boost::any GetParam(const std::string &_key) const
Get an parameter of the physics engine.
gazebo::physics::SimbodyPhysics::SetGravity
virtual void SetGravity(const ignition::math::Vector3d &_gravity)
Set the gravity vector.
gazebo::physics::SimbodyPhysics::OnPhysicsMsg
virtual void OnPhysicsMsg(ConstPhysicsPtr &_msg)
virtual callback for gztopic "~/physics".
system.hh
gazebo::physics::SimbodyPhysics::UpdatePhysics
virtual void UpdatePhysics()
Update the physics engine.
gazebo::physics::SimbodyPhysics::CreateCollision
virtual CollisionPtr CreateCollision(const std::string &_type, LinkPtr _body)
Create a collision.
gazebo::physics::SimbodyPhysics::simbodyPhysicsStepped
bool simbodyPhysicsStepped
Definition: SimbodyPhysics.hh:222
gazebo::physics::SimbodyPhysics::CreateShape
virtual ShapePtr CreateShape(const std::string &_shapeType, CollisionPtr _collision)
Create a physics::Shape object.
gazebo::physics::SimbodyPhysics::~SimbodyPhysics
virtual ~SimbodyPhysics()
Destructor.
gazebo::physics::SimbodyPhysics::SetSeed
virtual void SetSeed(uint32_t _seed)
Set the random number seed for the physics engine.
Shape.hh
gazebo::physics::SimbodyPhysics::InitForThread
virtual void InitForThread()
Init the engine for threads.
gazebo::physics::ShapePtr
boost::shared_ptr< Shape > ShapePtr
Definition: PhysicsTypes.hh:141
gazebo::physics::SimbodyPhysics::OnRequest
virtual void OnRequest(ConstRequestPtr &_msg)
virtual callback for gztopic "~/request".
gazebo::physics::BasePtr
boost::shared_ptr< Base > BasePtr
Definition: PhysicsTypes.hh:77
gazebo::physics::SimbodyPhysics::Pose2Transform
static SimTK::Transform Pose2Transform(const ignition::math::Pose3d &_pose)
Convert the given pose in x,y,z,thetax,thetay,thetaz format to a Simbody Transform.
gazebo::physics::SimbodyPhysics::SimbodyPhysics
SimbodyPhysics(WorldPtr _world)
Constructor.
gazebo::physics::SimbodyPhysics::Vector3ToVec3
static SimTK::Vec3 Vector3ToVec3(const ignition::math::Vector3d &_v)
Convert ignition::math::Vector3d to SimTK::Vec3.
gazebo::physics::SimbodyPhysics
Simbody physics engine.
Definition: SimbodyPhysics.hh:42
gazebo::msgs::Init
GAZEBO_VISIBLE void Init(google::protobuf::Message &_message, const std::string &_id="")
Initialize a message.
gazebo::physics::SimbodyPhysics::GetPose
static SimTK::Transform GetPose(sdf::ElementPtr _element)
If the given element contains a <pose> element, return it as a Transform.
gazebo::physics::LinkPtr
boost::shared_ptr< Link > LinkPtr
Definition: PhysicsTypes.hh:109
gazebo::physics::SimbodyPhysics::UpdateCollision
virtual void UpdateCollision()
Update the physics engine collision.
gazebo::physics::SimbodyPhysics::Reset
virtual void Reset()
Rest the physics engine.
gazebo::physics::SimbodyPhysics::contact
SimTK::CompliantContactSubsystem contact
Definition: SimbodyPhysics.hh:216
gazebo::physics::SimbodyPhysics::InitModel
void InitModel(const physics::ModelPtr _model)
Add a Model to the Simbody system.
gazebo::physics::SimbodyPhysics::forces
SimTK::GeneralForceSubsystem forces
Definition: SimbodyPhysics.hh:212
gazebo::physics::SimbodyPhysics::simbodyPhysicsInitialized
bool simbodyPhysicsInitialized
true if initialized
Definition: SimbodyPhysics.hh:220
gazebo::physics::JointPtr
boost::shared_ptr< Joint > JointPtr
Definition: PhysicsTypes.hh:117
gazebo::physics::SimbodyPhysics::Transform2PoseIgn
static ignition::math::Pose3d Transform2PoseIgn(const SimTK::Transform &_xAB)
Convert a Simbody transform to a pose in x,y,z, thetax,thetay,thetaz format.
gazebo::physics::SimbodyPhysics::GetTypeString
static std::string GetTypeString(unsigned int _type)
Convert Base::GetType() to string, this is needed by the MultibodyGraphMaker.
gazebo::physics::CollisionPtr
boost::shared_ptr< Collision > CollisionPtr
Definition: PhysicsTypes.hh:113
gazebo::physics::SimbodyPhysics::CreateLink
virtual LinkPtr CreateLink(ModelPtr _parent)
Create a new body.
gazebo::physics::SimbodyPhysics::system
SimTK::MultibodySystem system
Definition: SimbodyPhysics.hh:210
gazebo::physics::SimbodyPhysics::tracker
SimTK::ContactTrackerSubsystem tracker
Definition: SimbodyPhysics.hh:215
gazebo::physics::SimbodyPhysics::GetDynamicsWorld
SimTK::MultibodySystem * GetDynamicsWorld() const
Register a joint with the dynamics world.
gazebo::physics::Base::EntityType
EntityType
Unique identifiers for all entity types.
Definition: Base.hh:75
gazebo::physics::WorldPtr
boost::shared_ptr< World > WorldPtr
Definition: PhysicsTypes.hh:89
gazebo::physics::SimbodyPhysics::gravity
SimTK::Force::Gravity gravity
Definition: SimbodyPhysics.hh:213
gazebo::physics::SimbodyPhysics::CreateJoint
virtual JointPtr CreateJoint(const std::string &_type, ModelPtr _parent)
Create a new joint.
gazebo::physics::SimbodyPhysics::QuadToQuadIgn
static ignition::math::Quaterniond QuadToQuadIgn(const SimTK::Quaternion &_q)
Convert SimTK::Quaternion to ignition::math::Quaterniond.
gazebo::physics::SimbodyPhysics::Fini
virtual void Fini()
Finilize the physics engine.
gazebo::physics::SimbodyPhysics::QuadToQuad
static SimTK::Quaternion QuadToQuad(const ignition::math::Quaterniond &_q)
Convert ignition::math::Quaterniond to SimTK::Quaternion.
SimbodyTypes.hh
Simbody wrapper forward declarations and typedefs.
gazebo::physics::SimbodyPhysics::Load
virtual void Load(sdf::ElementPtr _sdf)
Load the physics engine.
simbody_inc.h