NTRT Simulator  v1.1
 All Classes Namespaces Files Functions Variables Typedefs Friends Pages
SpineFeedbackControl.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 SPINE_FEEDBACK_CONTROL_H
20 #define SPINE_FEEDBACK_CONTROL_H
21 
31 
34 
36 
46 {
47 public:
48 
50  {
51  public:
55  Config( int ss,
56  int tm,
57  int om,
58  int param,
59  int segnum = 6,
60  double ct = 0.1,
61  double la = 0,
62  double ha = 30,
63  double lp = -1 * M_PI,
64  double hp = M_PI,
65  double kt = 0.0,
66  double kp = 1000.0,
67  double kv = 100.0,
68  bool def = true,
69  double cl = 10.0,
70  double lf = 0.0,
71  double hf = 30.0,
72  double ffMin = 0.0,
73  double ffMax = 0.0,
74  double afMin = 0.0,
75  double afMax = 0.0,
76  double pfMin = 0.0,
77  double pfMax = 0.0);
78 
79  const double freqFeedbackMin;
80  const double freqFeedbackMax;
81  const double ampFeedbackMin;
82  const double ampFeedbackMax;
83  const double phaseFeedbackMin;
84  const double phaseFeedbackMax;
85 
86  };
87 
89  std::string args,
90  std::string resourcePath = "",
91  std::string ec = "edgeConfig.ini",
92  std::string nc = "nodeConfig.ini",
93  std::string fc = "feedbackConfig.ini");
94 
95  virtual ~SpineFeedbackControl() {}
96 
97  virtual void onSetup(BaseSpineModelLearning& subject);
98 
99  virtual void onStep(BaseSpineModelLearning& subject, double dt);
100 
101  virtual void onTeardown(BaseSpineModelLearning& subject);
102 
103 protected:
104 
105  virtual void setupCPGs(BaseSpineModelLearning& subject, array_2D nodeActions, array_4D edgeActions);
106 
107  virtual array_2D scaleNodeActions (std::vector< std::vector <double> > actions);
108 
109  std::vector<double> getFeedback(BaseSpineModelLearning& subject);
110 
111  std::vector<double> getCableState(const tgSpringCableActuator& cable);
112 
113  std::vector<double> transformFeedbackActions(std::vector< std::vector<double> >& actions);
114 
116 
117  std::string feedbackConfigFilename;
118 
119  NeuroEvolution feedbackEvolution;
120  NeuroAdapter feedbackAdapter;
121 
122  bool feedbackLearning;
123 
124  configuration feedbackConfigData;
125 };
126 
127 #endif // SPINE_FEEDBACK_CONTROL_H
Config(int ss, int tm, int om, int param, int segnum=6, double ct=0.1, double la=0, double ha=30, double lp=-1 *M_PI, double hp=M_PI, double kt=0.0, double kp=1000.0, double kv=100.0, bool def=true, double cl=10.0, double lf=0.0, double hf=30.0, double ffMin=0.0, double ffMax=0.0, double afMin=0.0, double afMax=0.0, double pfMin=0.0, double pfMax=0.0)
virtual void onStep(BaseSpineModelLearning &subject, double dt)
SpineFeedbackControl(SpineFeedbackControl::Config config, std::string args, std::string resourcePath="", std::string ec="edgeConfig.ini", std::string nc="nodeConfig.ini", std::string fc="feedbackConfig.ini")
Defines a class NeuroAdapter to pass parameters from NeuroEvolution to a controller.
A controller for the template class BaseSpineModelLearning.
Top level class for NeuroEvolution.
virtual void onSetup(BaseSpineModelLearning &subject)
virtual void onTeardown(BaseSpineModelLearning &subject)