SCL  1.0
Standard Control Library : Control, dynamics, physics, and simulation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends Macros Groups Pages
SDatabase.hpp
Go to the documentation of this file.
1 /* This file is part of scl, a control and simulation library
2 for robots and biomechanical models.
3 
4 scl is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 3 of the License, or (at your option) any later version.
8 
9 Alternatively, you can redistribute it and/or
10 modify it under the terms of the GNU General Public License as
11 published by the Free Software Foundation; either version 2 of
12 the License, or (at your option) any later version.
13 
14 scl is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18 
19 You should have received a copy of the GNU Lesser General Public
20 License and a copy of the GNU General Public License along with
21 scl. If not, see <http://www.gnu.org/licenses/>.
22 */
23 /* \file SDatabase.hpp
24  *
25  * Created on: Jun 21, 2010
26  *
27  * Copyright (C) 2011
28  *
29  * Author: Samir Menon <smenon@stanford.edu>
30  */
31 
34 #ifndef SDATABASE_HPP_
35 #define SDATABASE_HPP_
36 
37 //Controller data --> Dynamically updated information.
38 #include <scl/control/task/data_structs/SControllerMultiTask.hpp>
39 #include <scl/control/gc/data_structs/SControllerGc.hpp>
40 
41 //Parser data --> Static information about the robot
42 #include <scl/data_structs/SRobotParsed.hpp>
43 #include <scl/data_structs/SGraphicsParsed.hpp>
44 #include <scl/data_structs/SRobotIO.hpp>
45 #include <scl/data_structs/SActuatorSetMuscleParsed.hpp>
46 #include <scl/data_structs/SUIParsed.hpp>
47 
48 #include <scl/graphics/chai/data_structs/SGraphicsChai.hpp>
49 
50 //3rdparty Utils
51 #include <sutil/CMappedList.hpp>
52 #include <sutil/CMappedMultiLevelList.hpp>
53 
54 #include <map>
55 #include <string>
56 #include <iostream>
57 
58 namespace scl {
59 
65 {
68 
71 
81 
84 
88  std::string file_name_;
89 };
90 
111 {
112 public:
123 
132 
141 
143  sBool getControllersForRobot(const std::string & arg_robot,
144  std::vector<SControllerBase*>& ret_controllers)
145  {
146  ret_controllers.clear();
148  for(it = controllers_.begin(), ite = controllers_.end(); it!=ite; ++it)
149  {
150  SControllerBase* tmp = *it;
151 
152  if(S_NULL == tmp->robot_)
153  {
154  std::cout<<"SControllerData::getControllersForRobot()"
155  <<"WARNING : Found NULL robot controller ds in the pile.";
156  return false;
157  }
158 
159  if(tmp->robot_->name_ == arg_robot)
160  { ret_controllers.push_back(tmp); }
161  }
162  if(0 < ret_controllers.size())
163  { return true; }
164  else
165  { return false; }
166  }
167 };
168 
170 #define SCL_NUM_UI_POINTS 12
171 
172 #define SCL_NUM_UI_FLAGS 9
173 
179 struct SGuiData
180 {
181  // Eigen requires redefining the new operator for classes that contain fixed size Eigen member-data.
182  // See http://eigen.tuxfamily.org/dox/StructHavingEigenMembers.html
183  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
184 
193 
195  Eigen::Vector3d ui_point_[SCL_NUM_UI_POINTS];
196 
197  sBool ui_flag_[SCL_NUM_UI_FLAGS];
198 
202 
203  sBool glut_initialized_;
204 
205  SGuiData() : glut_initialized_(false) {
207  for(int i=0;i<SCL_NUM_UI_FLAGS;++i)ui_flag_[i] = false;
208  }
209 };
210 
220 struct SIOData
221 {
226 };
227 
228 
239 class SDatabase{
240 public:
241  /*******************************************
242  ********************************************
243  * The Static Data:
244  * Doesn't change during runtime
245  * [[Zero writers, multiple readers]]
246  ********************************************/
249 
250  /*******************************************
251  ********************************************
252  * The Dynamic Data:
253  * Changes during runtime
254  * [[Single writer, multiple readers]]
255  *
256  * NOTE: The programmer is responsible for
257  * ensuring threaded safety.
258  ********************************************/
262 
266 
270 
271  /***********
272  * Time data:
273  ************/
276 
280 
283 
285  std::string cwd_;
286 
288  std::string dir_specs_;
289 
290  /***********
291  * Exec data:
292  ************/
295 
298 
301 
304 
307 
308  SDatabase()
309  {
310  sim_ticks_ = 0;
311 #ifdef SCL_HIGH_QUALITY_SIMULATION
312  sim_dt_ = 0.00005;//0.05ms
313 #else
314  sim_dt_ = 0.0005;//0.5ms
315 #endif
316  time_ = 0.0;
317  cwd_ = "";
318  dir_specs_ = "";
319  running_ = true;
320  pause_ctrl_dyn_ = false;
321  step_ctrl_dyn_ = false;
322  pause_graphics_ = false;
323  param_logging_on_ = false;
324  }
325 };
326 
327 }
328 
329 #endif /* SDATABASE_HPP_ */
std::string file_name_
Definition: SDatabase.hpp:88
sLongLong sim_ticks_
Definition: SDatabase.hpp:275
Definition: SDatabase.hpp:64
sutil::CMappedList< std::string, SRobotParsed > robots_
Definition: SDatabase.hpp:70
sBool param_logging_on_
Definition: SDatabase.hpp:306
sutil::CMappedList< std::string, SGraphicsParsed > graphics_worlds_
Definition: SDatabase.hpp:67
sFloat time_
Definition: SDatabase.hpp:282
sutil::CMappedList< std::string, SRobotIO > io_data_
Definition: SDatabase.hpp:225
const SRobotParsed * robot_
Definition: SControllerBase.hpp:55
sBool pause_ctrl_dyn_
Definition: SDatabase.hpp:297
Definition: CMappedList.hpp:85
#define SCL_NUM_UI_POINTS
Definition: SDatabase.hpp:170
Definition: SDatabase.hpp:239
Definition: CMappedList.hpp:277
sutil::CMappedList< std::string, SActuatorSetMuscleParsed > muscle_sets_
Definition: SDatabase.hpp:80
EIGEN_MAKE_ALIGNED_OPERATOR_NEW sutil::CMappedList< std::string, scl::SGraphicsChai > chai_data_
Definition: SDatabase.hpp:192
sBool pause_graphics_
Definition: SDatabase.hpp:303
sBool getControllersForRobot(const std::string &arg_robot, std::vector< SControllerBase * > &ret_controllers)
Definition: SDatabase.hpp:143
#define SCL_NUM_UI_FLAGS
Definition: SDatabase.hpp:172
Definition: CMappedList.hpp:549
bool sBool
Definition: DataTypes.hpp:54
sUInt ui_point_selector_
Definition: SDatabase.hpp:201
sBool step_ctrl_dyn_
Definition: SDatabase.hpp:300
Definition: SControllerBase.hpp:48
SGuiData s_gui_
Definition: SDatabase.hpp:269
SParserData s_parser_
Definition: SDatabase.hpp:248
Definition: SDatabase.hpp:179
sutil::CMappedPointerList< std::string, STaskBase, true > tasks_
Definition: SDatabase.hpp:131
sutil::CMappedPointerList< std::string, SNonControlTaskBase, true > tasks_non_ctrl_
Definition: SDatabase.hpp:140
Eigen::Vector3d ui_point_[SCL_NUM_UI_POINTS]
Definition: SDatabase.hpp:195
long long sLongLong
Definition: DataTypes.hpp:66
std::string name_
Definition: SObject.hpp:69
sutil::CMappedList< std::string, SUIParsed > user_interface_
Definition: SDatabase.hpp:83
sutil::CMappedPointerList< std::string, SControllerBase, true > controllers_
Definition: SDatabase.hpp:122
SControllerData s_controller_
Definition: SDatabase.hpp:261
std::string cwd_
Definition: SDatabase.hpp:285
sBool running_
Definition: SDatabase.hpp:294
Definition: SDatabase.hpp:110
double sFloat
Definition: DataTypes.hpp:72
sFloat sim_dt_
Definition: SDatabase.hpp:279
SIOData s_io_
Definition: SDatabase.hpp:265
std::string dir_specs_
Definition: SDatabase.hpp:288
Definition: SDatabase.hpp:220