hrplib/hrpModel/World.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008, AIST, the University of Tokyo and General Robotix Inc.
3  * All rights reserved. This program is made available under the terms of the
4  * Eclipse Public License v1.0 which accompanies this distribution, and is
5  * available at http://www.eclipse.org/legal/epl-v10.html
6  * Contributors:
7  * National Institute of Advanced Industrial Science and Technology (AIST)
8  */
13 #ifndef OPENHRP_WORLD_H_INCLUDED
14 #define OPENHRP_WORLD_H_INCLUDED
15 
16 #include <vector>
17 #include <map>
18 #include <boost/shared_ptr.hpp>
19 #include <boost/intrusive_ptr.hpp>
20 #include <hrpUtil/Eigen3d.h>
21 #include "Body.h"
22 #include "ForwardDynamics.h"
23 #include "Config.h"
24 
25 namespace OpenHRP {
26  class CollisionSequence;
27 }
28 
29 namespace hrp {
30 
31  class Link;
32  class RangeSensor;
33 
34  class HRPMODEL_API WorldBase
35  {
36  public:
37  WorldBase();
38  virtual ~WorldBase();
39 
44  unsigned int numBodies() { return bodyInfoArray.size(); }
45 
51  BodyPtr body(int index);
52 
58  BodyPtr body(const std::string& name);
59 
66  return bodyInfoArray[index].forwardDynamics;
67  }
68 
74  int bodyIndex(const std::string& name);
75 
82  int addBody(BodyPtr body);
83 
87  void clearBodies();
88 
92  void clearCollisionPairs();
93 
98  void setTimeStep(double dt);
99 
104  double timeStep(void) const { return timeStep_; }
105 
110  void setCurrentTime(double tm);
111 
116  double currentTime(void) const { return currentTime_; }
117 
122  void setGravityAcceleration(const Vector3& g);
123 
128  const Vector3& getGravityAcceleration() { return g; }
129 
135  void enableSensors(bool on);
136 
140  void setEulerMethod();
141 
145  void setRungeKuttaMethod();
146 
150  virtual void initialize();
151 
155  virtual void calcNextState();
156 
163  std::pair<int,bool> getIndexOfLinkPairs(Link* link1, Link* link2);
164 
165  protected:
166 
167  double currentTime_;
168  double timeStep_;
169 
170  struct BodyInfo {
173  };
174  std::vector<BodyInfo> bodyInfoArray;
175 
177 
178  private:
179  void updateRangeSensors();
180  void updateRangeSensor(RangeSensor *sensor);
181 
182  typedef std::map<std::string, int> NameToIndexMap;
184 
185  typedef std::map<BodyPtr, int> BodyToIndexMap;
187 
188  struct LinkPairKey {
191  bool operator<(const LinkPairKey& pair2) const;
192  };
193  typedef std::map<LinkPairKey, int> LinkPairKeyToIndexMap;
195 
197 
199 
200  bool isEulerMethod; // Euler or Runge Kutta ?
201 
202  };
203 
204 
205  template <class TConstraintForceSolver> class World : public WorldBase
206  {
207  public:
208  TConstraintForceSolver constraintForceSolver;
209 
211 
212  virtual void initialize() {
214  constraintForceSolver.initialize();
215  }
216 
217  virtual void calcNextState(OpenHRP::CollisionSequence& corbaCollisionSequence) {
218  constraintForceSolver.solve(corbaCollisionSequence);
220  }
221  };
222 
223 };
224 
225 #endif
hrp::World::World
World()
Definition: hrplib/hrpModel/World.h:210
hrp::WorldBase::currentTime
double currentTime(void) const
get current time
Definition: hrplib/hrpModel/World.h:116
hrp::WorldBase::sensorsAreEnabled
bool sensorsAreEnabled
Definition: hrplib/hrpModel/World.h:176
hrp::WorldBase::bodyToIndexMap
BodyToIndexMap bodyToIndexMap
Definition: hrplib/hrpModel/World.h:186
hrp::World::calcNextState
virtual void calcNextState(OpenHRP::CollisionSequence &corbaCollisionSequence)
Definition: hrplib/hrpModel/World.h:217
hrp::WorldBase::BodyInfo::forwardDynamics
ForwardDynamicsPtr forwardDynamics
Definition: hrplib/hrpModel/World.h:172
hrp
Definition: ColdetModel.h:28
hrp::WorldBase::currentTime_
double currentTime_
Definition: hrplib/hrpModel/World.h:167
hrp::WorldBase::LinkPairKey::link1
Link * link1
Definition: hrplib/hrpModel/World.h:189
hrp::WorldBase::timeStep
double timeStep(void) const
get time step
Definition: hrplib/hrpModel/World.h:104
hrp::World
Definition: hrplib/hrpModel/World.h:205
hrp::WorldBase::g
Vector3 g
Definition: hrplib/hrpModel/World.h:198
hrp::WorldBase::numBodies
unsigned int numBodies()
get the number of bodies in this world
Definition: hrplib/hrpModel/World.h:44
OpenHRP
Definition: ConstraintForceSolver.h:19
hrp::WorldBase::linkPairKeyToIndexMap
LinkPairKeyToIndexMap linkPairKeyToIndexMap
Definition: hrplib/hrpModel/World.h:194
hrp::Vector3
Eigen::Vector3d Vector3
Definition: EigenTypes.h:11
hrp::WorldBase::numRegisteredLinkPairs
int numRegisteredLinkPairs
Definition: hrplib/hrpModel/World.h:196
hrp::RangeSensor
Definition: hrplib/hrpModel/Sensor.h:115
hrp::WorldBase::calcNextState
virtual void calcNextState()
compute forward dynamics and update current state
Definition: hrplib/hrpModel/World.cpp:135
hrp::ForwardDynamicsPtr
boost::shared_ptr< ForwardDynamics > ForwardDynamicsPtr
Definition: ForwardDynamics.h:92
hrp::World::constraintForceSolver
TConstraintForceSolver constraintForceSolver
Definition: hrplib/hrpModel/World.h:208
hrp::WorldBase::NameToIndexMap
std::map< std::string, int > NameToIndexMap
Definition: hrplib/hrpModel/World.h:182
hrp::WorldBase::bodyInfoArray
std::vector< BodyInfo > bodyInfoArray
Definition: hrplib/hrpModel/World.h:174
hrp::BodyPtr
boost::shared_ptr< Body > BodyPtr
Definition: Body.h:315
name
png_infop png_charpp name
Definition: png.h:2379
hrp::WorldBase
Definition: hrplib/hrpModel/World.h:34
hrp::WorldBase::timeStep_
double timeStep_
Definition: hrplib/hrpModel/World.h:168
hrp::WorldBase::BodyInfo::body
BodyPtr body
Definition: hrplib/hrpModel/World.h:171
hrp::WorldBase::initialize
virtual void initialize()
initialize this world. This must be called after all bodies are registered.
Definition: hrplib/hrpModel/World.cpp:99
hrp::WorldBase::LinkPairKey
Definition: hrplib/hrpModel/World.h:188
hrp::World::initialize
virtual void initialize()
initialize this world. This must be called after all bodies are registered.
Definition: hrplib/hrpModel/World.h:212
hrp::WorldBase::getGravityAcceleration
const Vector3 & getGravityAcceleration()
get gravity acceleration
Definition: hrplib/hrpModel/World.h:128
ForwardDynamics.h
hrp::WorldBase::forwardDynamics
ForwardDynamicsPtr forwardDynamics(int index)
get forward dynamics computation method for body
Definition: hrplib/hrpModel/World.h:65
Body.h
hrp::WorldBase::BodyInfo
Definition: hrplib/hrpModel/World.h:170
hrp::WorldBase::LinkPairKey::link2
Link * link2
Definition: hrplib/hrpModel/World.h:190
hrp::WorldBase::LinkPairKeyToIndexMap
std::map< LinkPairKey, int > LinkPairKeyToIndexMap
Definition: hrplib/hrpModel/World.h:193
Eigen3d.h
hrp::WorldBase::BodyToIndexMap
std::map< BodyPtr, int > BodyToIndexMap
Definition: hrplib/hrpModel/World.h:185
hrp::WorldBase::isEulerMethod
bool isEulerMethod
Definition: hrplib/hrpModel/World.h:200
hrp::WorldBase::nameToBodyIndexMap
NameToIndexMap nameToBodyIndexMap
Definition: hrplib/hrpModel/World.h:183


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Wed Sep 7 2022 02:51:04