NTRT Simulator  v1.1
 All Classes Namespaces Files Functions Variables Typedefs Friends Pages
SerializedSpineControl.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 SERIALIZED_SPINE_CONTROL
20 #define SERIALIZED_SPINE_CONTROL
21 
30 // NTRTSim
31 #include "core/tgObserver.h"
32 #include "sensors/tgDataObserver.h"
33 
34 // The C++ Standard Library
35 #include <vector>
36 #include <string>
37 
38 // Forward Declarations
42 
47 class SerializedSpineControl : public tgObserver<BaseSpineModelLearning>
48 {
49 public:
50 
51 struct Config
52 {
53  Config(std::string fileName);
54 
55  ~Config();
56 
61  tgImpedanceController* out_controller;
62  tgImpedanceController* top_controller;
63 
67  double rod_edge;
68  double rod_front;
69  double rod_offset;
70 
71 
76  std::vector<double> insideTopLength;
77  std::vector<double> insideLeftLength;
78  std::vector<double> insideRightLength;
79  std::vector<double> outsideTopLength;
80  std::vector<double> outsideLeftLength;
81  std::vector<double> outsideRightLength;
82 
87  std::vector<double> insideTopTens;
88  std::vector<double> insideLeftTens;
89  std::vector<double> insideRightTens;
90  std::vector<double> outsideTopTens;
91  std::vector<double> outsideLeftTens;
92  std::vector<double> outsideRightTens;
93 
97  double offsetSpeed;
98  double cpgAmplitude;
99  double cpgFrequency;
100  double bodyWaves;
101 
105  double insideMod;
106 
111  std::vector<double> phaseOffsets;
112 
117 
118 };
119 
120 public:
121 
127  SerializedSpineControl(std::string fileName);
128 
133 
134 
135 
136  virtual void onSetup(BaseSpineModelLearning& subject);
137 
145  virtual void onStep(BaseSpineModelLearning& subject, double dt);
146 
147 private:
148 
152  void applyImpedanceControlGeneric(tgImpedanceController* controller,
153  const std::vector<tgSpringCableActuator*> stringList,
154  const std::vector<double> stringLengths,
155  const std::vector<double> tensions,
156  double dt,
157  std::size_t phase);
158 
159  Config m_config;
160 
161  std::size_t segments;
162 
163  tgDataObserver m_dataObserver;
164 
170  double simTime;
171  double updateTime;
172  double cycle;
173  double target;
174 };
175 
176 #endif // MY_MODEL_CONTROLLER_H
Definition of tgObserver class.
tgImpedanceController * in_controller
virtual void onStep(BaseSpineModelLearning &subject, double dt)
SerializedSpineControl(std::string fileName)
Definition of tgObserver class.
virtual void onSetup(BaseSpineModelLearning &subject)