NTRT Simulator  Version: Master
 All Classes Namespaces Files Functions Variables Typedefs Friends Pages
AppTetraSpineCol.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 
28 // This application
29 #include "TetraSpineCollisions.h"
30 #include "colSpineSine.h"
31 
32 // 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"
40 #include "models/obstacles/tgWall.h"
41 // obstacles
43 // The C++ Standard Library
44 #include <iostream>
45 
53 int main(int argc, char** argv)
54 {
55  std::cout << "AppTetraSpineHT" << std::endl;
56 
57  // First create the world
58  const double scale = 100;
59  const tgWorld::Config config(9.81 * scale); // gravity, cm/sec^2
60 
61  ;
62 #if (1)
63  btVector3 eulerAngles = btVector3(M_PI/4.0, 0.0, 0.0);
64  btScalar friction = 0.5;
65  btScalar restitution = 0.1;
66  btVector3 size = btVector3(500.0, 1.5, 500.0);
67  btVector3 origin = btVector3(0.0, 0.0, 0.0);
68  const size_t nx = 100;
69  const size_t ny = 100;
70  const double triangleSize = 15.0;
71  const double waveHeight = 5.0;
72  const double offset = 0.0;
73  const double margin = 1.0;
74  tgHillyGround::Config groundConfig(eulerAngles, friction, restitution,
75  size, origin, nx, ny, margin, triangleSize,
76  waveHeight, offset);
77 
78  tgHillyGround* ground = new tgHillyGround(groundConfig);
79 
80  tgWorld world(config, ground);
81 #else
82  tgWorld world(config);
83 #endif
84  // Second create the view
85  const double stepSize = 1.0/1000.0; // Seconds
86  const double renderRate = 1.0/60.0; // Seconds
87  tgSimViewGraphics view(world, stepSize, renderRate);
88 
89  // Third create the simulation
90  tgSimulation simulation(view);
91 
92  // Fourth create the models with their controllers and add the models to the
93  // simulation
94  const int segments = 12;
95  TetraSpineCollisions* myModel =
96  new TetraSpineCollisions(segments, scale /2.0);
97 
98  colSpineSine* const myControl =
99  new colSpineSine("controlVars.json", "tetraTerrain/");
100 
101  myModel->attach(myControl);
102  /*
103  tgCPGLogger* const myLogger =
104  new tgCPGLogger("logs/CPGValues.txt");
105 
106  myControl->attach(myLogger);
107  */
108 
109  // Add obstacles
110  btVector3 wallOrigin(0.0, 0.0, 50.0);
111  Wall* myWall = new Wall(wallOrigin);
112 
113  tgBlockField* myObstacle = new tgBlockField();
114 
115  simulation.addModel(myModel);
116  //simulation.addModel(myObstacle);
117 
118  int i = 0;
119  while (i < 1)
120  {
121  simulation.run(240000);
122  //simulation.reset();
123  i++;
124  }
125 
127 
131  #if (0)
132  delete myControl;
133  #endif
134  //Teardown is handled by delete, so that should be automatic
135  return 0;
136 }
int main(int argc, char **argv)
Contains the definition of class tgHillyGround.
void addModel(tgModel *pModel)
Contains the definition of class tgSimulation.
Contains the definition of class tgModel.
Contains the definition of class tgSimViewGraphics.
Definition: tgWall.h:45
Contains the definition of class tgBlockField. A random field of blocks used to test tensegrities...
Contains the definition of class tgWorld $Id$.
Controller for TetraSpineCollisions.
Middle segment of In Won's robot reconfigured with tgBulletContactSpringCable and more segments...
void run() const
Contains the definition of class tgSimView.
Contains the definition of interface class tgCPGLogger.
void attach(tgObserver< T > *pObserver)
Definition: tgSubject.h:91