NTRT Simulator  Version: Master
 All Classes Namespaces Files Functions Variables Typedefs Friends Pages
JSONMixedLearningControl.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 JSON_MIXED_LEARNING_CONTROL_H
20 #define JSON_MIXED_LEARNING_CONTROL_H
21 
31 
32 #include <json/value.h>
33 
34 // Forward Declarations
35 class neuralNetwork;
37 
47 {
48 public:
49 
51  {
52  public:
56  Config( int ss,
57  int tm,
58  int om,
59  int param,
60  int segnum = 6,
61  double ct = 0.1,
62  double la = 0,
63  double ha = 30,
64  double lp = -1 * M_PI,
65  double hp = M_PI,
66  double kt = 0.0,
67  double kp = 1000.0,
68  double kv = 100.0,
69  bool def = true,
70  double cl = 10.0,
71  double lf = 0.0,
72  double hf = 30.0,
73  double ffMin = 0.0,
74  double ffMax = 0.0,
75  double afMin = 0.0,
76  double afMax = 0.0,
77  double pfMin = 0.0,
78  double pfMax = 0.0,
79  double maxH = 25.0,
80  double minH = 1.0
81  );
82 
83  const double freqFeedbackMin;
84  const double freqFeedbackMax;
85  const double ampFeedbackMin;
86  const double ampFeedbackMax;
87  const double phaseFeedbackMin;
88  const double phaseFeedbackMax;
89 
90  const double maxHeight;
91  const double minHeight;
92 
93  // Values to be filled in by JSON file during onSetup
94  int numStates;
95  int numActions;
96  int numHidden;
97 
98  };
99 
101  std::string args,
102  std::string resourcePath = "");
103 
104  virtual ~JSONMixedLearningControl();
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 startingEdgeActions, array_4D middleEdgeActions, array_4D endingEdgeActions);
115 
116  virtual array_2D scaleNodeActions (Json::Value actions);
117 
118  std::vector<double> getFeedback(BaseSpineModelLearning& subject);
119 
120  std::vector<double> getCableState(const tgSpringCableActuator& cable);
121 
122  std::vector<double> transformFeedbackActions(std::vector< std::vector<double> >& actions);
123 
125 
126  std::vector<tgCPGActuatorControl*> m_startingControllers;
127  std::vector<tgCPGActuatorControl*> m_middleControllers;
128  std::vector<tgCPGActuatorControl*> m_endingControllers;
129 
131  neuralNetwork* nn;
132 
133 };
134 
135 #endif // JSON_MIXED_LEARNING_CONTROL_H
An adaptation of JSONCPGControl that utilizes JSON for parameters.
virtual void onSetup(BaseSpineModelLearning &subject)
JSONMixedLearningControl(JSONMixedLearningControl::Config config, std::string args, std::string resourcePath="")
virtual void onTeardown(BaseSpineModelLearning &subject)
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 maxH=25.0, double minH=1.0)
virtual void onStep(BaseSpineModelLearning &subject, double dt)