NTRT Simulator  Version: Master
 All Classes Namespaces Files Functions Variables Typedefs Friends Pages
SpineGoalControl.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_GOAL_CONTROL_H
20 #define SPINE_GOAL_CONTROL_H
21 
31 
35 
36 #include "LinearMath/btVector3.h"
37 
39 class BaseSpineModelGoal;
40 
50 {
51 public:
52 
54  {
55  public:
59  Config( int ss,
60  int tm,
61  int om,
62  int param,
63  int segnum = 6,
64  double ct = 0.1,
65  double la = 0,
66  double ha = 30,
67  double lp = -1 * M_PI,
68  double hp = M_PI,
69  double kt = 0.0,
70  double kp = 1000.0,
71  double kv = 100.0,
72  bool def = true,
73  double cl = 10.0,
74  double lf = 0.0,
75  double hf = 30.0,
76  double ffMin = 0.0,
77  double ffMax = 0.0,
78  double afMin = 0.0,
79  double afMax = 0.0,
80  double pfMin = 0.0,
81  double pfMax = 0.0,
82  double tf = 0.0
83  );
84 
85  const double freqFeedbackMin;
86  const double freqFeedbackMax;
87  const double ampFeedbackMin;
88  const double ampFeedbackMax;
89  const double phaseFeedbackMin;
90  const double phaseFeedbackMax;
91 
92  const double tensFeedback;
93 
94  };
95 
97  std::string args,
98  std::string resourcePath = "",
99  std::string ec = "edgeConfig.ini",
100  std::string nc = "nodeConfig.ini",
101  std::string fc = "feedbackConfig.ini",
102  std::string gc = "goalConfig.ini");
103 
104  virtual ~SpineGoalControl() {}
105 
106  virtual void onSetup(BaseSpineModelLearning& subject);
107 
108  virtual void onStep(BaseSpineModelLearning& subject, double dt);
109 
110  virtual void onTeardown(BaseSpineModelLearning& subject);
111 
112 protected:
113 
114  virtual void setupCPGs(BaseSpineModelLearning& subject, array_2D nodeActions, array_4D edgeActions);
115 
116  virtual array_2D scaleNodeActions (std::vector< std::vector <double> > actions);
117 
118  std::vector<double> getFeedback(BaseSpineModelLearning& subject);
119 
120  std::vector<double> getGoalFeedback(const BaseSpineModelGoal* subject);
121 
122  void setGoalTensions(const BaseSpineModelGoal* subject, btVector3& desiredHeading);
123 
124  std::vector<double> getCableState(const tgSpringCableActuator& cable);
125 
126  std::vector<double> transformFeedbackActions(std::vector< std::vector<double> >& actions, configuration& configData);
127 
128  double calculateDistanceMoved(const BaseSpineModelGoal* subject) const;
129 
130  SpineGoalControl::Config m_config;
131 
132  std::string feedbackConfigFilename;
133  NeuroEvolution feedbackEvolution;
134  NeuroAdapter feedbackAdapter;
135  bool feedbackLearning;
136  configuration feedbackConfigData;
137 
138  std::string goalConfigFilename;
139  NeuroEvolution goalEvolution;
140  NeuroAdapter goalAdapter;
141  bool goalLearning;
142  configuration goalConfigData;
143 };
144 
145 #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, double tf=0.0)
SpineGoalControl(SpineGoalControl::Config config, std::string args, std::string resourcePath="", std::string ec="edgeConfig.ini", std::string nc="nodeConfig.ini", std::string fc="feedbackConfig.ini", std::string gc="goalConfig.ini")
A class to read a learning configuration from a .ini file.
virtual void onTeardown(BaseSpineModelLearning &subject)
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 onStep(BaseSpineModelLearning &subject, double dt)