server/UtDynamicsSimulator/World.h
Go to the documentation of this file.
1 // -*- mode: c++; indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
2 /*
3  * Copyright (c) 2008, AIST, the University of Tokyo and General Robotix Inc.
4  * All rights reserved. This program is made available under the terms of the
5  * Eclipse Public License v1.0 which accompanies this distribution, and is
6  * available at http://www.eclipse.org/legal/epl-v10.html
7  * Contributors:
8  * The University of Tokyo
9  * National Institute of Advanced Industrial Science and Technology (AIST)
10  * General Robotix Inc.
11  */
12 #ifndef OPENHRP_WORLD_H_INCLUDED
13 #define OPENHRP_WORLD_H_INCLUDED
14 
15 #include <vector>
16 #include <map>
17 #include <list>
18 #include <vector>
19 #include <fMatrix3.h>
20 #include <hrpCorba/DynamicsSimulator.hh>
21 
22 class pSim;
23 class Joint;
24 class SDContactPair;
25 
26 
27  class Sensor;
28  class ForceSensor;
29  class RateGyroSensor;
30  class AccelSensor;
31 
32 
33  class World
34  {
35 // friend class CharacterInfo;
37  {
38  friend class World;
39  CharacterInfo(Joint* _root, const std::string& _name): name(_name) {
40  root = _root;
41  n_joints = 0;
42  }
43  std::string name;
44  std::vector<Joint*> links;
45  std::vector<int> jointIDs;
46  int n_joints;
48  public:
50  }
51 
52  };
53  public:
54  World();
55  ~World();
56 
57  void clearCollisionPairs();
58 
59  void setTimeStep(double);
60  double timeStep(void) const { return timeStep_; }
61 
62  void setCurrentTime(double);
63  double currentTime(void) const { return currentTime_; }
64 
65  void setGravityAcceleration(const fVec3& g);
66  const fVec3& getGravityAcceleration() { return g; }
67 
68  void enableSensors(bool on);
69 
70  void setEulerMethod();
71  void setRungeKuttaMethod();
72 
73  void initialize();
74  void calcNextState(OpenHRP::CollisionSequence& corbaCollisionSequence);
75 
76 // std::pair<int,bool> getIndexOfLinkPairs(BodyPtr body1, Link* link1, BodyPtr body2, Link* link2);
77 
78  pSim* Chain() {
79  return chain;
80  }
81 
82  int addSensor(Joint* jnt, int sensorType, int id, const std::string name, const fVec3& _localPos, const fMat33& _localR);
83 
84  Sensor* findSensor(const char* sensorName, const char* charName);
85 
86  int numSensors(int sensorType, const char* charName);
87  int numSensors() {
88  return sensors.size();
89  }
90 
91  void getAllCharacterData(const char* name, OpenHRP::DynamicsSimulator::LinkDataType type, OpenHRP::DblSequence_out& rdata);
92  void setAllCharacterData(const char* name, OpenHRP::DynamicsSimulator::LinkDataType type, const OpenHRP::DblSequence& wdata);
93  void getAllCharacterPositions(OpenHRP::CharacterPositionSequence& all_char_pos);
94  void getAllSensorStates(OpenHRP::SensorStateSequence& all_sensor_states);
95  void calcCharacterJacobian(const char* characterName, const char* baseLink, const char* targetLink, fMat& J);
96 
97  void addCollisionCheckLinkPair(Joint* jnt1, Joint* jnt2, double staticFriction, double slipFriction, double epsilon);
98 
99  void addCharacter(Joint* rjoint, const std::string& _name, OpenHRP::LinkInfoSequence_var links);
100  Joint* rootJoint(int index);
101  int numLinks(int index) {
102  return characters[index].links.size();
103  }
104  int numJoints(int index) {
105  return characters[index].n_joints;
106  }
107 
108  int numCharacter() {
109  return characters.size();
110  }
111 
112  protected:
114  std::vector<SDContactPair*> contact_pairs;
115  std::vector<Sensor*> sensors;
116 
117  std::vector<CharacterInfo> characters;
118 
119  private:
120 
121  void _get_all_character_data_sub(Joint* cur, int index, OpenHRP::DynamicsSimulator::LinkDataType type, OpenHRP::DblSequence_out& rdata);
122  void _set_all_character_data_sub(Joint* cur, int index, OpenHRP::DynamicsSimulator::LinkDataType type, const OpenHRP::DblSequence& wdata);
123  void _get_all_sensor_states_sub(Joint* cur, int& count, OpenHRP::SensorState& state);
124 
125  double currentTime_;
126  double timeStep_;
127 
131 #if 0
132  typedef std::map<std::string, int> NameToIndexMap;
133  NameToIndexMap nameToBodyIndexMap;
134 
135  typedef std::map<BodyPtr, int> BodyToIndexMap;
136  BodyToIndexMap bodyToIndexMap;
137 
138  struct LinkPairKey {
139  BodyPtr body1;
140  BodyPtr body2;
141  Link* link1;
142  Link* link2;
143  bool operator<(const LinkPairKey& pair2) const;
144  };
145  typedef std::map<LinkPairKey, int> LinkPairKeyToIndexMap;
146  LinkPairKeyToIndexMap linkPairKeyToIndexMap;
147 #endif
148 
150 
152 
153  bool isEulerMethod; // Euler or Runge Kutta ?
154 
156 
157  };
158 
159 
160 #endif
World::numLinks
int numLinks(int index)
Definition: server/UtDynamicsSimulator/World.h:101
World::currentTime
double currentTime(void) const
Definition: server/UtDynamicsSimulator/World.h:63
World::setGravityAcceleration
void setGravityAcceleration(const fVec3 &g)
Definition: server/UtDynamicsSimulator/World.cpp:111
World::CharacterInfo::CharacterInfo
CharacterInfo(Joint *_root, const std::string &_name)
Definition: server/UtDynamicsSimulator/World.h:39
World::setTimeStep
void setTimeStep(double)
Definition: server/UtDynamicsSimulator/World.cpp:99
fVec3
3-element vector class.
Definition: fMatrix3.h:206
World::CharacterInfo::~CharacterInfo
~CharacterInfo()
Definition: server/UtDynamicsSimulator/World.h:49
World::getAllSensorStates
void getAllSensorStates(OpenHRP::SensorStateSequence &all_sensor_states)
Definition: server/UtDynamicsSimulator/World.cpp:492
World::addCharacter
void addCharacter(Joint *rjoint, const std::string &_name, OpenHRP::LinkInfoSequence_var links)
Definition: server/UtDynamicsSimulator/World.cpp:616
Sensor
Definition: server/UtDynamicsSimulator/Sensor.h:24
Joint
The class for representing a joint.
Definition: chain.h:538
World::_get_all_character_data_sub
void _get_all_character_data_sub(Joint *cur, int index, OpenHRP::DynamicsSimulator::LinkDataType type, OpenHRP::DblSequence_out &rdata)
Definition: server/UtDynamicsSimulator/World.cpp:378
World::Chain
pSim * Chain()
Definition: server/UtDynamicsSimulator/World.h:78
World::CharacterInfo::links
std::vector< Joint * > links
Definition: server/UtDynamicsSimulator/World.h:44
ForceSensor
Definition: server/UtDynamicsSimulator/Sensor.h:64
SDContactPair
Definition: sdcontact.h:23
World::CharacterInfo::root
Joint * root
Definition: server/UtDynamicsSimulator/World.h:47
type
png_infop png_charp png_int_32 png_int_32 int * type
Definition: png.h:2330
World::getAllCharacterData
void getAllCharacterData(const char *name, OpenHRP::DynamicsSimulator::LinkDataType type, OpenHRP::DblSequence_out &rdata)
Definition: server/UtDynamicsSimulator/World.cpp:354
World::getGravityAcceleration
const fVec3 & getGravityAcceleration()
Definition: server/UtDynamicsSimulator/World.h:66
World::enableSensors
void enableSensors(bool on)
Definition: server/UtDynamicsSimulator/World.cpp:119
RateGyroSensor
Definition: server/UtDynamicsSimulator/Sensor.h:78
World::setRungeKuttaMethod
void setRungeKuttaMethod()
Definition: server/UtDynamicsSimulator/World.cpp:277
World::~World
~World()
Definition: server/UtDynamicsSimulator/World.cpp:81
fMat33
3x3 matrix class.
Definition: fMatrix3.h:29
fMat
Matrix of generic size. The elements are stored in a one-dimensional array in row-major order.
Definition: fMatrix.h:46
World::numJoints
int numJoints(int index)
Definition: server/UtDynamicsSimulator/World.h:104
World::World
World()
Definition: server/UtDynamicsSimulator/World.cpp:68
World
Definition: server/UtDynamicsSimulator/World.h:33
World::findSensor
Sensor * findSensor(const char *sensorName, const char *charName)
Definition: server/UtDynamicsSimulator/World.cpp:325
World::timeStep
double timeStep(void) const
Definition: server/UtDynamicsSimulator/World.h:60
World::CharacterInfo::name
std::string name
Definition: server/UtDynamicsSimulator/World.h:43
fMatrix3.h
3x3 matrix and 3-element vector classes.
World::setEulerMethod
void setEulerMethod()
Definition: server/UtDynamicsSimulator/World.cpp:271
World::CharacterInfo::n_joints
int n_joints
Definition: server/UtDynamicsSimulator/World.h:46
World::calcNextState
void calcNextState(OpenHRP::CollisionSequence &corbaCollisionSequence)
Definition: server/UtDynamicsSimulator/World.cpp:146
World::numRegisteredLinkPairs
int numRegisteredLinkPairs
Definition: server/UtDynamicsSimulator/World.h:149
World::getAllCharacterPositions
void getAllCharacterPositions(OpenHRP::CharacterPositionSequence &all_char_pos)
Definition: server/UtDynamicsSimulator/World.cpp:473
World::numSensors
int numSensors()
Definition: server/UtDynamicsSimulator/World.h:87
World::_set_all_character_data_sub
void _set_all_character_data_sub(Joint *cur, int index, OpenHRP::DynamicsSimulator::LinkDataType type, const OpenHRP::DblSequence &wdata)
Definition: server/UtDynamicsSimulator/World.cpp:429
hrp::BodyPtr
boost::shared_ptr< Body > BodyPtr
Definition: Body.h:315
World::update_rate_gyro_sensor
void update_rate_gyro_sensor(RateGyroSensor *rgs)
Definition: server/UtDynamicsSimulator/World.cpp:254
name
png_infop png_charpp name
Definition: png.h:2379
World::characters
std::vector< CharacterInfo > characters
Definition: server/UtDynamicsSimulator/World.h:117
World::currentTime_
double currentTime_
Definition: server/UtDynamicsSimulator/World.h:125
World::chain
pSim * chain
Definition: server/UtDynamicsSimulator/World.h:113
World::numCharacter
int numCharacter()
Definition: server/UtDynamicsSimulator/World.h:108
World::rootJoint
Joint * rootJoint(int index)
Definition: server/UtDynamicsSimulator/World.cpp:635
World::_get_all_sensor_states_sub
void _get_all_sensor_states_sub(Joint *cur, int &count, OpenHRP::SensorState &state)
World::update_force_sensor
void update_force_sensor(ForceSensor *fs)
Definition: server/UtDynamicsSimulator/World.cpp:237
World::CharacterInfo::jointIDs
std::vector< int > jointIDs
Definition: server/UtDynamicsSimulator/World.h:45
World::setCurrentTime
void setCurrentTime(double)
Definition: server/UtDynamicsSimulator/World.cpp:105
World::sensorsAreEnabled
bool sensorsAreEnabled
Definition: server/UtDynamicsSimulator/World.h:155
World::addSensor
int addSensor(Joint *jnt, int sensorType, int id, const std::string name, const fVec3 &_localPos, const fMat33 &_localR)
Definition: server/UtDynamicsSimulator/World.cpp:312
World::addCollisionCheckLinkPair
void addCollisionCheckLinkPair(Joint *jnt1, Joint *jnt2, double staticFriction, double slipFriction, double epsilon)
Definition: server/UtDynamicsSimulator/World.cpp:605
World::timeStep_
double timeStep_
Definition: server/UtDynamicsSimulator/World.h:126
World::update_accel_sensor
void update_accel_sensor(AccelSensor *as)
Definition: server/UtDynamicsSimulator/World.cpp:259
World::contact_pairs
std::vector< SDContactPair * > contact_pairs
Definition: server/UtDynamicsSimulator/World.h:114
World::initialize
void initialize()
Definition: server/UtDynamicsSimulator/World.cpp:125
World::isEulerMethod
bool isEulerMethod
Definition: server/UtDynamicsSimulator/World.h:153
World::CharacterInfo
Definition: server/UtDynamicsSimulator/World.h:36
World::calcCharacterJacobian
void calcCharacterJacobian(const char *characterName, const char *baseLink, const char *targetLink, fMat &J)
Definition: server/UtDynamicsSimulator/World.cpp:565
World::clearCollisionPairs
void clearCollisionPairs()
World::g
fVec3 g
Definition: server/UtDynamicsSimulator/World.h:151
World::setAllCharacterData
void setAllCharacterData(const char *name, OpenHRP::DynamicsSimulator::LinkDataType type, const OpenHRP::DblSequence &wdata)
Definition: server/UtDynamicsSimulator/World.cpp:406
AccelSensor
Definition: server/UtDynamicsSimulator/Sensor.h:91
World::sensors
std::vector< Sensor * > sensors
Definition: server/UtDynamicsSimulator/World.h:115
pSim
Main class for forward dynamics computation.
Definition: psim.h:446


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