NTRT Simulator  Version: Master
 All Classes Namespaces Files Functions Variables Typedefs Friends Pages
AppBigPuppy.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 "BigPuppy.h"
30 
31 // Obstacles
34 
35 // This library
38 #include "core/tgModel.h"
39 #include "core/tgSimViewGraphics.h"
40 #include "core/tgSimulation.h"
41 #include "core/tgWorld.h"
42 // Bullet Physics
43 #include "LinearMath/btVector3.h"
44 // The C++ Standard Library
45 #include <iostream>
46 
54 int main(int argc, char** argv)
55 {
56  std::cout << "AppBigPuppy" << std::endl;
57 
58  // First create the ground and world. Specify ground rotation in radians
59 
60 #ifdef SMALL_HILLS
61  btVector3 eulerAngles = btVector3(0.0, 0.0, 0.0);
62  btScalar friction = 0.5;
63  btScalar restitution = 0.0;
64  // Size doesn't affect hilly terrain
65  btVector3 size = btVector3(0.0, 0.1, 0.0);
66  btVector3 origin = btVector3(0.0, 0.0, 0.0);
67  size_t nx = 100;
68  size_t ny = 100;
69  double margin = 0.5;
70  double triangleSize = 4.0;
71  double waveHeight = 2.0;
72  double offset = 0.0;
73  const tgHillyGround::Config hillyGroundConfig(eulerAngles, friction, restitution,
74  size, origin, nx, ny, margin, triangleSize,
75  waveHeight, offset);
76 
77  tgHillyGround* ground = new tgHillyGround(hillyGroundConfig);
78 #endif
79 
80 #ifdef LARGE_HILLS
81  btVector3 eulerAngles = btVector3(0.0, 0.0, 0.0);
82  btScalar friction = 0.5;
83  btScalar restitution = 0.0;
84  // Size doesn't affect hilly terrain
85  btVector3 size = btVector3(0.0, 0.1, 0.0);
86  btVector3 origin = btVector3(0.0, 0.0, 0.0);
87  size_t nx = 300;
88  size_t ny = 300;
89  double margin = 0.5;
90  double triangleSize = 4.0;
91  double waveHeight = 6.0;
92  double offset = 0.0;
93  const tgHillyGround::Config hillyGroundConfig(eulerAngles, friction, restitution,
94  size, origin, nx, ny, margin, triangleSize,
95  waveHeight, offset);
96 
97  tgHillyGround* ground = new tgHillyGround(hillyGroundConfig);
98 #endif
99 
100 #ifdef BLOCKY_GROUND
101  btVector3 origin = btVector3(0.0, 0.0, 0.0);
102  btScalar friction = 0.5;
103  btScalar restitution = 0.0;
104  btVector3 minPos = btVector3(-500.0, 0.0, -500.0);
105  btVector3 maxPos = btVector3(500.0, 0.0, 500.0);
106  size_t nBlocks = 500;
107  double blockLength = 20.0;
108  double blockWidth = 20.0;
109  double blockHeight = 20.0;
110 
111  tgBlockField::Config blockyGroundConfig(origin,friction,restitution,
112  minPos,maxPos,nBlocks,blockLength,
113  blockWidth,blockHeight);
114 
115  tgBlockField* myObstacle = new tgBlockField(blockyGroundConfig);
116 
117 #endif
118 
119 #ifdef STAIRS
120  btVector3 origin = btVector3(-30.0, 10.0, -40.0);
121  btScalar friction = 0.5;
122  btScalar restitution = 0.0;
123  size_t nStairs = 1;
124  double stairWidth = 80.0;
125  double stepWidth = 20.0;
126  double stepHeight = 10.0;
127  double angle = 0.0;
128 
129  tgStairs::Config stairsConfig(origin,friction,restitution,nStairs,stairWidth,stepWidth,stepHeight,angle);
130 
131  tgStairs* myStairs = new tgStairs(stairsConfig);
132 #endif
133 
134 #ifdef FLAT_GROUND
135  const double yaw = 0.0;
136  const double pitch = 0.0;
137  const double roll = 0.0;
138  const tgBoxGround::Config groundConfig(btVector3(yaw, pitch, roll));
139  // the world will delete this
140  tgBoxGround* ground = new tgBoxGround(groundConfig);
141 
142 #endif
143 
144  const tgWorld::Config config(981); // gravity, cm/sec^2 981
145  tgWorld world(config, ground);
146 
147  // Second create the view
148  const double timestep_physics = 0.001; // seconds
149  const double timestep_graphics = 1.f/60.f; // seconds
150  tgSimViewGraphics view(world, timestep_physics, timestep_graphics);
151 
152  // Third create the simulation
153  tgSimulation simulation(view);
154 
155  BigPuppy* const myModel = new BigPuppy();
156 
157  // Add the model to the world
158  simulation.addModel(myModel);
159 
160 #ifdef BLOCKY_GROUND
161  simulation.addModel(myObstacle);
162 #endif
163 
164 #ifdef STAIRS
165  simulation.addModel(myStairs);
166 #endif
167  simulation.run();
168 
169 
170 
171  //Teardown is handled by delete, so that should be automatic
172  return 0;
173 }
int main(int argc, char **argv)
Contains the definition of class tgHillyGround.
Contains the definition of class tgStairs. A random field of blocks used to test tensegrities.
Contains the definition of class tgSimulation.
Contains the definition of class tgModel.
Contains the definition of class tgSimViewGraphics.
Contains the definition of class tgBlockField. A random field of blocks used to test tensegrities...
Contains the definition of class tgWorld $Id$.
Contains the definition of class tgBoxGround.