NTRT Simulator  Version: Master
 All Classes Namespaces Files Functions Variables Typedefs Friends Pages
CPGEquations.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 SRC_UTIL_CPGS_CPGEQUATIONS
20 #define SRC_UTIL_CPGS_CPGEQUATIONS
21 
30 #include <vector>
31 #include <sstream>
32 
33 #include "CPGNode.h"
34 
40 {
41  public:
42 
43  CPGEquations(int maxSteps = 200);
44 
45  CPGEquations(std::vector<CPGNode*>& newNodeList, int maxSteps = 200);
46 
47  virtual ~CPGEquations();
48 
49  int addNode(std::vector<double>& newParams);
50 
51  void defineConnections (int nodeIndex,
52  std::vector<int> connections,
53  std::vector<double> newWeights,
54  std::vector<double> newPhaseOffsets);
55 
56  const double operator[](const std::size_t i) const;
57 
58  virtual std::vector<double>& getXVars();
59 
60  virtual std::vector<double>& getDXVars();
61 
62  virtual void updateNodes(std::vector<double>& descCom);
63 
64  virtual void updateNodeData(std::vector<double> newXVals);
65 
69  void update(std::vector<double>& descCom, double dt);
70 
71  std::string toString(const std::string& prefix = "") const;
72 
73  void countStep()
74  {
75  numSteps++;
76  }
77 
78 protected:
79 
80  std::vector<CPGNode*> nodeList;
81 
82  std::vector<double> XVars;
83  std::vector<double> DXVars;
84 
85  double stepSize;
86 
87  int m_maxSteps;
88  int numSteps;
89 
90 };
91 
99 inline std::ostream&
100 operator<<(std::ostream& os, const CPGEquations& obj)
101 {
102  os << obj.toString() << std::endl;
103  return os;
104 }
105 
106 #endif // SIMULATOR_SRC_LIB_MODELS_SNAKE_CPGS_CPGEQUATIONS
void update(std::vector< double > &descCom, double dt)
std::ostream & operator<<(std::ostream &os, const CPGEquations &obj)
Definition: CPGEquations.h:100
Definition of class CPGNode.