NTRT Simulator  Version: Master
 All Classes Namespaces 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 
31 #include <vector>
32 #include <sstream>
33 
34 //Forward Declaration
35 class CPGEdge;
36 
37 class CPGNode
38 {
39  friend class CPGEquations;
40  friend class CPGNodeFB;
41 
42  public:
43 
48  CPGNode(int nodeNum, const std::vector<double> & params);
49  virtual ~CPGNode();
50 
51  void addCoupling( CPGNode* cNode,
52  const double cWeight,
53  const double cPhase);
54 
60  virtual void updateDTs( double descCom);
61 
65  double nodeEquation( double d,
66  double c0,
67  double c1);
68 
69  virtual void updateNodeValues ( double newR,
70  double newRD,
71  double newPhi);
72  // out of date since we're using pointers, but still potentially useful
73  #if (0)
74  std::vector<CPGNode*> getCoupling(){
75  std::vector<CPGNode*> couplingNumbers;
76  return couplingNumbers;
77  }
78  #endif
79 
80  const int getNodeIndex() const
81  {
82  return m_nodeNumber;
83  }
84 
85  std::string toString(const std::string& prefix = "") const;
86 
87  protected:
88 
92  double nodeValue;
93  double phiValue;
94  double phiDotValue;
95  double rValue; //Radius
96  double rDotValue; //rDot for next update
97  double rDoubleDotValue; //Deriviative of RDot
98 
99  std::vector<CPGNode*> couplingList;
100  std::vector<double> phaseList;
101  std::vector<double> weightList;
102 
106  const int m_nodeNumber;
107 
111  const double rConst;
112 
113  const double frequencyOffset;
114  const double frequencyScale;
115 
116  const double radiusOffset;
117  const double radiusScale;
118 
119  const double dMin;
120  const double dMax;
121 
122 };
123 
131 inline std::ostream&
132 operator<<(std::ostream& os, const CPGNode& obj)
133 {
134  os << obj.toString() << std::endl;
135  return os;
136 }
137 
138 #endif // SIMULATOR_SRC_LIB_MODELS_SNAKE_CPGS_CPGNODE
double nodeEquation(double d, double c0, double c1)
Definition: CPGNode.cpp:90
const int m_nodeNumber
Definition: CPGNode.h:106
std::ostream & operator<<(std::ostream &os, const CPGNode &obj)
Definition: CPGNode.h:132
const double rConst
Definition: CPGNode.h:111
CPGNode(int nodeNum, const std::vector< double > &params)
Definition: CPGNode.cpp:35
double nodeValue
Definition: CPGNode.h:92
virtual void updateDTs(double descCom)
Definition: CPGNode.cpp:71