NTRT Simulator
 All Classes Files Functions Variables Typedefs Friends Pages
CPGNode.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 SIMULATOR_SRC_LIB_MODELS_SNAKE_CPGS_CPGNODE
20 #define SIMULATOR_SRC_LIB_MODELS_SNAKE_CPGS_CPGNODE
21 
30 #include <algorithm> //for_each
31 #include <math.h>
32 #include <vector>
33 #include <assert.h>
34 #include <sstream>
35 
36 #include "CPGEdge.h"
37 
38 //Forward Declaration
39 class CPGEdge;
40 
41 class CPGNode
42 {
43  public:
44 
49  CPGNode(int nodeNum, const std::vector<double> & params);
50  ~CPGNode();
51 
52  void addCoupling(CPGEdge* newEdge);
53 
54  void addCoupling( CPGNode* cNode,
55  const double cWeight,
56  const double cPhase);
57 
58  void addCoupling(std::vector<CPGEdge*> edgeList);
59 
65  void updateDTs( double descCom);
66 
70  double nodeEquation( double d,
71  double c0,
72  double c1);
73 
74  void updateNodeValues ( double newR,
75  double newRD,
76  double newPhi);
77  // out of date since we're using pointers, but still potentially useful
78  #if (0)
79  std::vector<CPGNode*> getCoupling(){
80  std::vector<CPGNode*> couplingNumbers;
81  return couplingNumbers;
82  }
83  #endif
84 
85  const int getNodeIndex() const
86  {
87  return m_nodeNumber;
88  }
89 
90  std::string toString(const std::string& prefix = "") const;
91 
95  double nodeValue;
96  double phiValue;
97  double phiDotValue;
98  double rValue; //Radius
99  double rDotValue; //rDot for next update
100  double rDoubleDotValue; //Deriviative of RDot
101 
102  protected:
103 
104  std::vector<CPGEdge*> couplingList;
105 
109  const int m_nodeNumber;
110 
114  const double rConst;
115 
116  const double frequencyOffset;
117  const double frequencyScale;
118 
119  const double radiusOffset;
120  const double radiusScale;
121 
122  const double dMin;
123  const double dMax;
124 
125 };
126 
134 inline std::ostream&
135 operator<<(std::ostream& os, const CPGNode& obj)
136 {
137  os << obj.toString() << std::endl;
138  return os;
139 }
140 
141 #endif // SIMULATOR_SRC_LIB_MODELS_SNAKE_CPGS_CPGNODE
double nodeEquation(double d, double c0, double c1)
Definition: CPGNode.cpp:93
const int m_nodeNumber
Definition: CPGNode.h:109
std::ostream & operator<<(std::ostream &os, const CPGNode &obj)
Definition: CPGNode.h:135
const double rConst
Definition: CPGNode.h:114
Definition of class CPGEdge.
CPGNode(int nodeNum, const std::vector< double > &params)
Definition: CPGNode.cpp:30
double nodeValue
Definition: CPGNode.h:95
void updateDTs(double descCom)
Definition: CPGNode.cpp:76