NTRT Simulator  Version: Master
 All Classes Namespaces Files Functions Variables Typedefs Friends Pages
TetraSpineCPGControl.cpp
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 
28 #include "TetraSpineCPGControl.h"
29 
30 #include <string>
31 
32 
33 // Should include tgString, but compiler complains since its been
34 // included from TetraSpineLearningModel. Perhaps we should move things
35 // to a cpp over there
38 
41 
43 
50  std::string args,
51  std::string resourcePath,
52  std::string ec,
53  std::string nc) :
54 BaseSpineCPGControl(config, args, resourcePath, ec, nc)
55 {
56 }
57 
58 void TetraSpineCPGControl::setupCPGs(BaseSpineModelLearning& subject, array_2D nodeActions, array_4D edgeActions)
59 {
60  std::vector <tgSpringCableActuator*> allMuscles = subject.getAllMuscles();
61 
62  for (std::size_t i = 0; i < allMuscles.size(); i++)
63  {
64  tgCPGActuatorControl* pStringControl = new tgCPGActuatorControl();
65  allMuscles[i]->attach(pStringControl);
66  m_allControllers.push_back(pStringControl);
67  }
68 
70  // First assign node numbers to the info Classes
71  for (std::size_t i = 0; i < m_allControllers.size(); i++)
72  {
73  m_allControllers[i]->assignNodeNumber(*m_pCPGSys, nodeActions);
74  }
75 
76  double tension;
77  double kPosition;
78  double kVelocity;
79  double controlLength;
80  // Then determine connectivity and setup string
81  for (std::size_t i = 0; i < m_allControllers.size(); i++)
82  {
83  tgCPGActuatorControl * const pStringInfo = m_allControllers[i];
84  assert(pStringInfo != NULL);
85  pStringInfo->setConnectivity(m_allControllers, edgeActions);
86 
87  //String will own this pointer
88 #if (0) // origninal params
89  if (allMuscles[i]->hasTag("outer"))
90  {
91  tension = 0.0;
92  kPosition = 1000.0;
93  kVelocity = 100.0;
94  controlLength = 17.0;
95  }
96  else
97  {
98  tension = 0.0;
99  kPosition = 1000.0;
100  kVelocity = 100.0;
101  controlLength = 15.0 ;
102  }
103 #else // Params for In Won
104  if (allMuscles[i]->hasTag("outer"))
105  {
106  tension = 100.0;
107  kPosition = 100.0;
108  kVelocity = 200.0;
109  controlLength = 19.5;
110  }
111  else
112  {
113  tension = 100.0;
114  kPosition = 500.0;
115  kVelocity = 200.0;
116  controlLength = 16.5 ;
117  }
118 #endif
119  tgImpedanceController* p_ipc = new tgImpedanceController( tension,
120  kPosition,
121  kVelocity);
122  pStringInfo->setupControl(*p_ipc, controlLength);
123 
124  }
125 
126 }
Contains the definition of class ImpedanceControl. $Id$.
TetraSpineCPGControl(BaseSpineCPGControl::Config config, std::string args, std::string resourcePath, std::string ec="edgeConfig.ini", std::string nc="nodeConfig.ini")
void setConnectivity(const std::vector< tgCPGActuatorControl * > &allStrings, array_4D edgeParams)
Controller for TetraSpineLearningModel.
virtual void setupCPGs(BaseSpineModelLearning &subject, array_2D nodeActions, array_4D edgeActions)
Definition of the tgCPGStringControl observer class.
A class to read a learning configuration from a .ini file.
Contains the definition of abstract base class tgSpringCableActuator. Assumes that the string is line...
Contains the definition of class AnnealEvolution. Adapting NeuroEvolution to do Simulated Annealing...