NTRT Simulator  v1.1
 All Classes Namespaces Files Functions Variables Typedefs Friends Pages
AppCordeTest.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 
27 // This application
28 #include "CordeModel.h"
29 // This library
30 #include "core/tgModel.h"
31 #include "core/tgSimViewGraphics.h"
32 #include "core/tgSimulation.h"
33 #include "core/tgWorld.h"
34 #include "tgcreator/tgUtil.h"
35 // The Bullet Physics Library
36 #include "LinearMath/btVector3.h"
37 #include "LinearMath/btQuaternion.h"
38 // The C++ Standard Library
39 #include <iostream>
40 
47 int main(int argc, char** argv)
48 {
49 
50 #if (1) // X Pos
51  btVector3 startPos(0.0, 0.0, 0.0);
52  btVector3 endPos (10.0, 0.0, 0.0);
53 
54  // Setup for neither bending nor rotation
55  btQuaternion startRot( 0, sqrt(2)/2.0, 0, sqrt(2)/2.0);
56  btQuaternion endRot = startRot;
57 #else
58  btVector3 startPos(0.0, 0.0, 0.0);
59  btVector3 endPos (0.0, 0.0, 10.0);
60 
61  // Setup for neither bending nor rotation
62  btQuaternion startRot( 0, 0, 0, 1);
63  btQuaternion endRot = startRot;
64 #endif
65  // Values for Rope from Spillman's paper
66  const std::size_t resolution = 10;
67  const double radius = 0.01;
68  const double density = 1300;
69  const double youngMod = 0.5;
70  const double shearMod = 0.5;
71  const double stretchMod = 20.0;
72  const double springConst = 100.0 * pow(10, 3);
73  const double gammaT = 10.0 * pow(10, -6);
74  const double gammaR = 1.0 * pow(10, -6);
75  CordeModel::Config config(resolution, radius, density, youngMod, shearMod,
76  stretchMod, springConst, gammaT, gammaR);
77 
78  CordeModel testString(startPos, endPos, startRot, endRot, config);
79 
80  double t = 0.0;
81  double dt = 0.0001;
82  for (int i = 0; i < 10000; i++)
83  {
84  testString.step(dt);
85  t += dt;
86  }
87  #ifdef BT_USE_DOUBLE_PRECISION
88  std::cout << "Double precision" << std::endl;
89  #else
90  std::cout << "Single Precision" << std::endl;
91  #endif
92 
93  return 0;
94 }
int main(int argc, char **argv)
Defines structure for the Corde softbody String Model.
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 tgUtil and overloaded operator<<() free functions.