NTRT Simulator  v1.1
 All Classes Namespaces Files Functions Variables Typedefs Friends Pages
T12SuperBallPayload.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 SUPERBALL_MODEL_H
20 #define SUPERBALL_MODEL_H
21 
28 // This library
29 #include "core/tgModel.h"
30 #include "core/tgSubject.h"
31 #include "core/tgRod.h"
32 // The C++ Standard Library
33 #include <vector>
34 
35 // Forward declarations
36 class tgBasicActuator;
37 class tgModelVisitor;
38 class tgStructure;
39 class tgWorld;
40 
44 class T12SuperBallPayload : public tgSubject<T12SuperBallPayload>, public tgModel
45 {
46 public:
47 
54 
59  virtual ~T12SuperBallPayload();
60 
69  virtual void setup(tgWorld& world);
70 
75  void teardown();
76 
81  virtual void step(double dt);
82 
90  virtual void onVisit(tgModelVisitor& r);
91 
96  const std::vector<tgBasicActuator*>& getAllMuscles() const;
97 
98 private:
99 
106  void addNodes(tgStructure& s);
107 
113  static void addRods(tgStructure& s);
114 
120  void addMuscles(tgStructure& s);
121 
122  /*
123  * Adds the 12 markers to the end of the rods so that we can visualize
124  * them and track their position
125  */
126  void addMarkers(tgStructure& s);
127 
128  /*
129  * Moves all the rods (that are actually all the rigid bodies) according to the arguments.
130  * First rotates the structure around 3 axises given 3 angles.
131  * Moves the structure to the target point.
132  * Sets all the bars speed to the given speed vector.
133  * (muscles and markers are moved automatically since they are attached).
134  */
135  void moveModel(btVector3 targetPositionVector,btVector3 rotationVector,btVector3 speedVector);
136 
137 private:
138 
143  std::vector<tgBasicActuator*> allMuscles;
144  std::vector<std::vector <tgBasicActuator *> > musclesPerNodes;
145  std::vector<std::vector<std::vector<int> > > nodeNumberingSchema;
146 
147  std::vector<btVector3> nodePositions;
148 };
149 
150 #endif // SUPERBALL_MODEL_H
Definition of tgSubject class.
Contains the definition of class tgModel.
virtual void onVisit(tgModelVisitor &r)
virtual void step(double dt)
virtual void setup(tgWorld &world)
const std::vector< tgBasicActuator * > & getAllMuscles() const
Contains the definition of class tgRod.