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
OdeInit::world
dWorldID world
Definition: OdeInit.h:58
RobotConfig
Definition: RobotConfig.h:55
OdeInit::verbosity
int verbosity
Definition: OdeInit.h:72
OdeInit::stop
bool stop
Definition: OdeInit.h:69
OdeInit::contactFrictionCoefficient
double contactFrictionCoefficient
Definition: OdeInit.h:76
world.h
Header for the world creation.
OdeInit::getName
string getName()
Definition: OdeInit.h:92
iCubSimulationIMU.h
yarp::dev
Definition: DebugInterfaces.h:52
OdeInit::mtxTexture
std::mutex mtxTexture
Definition: OdeInit.h:66
OdeInit::sync
bool sync
Definition: OdeInit.h:70
OdeInit::contactOnSkin_t::body_geom_space_id
dSpaceID body_geom_space_id
Definition: OdeInit.h:81
worldSim
Definition: world.h:186
OdeInit::contactOnSkin_t
Definition: OdeInit.h:79
OdeInit::SimTime
double SimTime
Definition: OdeInit.h:57
OdeInit::name
string name
Definition: OdeInit.h:73
yarp::dev::iCubSimulationControl
Definition: iCubSimulationControl.h:77
string
string(REPLACE "-rdynamic" "" CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS}") include_directories($
Definition: CMakeLists.txt:9
ICubSim
Definition: iCub.h:75
control
@ control
Definition: ST_M1_dataType.h:63
iCub.h
The iCub header file
RobotConfig.h
OdeInit::_controls
iCubSimulationControl ** _controls
Definition: OdeInit.h:74
OdeInit::listOfSkinContactInfos
list< contactOnSkin_t > listOfSkinContactInfos
Definition: OdeInit.h:86
iCubSimulationIMU
Definition: iCubSimulationIMU.h:22
OdeInit::contactgroup
dJointGroupID contactgroup
Definition: OdeInit.h:60
OdeInit::setName
void setName(string module)
Definition: OdeInit.h:89
OdeInit::ground
dGeomID ground
Definition: OdeInit.h:61
OdeInit::contactOnSkin_t::body_index
int body_index
Definition: OdeInit.h:82
OdeInit::_wrld
worldSim * _wrld
Definition: OdeInit.h:68
robot_config
static RobotConfig * robot_config
Definition: iCub_Sim.cpp:84
OdeInit::contactOnSkin_t::contact_joint
dJointID contact_joint
Definition: OdeInit.h:84
iCubLogicalJoints.h
OdeInit::space
dSpaceID space
Definition: OdeInit.h:59
OdeInit::contactOnSkin_t::body_geom_id
dGeomID body_geom_id
Definition: OdeInit.h:80
OdeInit::_iCub
ICubSim * _iCub
Definition: OdeInit.h:67
iCubSimulationControl.h
This is the header file for the yarp interface of the iCubSimulation.
OdeInit::contactOnSkin_t::contact_geom
dContactGeom contact_geom
Definition: OdeInit.h:83
OdeInit::mtx
std::mutex mtx
Definition: OdeInit.h:65
OdeInit
ODE state information.
Definition: OdeInit.h:55