NTRT Simulator  v1.1
 All Classes Namespaces Files Functions Variables Typedefs Friends Pages
tgCPGActuatorControl.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 TG_CPG_STRING_CONTRL_H
20 #define TG_CPG_STRING_CONTRL_H
21 
30 #include "util/tgBaseCPGNode.h"
32 // The Boost library
33 #include "boost/multi_array.hpp"
34 
35 typedef boost::multi_array<double, 2> array_2D;
36 typedef boost::multi_array<double, 4> array_4D;
37 
38 // Forward declarations
39 class btRigidBody;
40 class CPGEquations;
41 class CPGEquationsFB;
43 
44 class tgCPGActuatorControl : public tgObserver<tgSpringCableActuator>,
45  public tgBaseCPGNode
46 {
47 public:
48 
49  tgCPGActuatorControl(const double controlStep = 1.0/10000.0);
50 
51  virtual ~tgCPGActuatorControl();
52 
53  virtual void onAttach(tgSpringCableActuator& subject);
54 
55  virtual void onStep(tgSpringCableActuator& subject, double dt);
56 
62  void assignNodeNumber (CPGEquations& CPGSys, array_2D nodeParams);
63 
68  void setConnectivity(const std::vector<tgCPGActuatorControl*>& allStrings,
69  array_4D edgeParams);
70 
71  const int getNodeNumber() const
72  {
73  return m_nodeNumber;
74  }
75 
79  const CPGEquations* getCPGSys() const
80  {
81  return m_pCPGSystem;
82  }
83 
84  const double getCommandedTension() const
85  {
86  return m_commandedTension;
87  }
88 
89  virtual void setupControl(tgImpedanceController& ipc);
90 
91  void setupControl(tgImpedanceController& ipc,
92  double controlLength);
93 
94  const btRigidBody* getFromBody() const
95  {
96  return m_pFromBody;
97  }
98 
99  const btRigidBody* getToBody() const
100  {
101  return m_pToBody;
102  }
103 
104 protected:
114  const double m_controlStep;
115 
116  double m_totalTime;
117 
118  double m_commandedTension;
119 
120  btRigidBody* m_pFromBody;
121 
122  btRigidBody* m_pToBody;
123 };
124 
125 
126 #endif
virtual void onStep(tgSpringCableActuator &subject, double dt)
void setConnectivity(const std::vector< tgCPGActuatorControl * > &allStrings, array_4D edgeParams)
const CPGEquations * getCPGSys() const
virtual void onAttach(tgSpringCableActuator &subject)
Contains the definition of abstract base class tgSpringCableActuator. Assumes that the string is line...
void assignNodeNumber(CPGEquations &CPGSys, array_2D nodeParams)
Definition of class tgBaseCPGNode.