NTRT Simulator
 All Classes 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 <assert.h>
32 #include <sstream>
33 
34 #include "CPGNode.h"
35 #include "CPGEdge.h"
36 
42 {
43  public:
44 
45  CPGEquations();
46 
47  CPGEquations(std::vector<CPGNode*> newNodeList);
48 
49  ~CPGEquations();
50 
51  int addNode(std::vector<double> newParams);
52 
53  void connectNode(int nodeIndex,
54  std::vector<CPGEdge*> connectivityList);
55 
56  void defineConnections (int nodeIndex,
57  std::vector<int> connections,
58  std::vector<double> newWeights,
59  std::vector<double> newPhaseOffsets);
60 
61  double operator[](const int i)
62  {
63  return nodeList[i]->nodeValue;
64  }
65 
66  std::vector<double> getXVars();
67 
68  std::vector<double> getDXVars();
69 
70  void updateNodes(std::vector<double> descCom);
71 
72  void updateNodeData(std::vector<double> newXVals);
73 
77  void update(std::vector<double> descCom, double dt);
78 
79  std::string toString(const std::string& prefix = "") const;
80 
81 protected:
82 
83  std::vector<CPGNode*> nodeList;
84 
85  double stepSize;
86 };
87 
95 inline std::ostream&
96 operator<<(std::ostream& os, const CPGEquations& obj)
97 {
98  os << obj.toString() << std::endl;
99  return os;
100 }
101 
102 #endif // SIMULATOR_SRC_LIB_MODELS_SNAKE_CPGS_CPGEQUATIONS
std::ostream & operator<<(std::ostream &os, const CPGEquations &obj)
Definition: CPGEquations.h:96
void update(std::vector< double > descCom, double dt)
Definition of class CPGEdge.
Definition of class CPGNode.