NTRT Simulator  v1.1
 All Classes Namespaces Files Functions Variables Typedefs Friends Pages
CordeModel.h
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 
19 //#define BT_USE_DOUBLE_PRECISION
20 
21 #ifndef CORDE_MODEL
22 #define CORDE_MODEL
23 
31 // Bullet Linear Algebra
32 #include "LinearMath/btScalar.h"
33 #include "LinearMath/btVector3.h"
34 #include "LinearMath/btQuaternion.h"
35 
36 // The C++ Standard Library
37 #include <vector>
38 
40 {
41 public:
42  struct Config
43  {
44  Config(const std::size_t res,
45  const double r, const double d,
46  const double ym, const double shm,
47  const double stm, const double csc,
48  const double gt, const double gr);
49 
50  const std::size_t resolution;
51  const double radius;
52  const double density;
53  const double YoungMod;
54  const double ShearMod;
55  const double StretchMod;
56  const double ConsSpringConst;
61  const double gammaT;
62  const double gammaR;
63  };
64 
75  CordeModel(btVector3 pos1, btVector3 pos2, btQuaternion quat1, btQuaternion quat2, CordeModel::Config& Config);
76 
77  ~CordeModel();
78 
79  void step (btScalar dt);
80 
81 private:
82  void computeConstants();
83 
84  void stepPrerequisites();
85 
86  void computeInternalForces();
87 
88  void unconstrainedMotion(double dt);
89 
93  struct CordePositionElement
94  {
99  CordePositionElement(btVector3 p1, double m);
100 
101  btVector3 pos;
102  btVector3 vel;
103  btVector3 force;
104  double mass;
105  };
106 
110  struct CordeQuaternionElement
111  {
115  CordeQuaternionElement(btQuaternion q1);
116 
117  void transposeTorques();
121  void updateQDot();
122 
123  btQuaternion q;
124  btQuaternion qdot;
128  btQuaternion tprime;
129  btVector3 torques;
130  btVector3 omega;
131  };
132 
133  CordeModel::Config m_config;
134 
135  std::vector<CordePositionElement*> m_massPoints;
136  std::vector<CordeQuaternionElement*> m_centerlines;
140  std::vector<double> linkLengths;
144  std::vector<double> quaternionShapes;
145 
152  std::vector<double> computedStiffness;
153 
158  btVector3 computedInertia;
159  btVector3 inverseInertia;
160 
161  bool invariant();
162 
163  double simTime;
164 };
165 
166 
167 #endif // CORDE_MODEL
const double gammaT
Definition: CordeModel.h:61
CordeModel(btVector3 pos1, btVector3 pos2, btQuaternion quat1, btQuaternion quat2, CordeModel::Config &Config)
Definition: CordeModel.cpp:84