NTRT Simulator
 All Classes Files Functions Variables Typedefs Friends Pages
tgCPGStringControl.h
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 TG_CPG_STRING_CONTRL_H
20 #define TG_CPG_STRING_CONTRL_H
21 
22 #include "util/tgBaseCPGNode.h"
23 #include "core/tgLinearString.h"
24 // The Boost library
25 #include "boost/multi_array.hpp"
26 
27 typedef boost::multi_array<double, 2> array_2D;
28 typedef boost::multi_array<double, 4> array_4D;
29 
30 // Forward declarations
31 class btRigidBody;
32 class CPGEquations;
33 class ImpedanceControl;
34 
35 class tgCPGStringControl : public tgObserver<tgLinearString>,
36  public tgBaseCPGNode
37 {
38 public:
39 
40  tgCPGStringControl(const double controlStep = 1.0/10000.0);
41 
42  virtual ~tgCPGStringControl();
43 
44  virtual void onAttach(tgLinearString& subject);
45 
46  virtual void onStep(tgLinearString& subject, double dt);
47 
53  void assignNodeNumber (CPGEquations& CPGSys, array_2D nodeParams);
54 
59  void setConnectivity(const std::vector<tgCPGStringControl*>& allStrings,
60  array_4D edgeParams);
61 
62  const int getNodeNumber() const
63  {
64  return m_nodeNumber;
65  }
66 
70  const CPGEquations* getCPGSys() const
71  {
72  return m_pCPGSystem;
73  }
74 
75  const double getCommandedTension() const
76  {
77  return m_commandedTension;
78  }
79 
80  virtual void setupControl(ImpedanceControl& ipc);
81 
82  void setupControl(ImpedanceControl& ipc,
83  double controlLength);
84 
85  const btRigidBody* getFromBody() const
86  {
87  return m_pFromBody;
88  }
89 
90  const btRigidBody* getToBody() const
91  {
92  return m_pToBody;
93  }
94 
95 private:
100  double m_controlTime;
105  const double m_controlStep;
106 
107  double m_commandedTension;
108 
109  btRigidBody* m_pFromBody;
110 
111  btRigidBody* m_pToBody;
112 };
113 
114 
115 #endif
virtual void onAttach(tgLinearString &subject)
virtual void onStep(tgLinearString &subject, double dt)
const CPGEquations * getCPGSys() const
void setConnectivity(const std::vector< tgCPGStringControl * > &allStrings, array_4D edgeParams)
Contains the definition of class tgLinearString.
void assignNodeNumber(CPGEquations &CPGSys, array_2D nodeParams)
Definition of class tgBaseCPGNode.