NTRT Simulator
 All Classes Files Functions Variables Typedefs Friends Pages
tgLinearString.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_LINEAR_STRING_H
20 #define TG_LINEAR_STRING_H
21 
30 // This application
31 #include "tgModel.h"
32 #include "tgBaseString.h"
33 #include "tgSubject.h"
34 
35 // Forward declarations
36 class Muscle2P;
37 class tgModelVisitor;
38 class tgWorld;
39 
40 // Should always be a child Model of a tgModel
41 class tgLinearString : public tgSubject<tgLinearString>,
42  public tgBaseString
43 {
44 public:
45 
56  tgLinearString(Muscle2P* muscle,
57  const tgTags& tags,
58  tgBaseString::Config& config);
62  tgLinearString(Muscle2P* muscle,
63  std::string space_separated_tags,
64  tgBaseString::Config& config);
65 
69  virtual ~tgLinearString();
70 
75  virtual void setup(tgWorld& world);
76 
80  virtual void teardown();
81 
88  virtual void step(double dt);
89 
96  virtual void onVisit(const tgModelVisitor& r) const;
97 
108  virtual void tensionMinLengthController(const double targetTension,
109  float dt);
110 
115  void setRestLength(double newLength, float dt);
116 
121  const Muscle2P* getMuscle() const
122  {
123  return m_muscle;
124  }
125 
129  virtual const double getStartLength() const;
130 
131  virtual const double getCurrentLength() const;
132 
133  virtual const double getTension() const;
134 
135  virtual const double getRestLength() const;
136 
137  virtual const double getVelocity() const;
138 
139  virtual const tgBaseString::BaseStringHistory& getHistory() const;
140 
141 protected:
142 
146  virtual void moveMotors(double dt);
147 
148  Muscle2P* m_muscle;
149 
150 private:
151 
155  void constructorAux();
156 
161  void logHistory();
162 
164  bool invariant() const;
165 
169  double prevVel;
170 
171 };
172 
173 
174 #endif
const Muscle2P * getMuscle() const
tgLinearString(Muscle2P *muscle, const tgTags &tags, tgBaseString::Config &config)
Contains the definition of abstract base class tgBaseString. Assumes that the string is linear (F = -...
virtual ~tgLinearString()
Definition of tgSubject class.
virtual void teardown()
virtual void step(double dt)
void setRestLength(double newLength, float dt)
Contains the definition of class tgModel. $Id$.
virtual void tensionMinLengthController(const double targetTension, float dt)
virtual void setup(tgWorld &world)
virtual void moveMotors(double dt)
virtual void onVisit(const tgModelVisitor &r) const
virtual const double getStartLength() const
Definition: tgTags.h:43