NTRT Simulator  Version: Master
 All Classes Namespaces Files Functions Variables Typedefs Friends Pages
DuCTTTestModel.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 NESTED_STRUCTURE_TEST_MODEL_H
20 #define NESTED_STRUCTURE_TEST_MODEL_H
21 
29 // This library
30 #include "tgPrismaticInfo.h"
31 
32 #include "core/tgModel.h"
33 #include "core/tgSubject.h"
34 #include "core/tgCast.h"
35 #include "core/tgString.h"
37 #include "tgcreator/tgBuildSpec.h"
40 #include "tgcreator/tgRodInfo.h"
41 #include "tgcreator/tgStructure.h"
43 #include "tgcreator/tgUtil.h"
44 // The Bullet Physics library
45 #include "btBulletDynamicsCommon.h"
46 // The C++ Standard Library
47 #include <iostream>
48 #include <stdexcept>
49 // The C++ Standard Library
50 #include <map>
51 #include <set>
52 #include <string>
53 #include <vector>
54 
55 // Forward declarations
57 
63 class DuCTTTestModel: public tgSubject<DuCTTTestModel>, public tgModel
64 {
65 public:
66 
70  typedef std::map<std::string, std::vector<tgSpringCableActuator*> > MuscleMap;
71 
78  DuCTTTestModel(size_t segments);
79 
83  virtual ~DuCTTTestModel()
84  {}
85 
94  virtual void setup(tgWorld& world);
95 
100  virtual void step(const double dt);
101 
109  const std::vector<tgSpringCableActuator*>& getMuscles (const std::string& key) const;
110 
116  size_t getSegments() const
117  {
118  return m_segments;
119  }
120 
121 private:
122 
123  void addNodes(tgStructure& tetra, double edge, double height);
124  void addPairs(tgStructure& tetra);
125  void addTopPairs(tgStructure& tetra);
126  void addBottomPairs(tgStructure& tetra);
127  void addSegments(tgStructure& snake, const tgStructure& tetra, double edge,
128  size_t segmentCount);
129  // Add muscles that connect the segments;
130  void addMuscles(tgStructure& snake);
131  void mapMuscles(MuscleMap& muscleMap, tgModel& model);
132  void trace(const tgStructureInfo& structureInfo, tgModel& model);
133 
138  std::vector<tgSpringCableActuator*> allMuscles;
139 
144  MuscleMap muscleMap;
145 
149  const size_t m_segments;
150 };
151 
152 #endif
virtual ~DuCTTTestModel()
Definition of class tgRodInfo.
DuCTTTestModel(size_t segments)
virtual void step(const double dt)
Definition of tgSubject class.
Convenience function for combining strings with ints, mostly for naming structures.
size_t getSegments() const
Utility class for class casting and filtering collections by type.
const std::vector< tgSpringCableActuator * > & getMuscles(const std::string &key) const
Definition of class tgBasicActuatorInfo.
Contains the definition of class tgModel.
Contains the definition of abstract base class tgSpringCableActuator. Assumes that the string is line...
std::map< std::string, std::vector< tgSpringCableActuator * > > MuscleMap
Definition of class tgStructure.
Definition of class tgStructureInfo.
virtual void setup(tgWorld &world)
Rand seeding simular to the evolution and terrain classes.
Definition of class tgBuildSpec.
Contains the definition of class tgPrismaticInfo. A prismatic actuator builder.
Definition of class tgRigidAutoCompound.