NTRT Simulator
 All Classes Files Functions Variables Typedefs Friends Pages
AppSUPERball.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 
26 // This application
27 #include "T6Model.h"
28 #include "T6TensionController.h"
29 #include "T6RestLengthController.h"
30 // 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 = 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 tgWorld::Config config =
62  {
63  // Note, by changing the setting below from 981 to 98.1, we've
64  // scaled the world length scale to decimeters not cm.
65 
66  // Gravity, in cm/sec^2. Use this to adjust length scale of world.
67  98.1
68  };
69  tgWorld world(config, ground);
70 
71  // Second create the view
72  const double timestep_physics = 0.0001; // Seconds
73  const double timestep_graphics = 1.f/60.f; // Seconds
74  tgSimViewGraphics view(world, timestep_physics, timestep_graphics);
75 
76  // Third create the simulation
77  tgSimulation simulation(view);
78 
79  // Fourth create the models with their controllers and add the models to the
80  // simulation
81  T6Model* const myModel = new T6Model();
82 
83  // Fifth, select the controller to use. Uncomment desired controller.
84 
85  // For the T6RestLengthController, pass in the amount of cable to contract
86  // in. This is the "rest length difference": the static offset of cable
87  // length between geometric length in equilibrium and the actual rest length
88  // of an individual cable.
89  // Note for the above scale of gravity, this is in decimeters.
91 
92  // For the T6TensionController,
93  // Set the tension of the controller units of kg * length / s^2
94  // So 10000 units at this scale is 1000 N
95 
96  // T6TensionController* const pTC = new T6TensionController(10000);
97 
98  myModel->attach(pTC);
99  simulation.addModel(myModel);
100 
101  // Run until the user stops
102  simulation.run();
103 
104  //Teardown is handled by delete, so that should be automatic
105  return 0;
106 }
Contains the definition of class T6Model. $Id$.
void addModel(tgModel *pModel)
Contains the definition of class tgSimulation $Id$.
Contains the definition of class tgModel. $Id$.
Contains the definition of class tgSimViewGraphics $Id$.
int main(int argc, char **argv)
Contains the definition of class T6RestLengthController.
Contains the definition of class tgWorld $Id$.
void run() const
Contains the definition of class tgBoxGround.
Contains the definition of class T6TensionController.
void attach(tgObserver< T > *pObserver)
Definition: tgSubject.h:90