NTRT Simulator  Version: Master
 All Classes Namespaces Files Functions Variables Typedefs Friends Pages
AppSUPERball.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 
26 // This application
27 #include "SuperBallModel.h"
28 #include "SuperBallLearningController.h"
29 // This library
32 #include "core/tgModel.h"
33 #include "core/tgSimViewGraphics.h"
34 #include "core/tgSimulation.h"
35 #include "core/tgWorld.h"
36 // Bullet Physics
37 #include "LinearMath/btVector3.h"
38 // The C++ Standard Library
39 #include <iostream>
40 
47 int main(int argc, char** argv)
48 {
49  std::cout << "AppSUPERball" << std::endl;
50 
51  // First create the ground and world
52 
53  // Determine the angle of the ground in radians. All 0 is flat
54  const double yaw = 0.0;
55  const double pitch = 0.0;//M_PI/15.0;
56  const double roll = 0.0;
57 // const tgBoxGround::Config groundConfig(btVector3(yaw, pitch, roll));
58 // // the world will delete this
59 // tgBoxGround* ground = new tgBoxGround(groundConfig);
60 
61  const tgPlaneGround::Config groundConfig(btVector3(0.0,1.0,0.0));
62  // the world will delete this
63  tgPlaneGround* ground = new tgPlaneGround(groundConfig);
64 
65 
66  const tgWorld::Config config(98.1); // gravity, cm/sec^2 Use this to adjust length scale of world.
67  // Note, by changing the setting below from 981 to 98.1, we've
68  // scaled the world length scale to decimeters not cm.
69  tgWorld world(config, ground);
70 
71  // Second create the view
72  const double timestep_physics = 1.0 / 60.0 / 10.0; // Seconds
73  const double timestep_graphics = 1.f /60.f; // Seconds
74 
75 // tgSimViewGraphics view(world, timestep_physics, timestep_graphics);
76  tgSimView view(world, timestep_physics, timestep_graphics);
77 
78  // Third create the simulation
79  tgSimulation simulation(view);
80 
81  // Fourth create the models with their controllers and add the models to the
82  // simulation
83  SuperBallModel* const myModel = new SuperBallModel(world);
84 
85  // Fifth, select the controller to use. Uncomment desired controller.
86 
87  // For the T6RestLengthController, pass in the amount of cable to contract
88  // in. This is the "rest length difference": the static offset of cable
89  // length between geometric length in equilibrium and the actual rest length
90  // of an individual cable.
91  // Note for the above scale of gravity, this is in decimeters.
92 
93 
95 
96 
97  // For the T6TensionController,
98  // Set the tension of the controller units of kg * length / s^2
99  // So 10000 units at this scale is 1000 N
100 
101  // T6TensionController* const pTC = new T6TensionController(10000);
102 
103  myModel->attach(pTC);
104  simulation.addModel(myModel);
105 
106  // Run for 60 secs
107  int simLength=60/timestep_physics;
108  int i = 0;
109  while (i < 10000)
110  {
111  simulation.run(simLength);
112  simulation.reset();
113  i++;
114  }
115 
116  //Teardown is handled by delete, so that should be automatic
117  return 0;
118 }
int main(int argc, char **argv)
Contains the definition of class tgPlaneGround.
Contains the definition of class SuperBallModel. $Id$.
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$.
Contains the definition of class tgBoxGround.
void attach(tgObserver< T > *pObserver)
Definition: tgSubject.h:91