NTRT Simulator  v1.1
 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 #include "Wall.h"
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 // The C++ Standard Library
41 #include <iostream>
42 
50 int main(int argc, char** argv)
51 {
52  std::cout << "AppTetraSpineHT" << std::endl;
53 
54  // First create the world
55  const tgWorld::Config config(981); // gravity, cm/sec^2
56 
57  ;
58 #if (1)
59  btVector3 eulerAngles = btVector3(0.0, 0.0, 0.0);
60  btScalar friction = 0.5;
61  btScalar restitution = 0.0;
62  btVector3 size = btVector3(500.0, 1.5, 500.0);
63  btVector3 origin = btVector3(0.0, 0.0, 0.0);
64  size_t nx = 50;
65  size_t ny = 50;
66  double margin = 0.2;
67  double triangleSize = 12;
68  double waveHeight = 5.0;
69  double offset = 0.0;
70  tgHillyGround::Config groundConfig(eulerAngles, friction, restitution,
71  size, origin, nx, ny, margin, triangleSize,
72  waveHeight, offset);
73 
74  tgHillyGround* ground = new tgHillyGround(groundConfig);
75 
76  tgWorld world(config, ground);
77 #else
78  tgWorld world(config);
79 #endif
80  // Second create the view
81  const double stepSize = 1.0/500.0; // Seconds
82  const double renderRate = 1.0/60.0; // Seconds
83  tgSimViewGraphics view(world, stepSize, renderRate);
84 
85  // Third create the simulation
86  tgSimulation simulation(view);
87 
88  // Fourth create the models with their controllers and add the models to the
89  // simulation
90  const int segments = 6;
91  TetraSpineCollisions* myModel =
92  new TetraSpineCollisions(segments);
93 
94  colSpineSine* const myControl =
95  new colSpineSine();
96 
97  myModel->attach(myControl);
98  /*
99  tgCPGLogger* const myLogger =
100  new tgCPGLogger("logs/CPGValues.txt");
101 
102  myControl->attach(myLogger);
103  */
104 
105  // Add obstacles
106  btVector3 wallOrigin(0.0, 0.0, 50.0);
107  Wall* myWall = new Wall(wallOrigin);
108 
109  simulation.addModel(myModel);
110  simulation.addModel(myWall);
111 
112  int i = 0;
113  while (i < 1)
114  {
115  simulation.run(240000);
116  //simulation.reset();
117  i++;
118  }
119 
121 
125  #if (0)
126  delete myControl;
127  #endif
128  //Teardown is handled by delete, so that should be automatic
129  return 0;
130 }
int main(int argc, char **argv)
Contains the definition of class tgHillyGround.
void addModel(tgModel *pModel)
Contains the definition of class Wall. Specifically, a crater is defined as a series of boxes which f...
Contains the definition of class tgSimulation.
Contains the definition of class tgModel.
Contains the definition of class tgSimViewGraphics.
Definition: Wall.h:47
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