NTRT Simulator  Version: Master
 All Classes Namespaces Files Functions Variables Typedefs Friends Pages
BaseQuadModelLearning.h
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 BASE_QUAD_MODEL_LEARNING_H
20 #define BASE_QUAD_MODEL_LEARNING_H
21 
31 #include "core/tgModel.h"
32 #include "core/tgSubject.h"
33 
34 #include <map>
35 #include <set>
36 #include <string>
37 #include <vector>
38 
39 class tgWorld;
40 class tgStructureInfo;
42 class tgBaseRigid;
43 class btVector3;
44 
49 class BaseQuadModelLearning: public tgSubject<BaseQuadModelLearning>,
50  public tgModel
51 {
52 public:
53 
54  typedef std::map<std::string, std::vector<tgSpringCableActuator*> > MuscleMap;
55 
56  virtual ~BaseQuadModelLearning();
57 
58  virtual void setup(tgWorld& world);
59 
60  virtual void teardown();
61 
62  virtual void step(double dt);
63 
64  virtual std::vector<double> getCOM(const int n);
65 
66  virtual std::vector<double> getSegmentCOM(const int n);
67 
68  virtual btVector3 getSegmentCOMVector(const int n);
69 
70  virtual const std::vector<tgSpringCableActuator*>& getMuscles(const std::string& key) const;
71 
72  virtual const std::vector<tgSpringCableActuator*>& getAllMuscles() const;
73 
74  virtual const std::vector<tgBaseRigid*> getAllRigids() const;
75 
76  virtual const int getSegments() const;
77 
78  virtual std::size_t getNumberofMuslces() const
79  {
80  return m_allMuscles.size();
81  }
82 
83  double getSpineLength();
84 
85 protected:
86 
87  BaseQuadModelLearning(int segments, int hips);
88 
89  std::vector<tgSpringCableActuator*> m_allMuscles;
90 
91  std::vector<tgModel*> m_allSegments;
92 
93  MuscleMap m_muscleMap;
94 
95  std::size_t m_subStructures;
96 
97  const std::size_t m_segments;
98 
99  const std::size_t m_hips;
100 
101  std::vector<double> segmentMasses;
102 };
103 
104 #endif // BASE_QUAD_MODEL_H
105 
virtual void setup(tgWorld &world)
Definition of tgSubject class.
virtual void step(double dt)
Contains the definition of class tgModel.