NTRT Simulator
 All Classes Files Functions Variables Typedefs Friends Pages
AppRibModelLearning.cpp
1 /*
2  * Copyright © 2012, United States Government, as represented by the
3  * Administrator of the National Aeronautics and Space Administration.
4  * All rights reserved.
5  *
6  * The NASA Tensegrity Robotics Toolkit (NTRT) v1 platform is licensed
7  * under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * http://www.apache.org/licenses/LICENSE-2.0.
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
15  * either express or implied. See the License for the specific language
16  * governing permissions and limitations under the License.
17 */
18 
28 // This application
29 #include "RibModel.h"
30 
31 // This library
33 #include "core/tgModel.h"
34 #include "core/tgSimView.h"
35 #include "core/tgSimViewGraphics.h"
36 #include "core/tgSimulation.h"
37 #include "core/tgWorld.h"
38 // The C++ Standard Library
39 #include <iostream>
40 
48 int main(int argc, char** argv)
49 {
50  std::cout << "AppNestedStructureTest" << std::endl;
51 
52  // First create the world
53  const tgWorld::Config config =
54  {
55  981 // gravity, cm/sec^2
56  };
57  tgWorld world(config);
58 
59  // Second create the view
60  const double stepSize = 1.0/1000.0; // Seconds
61  const double renderRate = 1.0/60.0; // Seconds
62  tgSimViewGraphics view(world, stepSize, renderRate);
63 
64  // Third create the simulation
65  tgSimulation simulation(view);
66 
67  // Fourth create the models with their controllers and add the models to the
68  // simulation
69  const int segments = 12;
70  RibModel* myModel =
71  new RibModel(segments);
72 
73  /* Required for setting up learning file input/output. */
74  const std::string suffix((argc > 1) ? argv[1] : "default");
75  const int segmentSpan = 3;
76  const int numMuscles = 7;
77  const int numParams = 2;
78  BaseSpineCPGControl::Config control_config(segmentSpan, numMuscles, numMuscles, numParams);
79  BaseSpineCPGControl* const myControl =
80  new BaseSpineCPGControl(control_config, suffix);
81  myModel->attach(myControl);
82 
83  simulation.addModel(myModel);
84 
85  int i = 0;
86  while (i < 2000)
87  {
88  simulation.run(15000);
89  simulation.reset();
90  i++;
91  }
92 
94 
98  #if (0)
99  delete myControl;
100  #endif
101  //Teardown is handled by delete, so that should be automatic
102  return 0;
103 }
Implements a spine model with a rib cage.
Contains the definition of class tgSimulation $Id$.
Contains the definition of class tgModel. $Id$.
Contains the definition of class tgSimViewGraphics $Id$.
Contains the definition of class tgWorld $Id$.
A controller for the template class BaseSpineModelLearning.
int main(int argc, char **argv)
Contains the definition of class tgSimView $Id$.
void attach(tgObserver< T > *pObserver)
Definition: tgSubject.h:90