NTRT Simulator  Version: Master
 All Classes Namespaces Files Functions Variables Typedefs Friends Pages
AppOctaCL_sine.cpp
Go to the documentation of this file.
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 
27 // This application
29 // This library
30 #include "OctaCLSine.h"
32 #include "core/tgModel.h"
33 #include "core/tgSimView.h"
34 #include "core/tgSimViewGraphics.h"
35 #include "core/tgSimulation.h"
36 #include "core/tgWorld.h"
37 // The C++ Standard Library
38 #include <iostream>
39 
47 int main(int argc, char** argv)
48 {
49  std::cout << "AppNestedStructureTest" << std::endl;
50 
51  // First create the world
52  const tgWorld::Config config(981); // gravity, cm/sec^2
53  tgWorld world(config);
54 
55  // Second create the view
56  const double stepSize = 1.0/1000.0; // Seconds
57  const double renderRate = 1.0/60.0; // Seconds
58  tgSimView view(world, stepSize, renderRate);
59 
60  // Third create the simulation
61  tgSimulation simulation(view);
62 
63  // Fourth create the models with their controllers and add the models to the
64  // simulation
65  const int segments = 3;
67  new FlemonsSpineModelLearningCL(segments);
68 
69  /* Required for setting up learning file input/output. */
70  const std::string suffix((argc > 1) ? argv[1] : "default");
71 
72  const int segmentSpan = 3;
73  const int numMuscles = 4;
74  const int numParams = 2;
75  const int segNumber = 1;
76 
77  const double controlTime = 0.1;
78  const double lowPhase = -1 * M_PI;
79  const double highPhase = M_PI;
80  const double lowAmplitude = 0.0;
81  // Account for descending command
82  const double highAmplitude = 30.0 * 3;
83 
84  const double tension = 0.0;
85  const double kPosition = 400.0;
86  const double kVelocity = 40.0;
87 
88  const bool def = true;
89 
90  // Overridden by def being true
91  const double cl = 10.0;
92  const double lf = 0.0;
93  // Account for descending command
94  const double hf = 30.0 * 3;
95 
96 
97  BaseSpineCPGControl::Config control_config(segmentSpan, numMuscles, numMuscles, numParams, segNumber, controlTime,
98  lowAmplitude, highAmplitude, lowPhase, highPhase,
99  tension, kPosition, kVelocity, def, cl, lf, hf);
100  OctaCLSine* const myControl =
101  new OctaCLSine(control_config, suffix, "bmirletz/OctaCL_sine/");
102  myModel->attach(myControl);
103 
104  simulation.addModel(myModel);
105 
106  int i = 0;
107  while (i < 40000)
108  {
109  simulation.run(60000);
110  simulation.reset();
111  i++;
112  }
113 
115 
119  #if (0)
120  delete myControl;
121  #endif
122  //Teardown is handled by delete, so that should be automatic
123  return 0;
124 }
Implementing the cross-linked octahedral complex spine inspired by Tom Flemons.
void addModel(tgModel *pModel)
int main(int argc, char **argv)
Controller for FlemonsSpineLearningModelCL.
Contains the definition of class tgSimulation.
Contains the definition of class tgModel.
Contains the definition of class tgSimViewGraphics.
Contains the definition of class tgWorld $Id$.
A controller for the template class BaseSpineModelLearning.
void run() const
Contains the definition of class tgSimView.
void attach(tgObserver< T > *pObserver)
Definition: tgSubject.h:91