NTRT Simulator  Version: Master
 All Classes Namespaces Files Functions Variables Typedefs Friends Pages
JSONMGFeedbackControlFM1.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_MG_FEEDBACK_CONTROL_FM1_H
20 #define JSON_MG_FEEDBACK_CONTROL_FM1_H
21 
31 #include "dev/dhustigschultz/BP_SC_NoLegs_Stats/JSONQuadCPGControl.h"
32 
33 #include <json/value.h>
34 
35 // Forward Declarations
36 class neuralNetwork;
38 
48 {
49 public:
50 
52  {
53  public:
57  Config( int ss,
58  int tm,
59  int om,
60  int param,
61  int segnum = 6,
62  double ct = 0.1,
63  double la = 0,
64  double ha = 30,
65  double lp = -1 * M_PI,
66  double hp = M_PI,
67  double kt = 0.0,
68  double kp = 1000.0,
69  double kv = 100.0,
70  bool def = true,
71  double cl = 10.0,
72  double lf = 0.0,
73  double hf = 30.0,
74  double ffMin = 0.0,
75  double ffMax = 0.0,
76  double afMin = 0.0,
77  double afMax = 0.0,
78  double pfMin = 0.0,
79  double pfMax = 0.0,
80  double maxH = 60.0, //May need to tune this value more
81  double minH = 1.0 //Perhaps same
82  );
83 
84  const double freqFeedbackMin;
85  const double freqFeedbackMax;
86  const double ampFeedbackMin;
87  const double ampFeedbackMax;
88  const double phaseFeedbackMin;
89  const double phaseFeedbackMax;
90 
91  const double maxHeight;
92  const double minHeight;
93 
94  // Values to be filled in by JSON file during onSetup
95  int numStates;
96  int numActions;
97 
98  };
99 
101  std::string args,
102  std::string resourcePath = "");
103 
104  virtual ~JSONMGFeedbackControlFM1();
105 
106  virtual void onSetup(BaseQuadModelLearning& subject);
107 
108  virtual void onStep(BaseQuadModelLearning& subject, double dt);
109 
110  virtual void onTeardown(BaseQuadModelLearning& subject);
111 
112 
113 protected:
114 
115  virtual void setupCPGs(BaseQuadModelLearning& subject, array_2D nodeActions, array_4D edgeActions);
116 
117  virtual array_2D scaleNodeActions (Json::Value actions);
118 
119  std::vector<double> getFeedback(BaseQuadModelLearning& subject);
120 
121  std::vector<double> getCableState(const tgSpringCableActuator& cable);
122 
123  std::vector<double> transformFeedbackActions(std::vector< std::vector<double> >& actions);
124 
126 
127  std::vector<tgCPGActuatorControl*> m_spineControllers;
128 
130  neuralNetwork* nn;
131 
132  double m_totalTime;
133 
134 };
135 
136 #endif // JSON_QUAD_FEEDBACK_CONTROL_H
virtual void onStep(BaseQuadModelLearning &subject, double dt)
virtual void onSetup(BaseQuadModelLearning &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=60.0, double minH=1.0)
virtual void onTeardown(BaseQuadModelLearning &subject)
JSONMGFeedbackControlFM1(JSONMGFeedbackControlFM1::Config config, std::string args, std::string resourcePath="")