openrave.org

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
physicsengine.h
Go to the documentation of this file.
1 // -*- coding: utf-8 -*-
2 // Copyright (C) 2006-2010 Rosen Diankov (rosen.diankov@gmail.com)
3 //
4 // This file is part of OpenRAVE.
5 // OpenRAVE is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU Lesser General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #ifndef OPENRAVE_PHYSICSENGINE_H
23 #define OPENRAVE_PHYSICSENGINE_H
24 
25 namespace OpenRAVE {
26 
29 {
31 };
32 
37 {
38 public:
39  PhysicsEngineBase(EnvironmentBasePtr penv) : InterfaceBase(PT_PhysicsEngine, penv) {
40  }
41  virtual ~PhysicsEngineBase() {
42  }
43 
45  static inline InterfaceType GetInterfaceTypeStatic() {
46  return PT_PhysicsEngine;
47  }
48 
50  virtual bool SetPhysicsOptions(int physicsoptions) = 0;
51  virtual int GetPhysicsOptions() const = 0;
52 
54  virtual bool SetPhysicsOptions(std::ostream& sout, std::istream& sinput) RAVE_DEPRECATED = 0;
55 
57  virtual bool InitEnvironment() = 0;
58 
61  virtual void DestroyEnvironment() = 0;
62 
64  virtual bool InitKinBody(KinBodyPtr body) = 0;
65 
67  virtual void RemoveKinBody(KinBodyPtr body) = 0;
68 
74  virtual bool SetLinkVelocity(KinBody::LinkPtr link, const Vector& linearvel, const Vector& angularvel) = 0;
75 
80  virtual bool SetLinkVelocities(KinBodyPtr body, const std::vector<std::pair<Vector,Vector> >& velocities) = 0;
81 
85  virtual bool GetLinkVelocity(KinBody::LinkConstPtr link, Vector& linearvel, Vector& angularvel) = 0;
86 
89  virtual bool GetLinkVelocities(KinBodyConstPtr body, std::vector<std::pair<Vector,Vector> >& velocities) = 0;
90 
95  virtual bool SetBodyForce(KinBody::LinkPtr link, const Vector& force, const Vector& position, bool bAdd) OPENRAVE_DUMMY_IMPLEMENTATION;
96 
101  virtual bool SetBodyTorque(KinBody::LinkPtr link, const Vector& torque, bool bAdd) OPENRAVE_DUMMY_IMPLEMENTATION;
102 
106  virtual bool AddJointTorque(KinBody::JointPtr pjoint, const std::vector<dReal>& pTorques) OPENRAVE_DUMMY_IMPLEMENTATION;
107 
111  virtual bool GetLinkForceTorque(KinBody::LinkConstPtr link, Vector& force, Vector& torque) OPENRAVE_DUMMY_IMPLEMENTATION;
112 
116  //virtual bool GetJointForceTorque(KinBody::JointConstPtr joint, KinBody::LinkConstPtr link, Vector& force, Vector& torque) OPENRAVE_DUMMY_IMPLEMENTATION;
117 
118 
120  virtual void SetGravity(const Vector& gravity) OPENRAVE_DUMMY_IMPLEMENTATION;
121  virtual Vector GetGravity() OPENRAVE_DUMMY_IMPLEMENTATION;
122 
125  virtual void SimulateStep(dReal fTimeElapsed)=0;
126 
128  virtual bool GetBodyVelocity(KinBodyConstPtr body, std::vector<Vector>& vLinearVelocities, std::vector<Vector>& vAngularVelocities) RAVE_DEPRECATED {
129  std::vector<std::pair<Vector,Vector> > velocities;
130  if( !GetLinkVelocities(body, velocities) ) {
131  return false;
132  }
133  vLinearVelocities.resize(velocities.size());
134  vAngularVelocities.resize(velocities.size());
135  for(size_t i = 0; i < velocities.size(); ++i) {
136  vLinearVelocities[i] = velocities[i].first;
137  vAngularVelocities[i] = velocities[i].second;
138  }
139  return true;
140  }
141 
142  virtual bool SetBodyVelocity(KinBodyPtr body, const std::vector<Vector>& vLinearVelocities, const std::vector<Vector>& vAngularVelocities) RAVE_DEPRECATED {
143  BOOST_ASSERT(vLinearVelocities.size()==vAngularVelocities.size());
144  std::vector<std::pair<Vector,Vector> > velocities(vLinearVelocities.size());
145  for(size_t i = 0; i < velocities.size(); ++i) {
146  velocities[i].first = vLinearVelocities[i];
147  velocities[i].second = vAngularVelocities[i];
148  }
149  return SetLinkVelocities(body,velocities);
150  }
151 
152 protected:
155  body->SetUserData(GetXMLId(), data);
156  }
157 
158 private:
159  virtual const char* GetHash() const {
161  }
162 };
163 
164 } // end namespace OpenRAVE
165 
166 #endif