iCub-main
OdeInit.h
Go to the documentation of this file.
1 // -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*-
2 
3 /*
4 * Copyright (C) 2010 RobotCub Consortium, European Commission FP6 Project IST-004370
5 * Author: Vadim Tikhanoff
6 * email: vadim.tikhanoff@iit.it
7 * website: www.robotcub.org
8 * Permission is granted to copy, distribute, and/or modify this program
9 * under the terms of the GNU General Public License, version 2 or any
10 * later version published by the Free Software Foundation.
11 *
12 * A copy of the license can be found at
13 * http://www.robotcub.org/icub/license/gpl.txt
14 *
15 * This program is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
18 * Public License for more details
19 */
29 #ifndef ICUBSIMULATION_ODEINIT_INC
30 #define ICUBSIMULATION_ODEINIT_INC
31 
32 #include "iCub.h"
33 #include "world.h"
34 #include <time.h>
35 #include "iCubLogicalJoints.h"
36 #include "iCubSimulationControl.h"
37 #include "iCubSimulationIMU.h"
38 //#include <vector>
39 
40 #include "RobotConfig.h"
41 
42 #include <mutex>
43 #include <list>
44 
45 using namespace std;
46 using namespace yarp::dev;
47 
48 class ICubSim;
49 
55 class OdeInit {
56 public:
57  double SimTime;
58  dWorldID world;
59  dSpaceID space;
60  dJointGroupID contactgroup;
61  dGeomID ground;
62  //dJointFeedback *feedback;
63  //dJointFeedback *feedback1;
64  //dJointFeedback *feedback_mat;
65  std::mutex mtx;
66  std::mutex mtxTexture;
69  bool stop;
70  bool sync;
71  //bool verbose;
72  int verbosity;
73  string name;
75  iCubSimulationIMU * _imu{nullptr};
76  double contactFrictionCoefficient; //unlike the other ODE params fron .ini file that are used to intiialize the properties of the simulation (dWorldSet...),
77  //This parameter is employed on the run as contact joints are created (in OdeSdlSimulation::nearCallback() )
78  //for whole_body_skin_emul
79  struct contactOnSkin_t {
80  dGeomID body_geom_id;
82  int body_index; //if there are two iCub bodies colliding, they share the same contact geom and joint - but we need to know that they are two different
83  dContactGeom contact_geom;
84  dJointID contact_joint;
85  };
86  list<contactOnSkin_t> listOfSkinContactInfos;
87 
88 
89  void setName( string module ){
90  name = module;
91  }
92  string getName(){
93  return name;
94  }
95 
96  ~OdeInit();
97 
98  void setSimulationControl(iCubSimulationControl *control, int part);
99  void removeSimulationControl(int part);
100  void setSimulationIMU(iCubSimulationIMU *imu);
101  void removeSimulationIMU();
102  static OdeInit& init(RobotConfig *config);
103  void sendHomePos();
104 
105  static OdeInit& get();
106 
107  static void destroy();
108 
109  static void printGeomClassAndNr(int geom_class, int geom_nr);
110  static void printInfoOnSpace(dSpaceID my_space,const std::string & my_space_name);
111 
112 
113 private:
114  OdeInit(RobotConfig *config);
115  static OdeInit *_odeinit;
116 
118 };
119 
120 #endif
static RobotConfig * robot_config
Definition: iCub_Sim.cpp:84
bool sync
Definition: OdeInit.h:70
dSpaceID body_geom_space_id
Definition: OdeInit.h:81
int verbosity
Definition: OdeInit.h:72
The iCub header file.
Definition: iCub.h:75
ICubSim * _iCub
Definition: OdeInit.h:67
std::mutex mtx
Definition: OdeInit.h:65
string getName()
Definition: OdeInit.h:92
dWorldID world
Definition: OdeInit.h:58
STL namespace.
dGeomID ground
Definition: OdeInit.h:61
list< contactOnSkin_t > listOfSkinContactInfos
Definition: OdeInit.h:86
double contactFrictionCoefficient
Definition: OdeInit.h:76
dSpaceID space
Definition: OdeInit.h:59
iCubSimulationControl ** _controls
Definition: OdeInit.h:74
Header for the world creation.
std::mutex mtxTexture
Definition: OdeInit.h:66
dJointID contact_joint
Definition: OdeInit.h:84
ODE state information.
Definition: OdeInit.h:55
dJointGroupID contactgroup
Definition: OdeInit.h:60
dContactGeom contact_geom
Definition: OdeInit.h:83
void setName(string module)
Definition: OdeInit.h:89
worldSim * _wrld
Definition: OdeInit.h:68
string name
Definition: OdeInit.h:73
bool stop
Definition: OdeInit.h:69
double SimTime
Definition: OdeInit.h:57
This is the header file for the yarp interface of the iCubSimulation.