NTRT Simulator
 All Classes Files Functions Variables Typedefs Friends Pages
CPGEdge.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 
27 #include "CPGEdge.h"
28 #include "CPGNode.h"
29 
30 CPGEdge::CPGEdge( CPGNode* newTarget,
31  double newWeight,
32  double newPhase):
33 targetNode(newTarget),
34 weight(newWeight),
35 phaseOffset(newPhase)
36 {
37 
38 }
39 
41  // will be deleted by CPGEquations
42  targetNode = NULL;
43 }
44 
45 void CPGEdge::couple(CPGNode & currentNode){
46  currentNode.phiDotValue += weight * targetNode->rValue * sin (targetNode->phiValue - currentNode.phiValue - phaseOffset);
47 }
48 
49 std::string CPGEdge::toString(const std::string& prefix) const
50 {
51  std::string p = " ";
52  std::ostringstream os;
53  os << prefix << "CPGEdge(";
54 
55  // TODO: add something about parameters of this edge?
56 
57  os << prefix << p << "Conected to:";
58  os << prefix << p << p << targetNode->getNodeIndex();
59 
60  os << prefix << ")";
61  return os.str();
62 }
~CPGEdge()
Definition: CPGEdge.cpp:40
virtual void couple(CPGNode &currentNode)
Definition: CPGEdge.cpp:45
Definition of class CPGEdge.
Definition of class CPGNode.