NTRT Simulator  v1.1
 All Classes Namespaces Files Functions Variables Typedefs Friends Pages
tgBulletContactSpringCable.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 #ifndef SRC_CORE_TG_BULLET_CONTACT_SPRING_CABLE_H_
20 #define SRC_CORE_TG_BULLET_CONTACT_SPRING_CABLE_H_
21 
30 // NTRT
32 // The Bullet Physics library
33 #include "LinearMath/btScalar.h"
34 #include "LinearMath/btVector3.h"
35 // The C++ Standard Library
36 
37 #include <vector>
38 
39 // Forward references
40 class tgWorld;
42 class btRigidBody;
43 class btCollisionShape;
44 class btCompoundShape;
45 class btPairCachingGhostObject;
46 class btDynamicsWorld;
47 
61 {
62 public:
63 
83  tgBulletContactSpringCable(btPairCachingGhostObject* ghostObject,
84  tgWorld& world,
85  const std::vector<tgBulletSpringCableAnchor*>& anchors,
86  double coefK,
87  double dampingCoefficient,
88  double pretension = 0.0,
89  double thickness = 0.001,
90  double resolution = 0.1);
97 
108  virtual void step(double dt);
109 
114  virtual const btScalar getActualLength() const;
115 
116 private:
117 
122  struct anchorCompare
123  {
124  anchorCompare(const tgBulletSpringCableAnchor* m1, const tgBulletSpringCableAnchor* m2);
125 
129  bool operator() (const tgBulletSpringCableAnchor* lhs, const tgBulletSpringCableAnchor* rhs) const;
130 
135  bool comparePoints(btVector3& pt2, btVector3& pt3) const;
136 
137  private:
138  const tgBulletSpringCableAnchor* const ma1;
139  const tgBulletSpringCableAnchor* const ma2;
140  };
141 
147  virtual void calculateAndApplyForce(double dt);
148 
155  void updateManifolds();
156 
163  void updateAnchorList();
164 
171  int updateAnchorPositions();
172 
179  void pruneAnchors();
180 
186  void updateCollisionObject();
187 
192  void deleteCollisionShape(btCollisionShape* pShape);
193 
199  void clearCompoundShape(btCompoundShape* pShape);
200 
207  bool deleteAnchor(int i);
208 
219  int findNearestPastAnchor(btVector3& pos);
220 
225  std::vector<tgBulletSpringCableAnchor*>::iterator m_anchorIt;
226 
231  std::vector<tgBulletSpringCableAnchor*> m_newAnchors;
232 
238  tgWorld& m_world;
239 
240 protected:
241 
247  btPairCachingGhostObject* m_ghostObject;
248 
253  const double m_thickness;
254 
259  const double m_resolution;
260 
261 private:
262  bool invariant() const;
263 };
264 
265 #endif // SRC_CORE_TG_BULLET_CONTACT_SPRING_CABLE_H_
tgBulletContactSpringCable(btPairCachingGhostObject *ghostObject, tgWorld &world, const std::vector< tgBulletSpringCableAnchor * > &anchors, double coefK, double dampingCoefficient, double pretension=0.0, double thickness=0.001, double resolution=0.1)
virtual const btScalar getActualLength() const
btPairCachingGhostObject * m_ghostObject
Definitions of classes tgBulletSpringCable $Id$.