NTRT Simulator
 All Classes Files Functions Variables Typedefs Friends Pages
tgBaseString.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_BASE_STRING_H
20 #define TG_BASE_STRING_H
21 
30 // This application
31 #include "tgModel.h"
32 
33 #include <deque> // For history
34 // Forward declarations
35 class tgWorld;
36 
41 // Should always be a child Model of a tgModel
42 class tgBaseString : public tgModel
43 {
44 public:
45 
46  struct Config
47  {
48  public:
54  Config( double s = 1000.0,
55  double d = 10.0,
56  bool h = false,
57  double rot = 0,
58  double mf = 1000.0,
59  double tVel = 100.0,
60  double mxAcc = 10000.0,
61  double mnAL = 0.1,
62  double mnRL = 0.1);
63 
69  void scale (double sf);
70 
71  // Muscle2P Parameters
79  double stiffness;
85  double damping;
86 
87  // History Parameters
92  bool hist;
93 
94  // Construction Parameters
101  double rotation;
102 
103  // Motor model parameters
117  double maxTens;
118 
125 
132  double maxAcc;
133 
140 
146  double minRestLength;
147  };
148 
151  {
153  std::deque<double> lastLengths;
154 
156  std::deque<double> restLengths;
157 
159  std::deque<double> dampingHistory;
160 
162  std::deque<double> lastVelocities;
163 
165  std::deque<double> tensionHistory;
166  };
167 
169  virtual ~tgBaseString();
170 
171  virtual void setup(tgWorld& wdorld);
172 
173  virtual void teardown();
174 
176  virtual void step(double dt);
177 
182  // Called from controller class, it makes the restLength get closer to preferredlength.
183  virtual void moveMotors(double dt) = 0;
184 
185  // @todo look into a base class implementation of this. Wouldn't be
186  // difficult with existing get functions
187  virtual void tensionMinLengthController(const double targetTension,
188  float dt) = 0;
189 
190  virtual void setRestLength(double newLength, float dt);
191 
192  virtual const double getStartLength() const = 0;
193 
194  virtual const double getCurrentLength() const = 0;
195 
196  virtual const double getTension() const = 0;
197 
198  virtual const double getRestLength() const = 0;
199 
200  virtual const double getVelocity() const = 0;
201 
202 protected:
203 
208  tgBaseString(const tgTags& tags,
209  tgBaseString::Config& config,
210  double restLength,
211  double actualLength);
212 
213  tgBaseString(std::string space_separated_tags,
214  tgBaseString::Config& config,
215  double restLength,
216  double actualLength);
217 
218 protected:
224 
227 
228 
233  double m_restLength;
234 
235  double m_preferredLength;
236 
241 
246 private:
247 
251  void constructorAux();
252 
254  bool invariant() const;
255 
256 
257 };
258 
259 
260 #endif
void scale(double sf)
virtual ~tgBaseString()
double m_restLength
Definition: tgBaseString.h:233
double m_startLength
Definition: tgBaseString.h:240
Config m_config
Definition: tgBaseString.h:223
virtual void step(double dt)
std::deque< double > lastLengths
Definition: tgBaseString.h:153
virtual void setup(tgWorld &wdorld)
std::deque< double > dampingHistory
Definition: tgBaseString.h:159
std::deque< double > tensionHistory
Definition: tgBaseString.h:165
Contains the definition of class tgModel. $Id$.
virtual void moveMotors(double dt)=0
Config(double s=1000.0, double d=10.0, bool h=false, double rot=0, double mf=1000.0, double tVel=100.0, double mxAcc=10000.0, double mnAL=0.1, double mnRL=0.1)
double m_prevVelocity
Definition: tgBaseString.h:245
BaseStringHistory *const m_pHistory
Definition: tgBaseString.h:226
virtual void teardown()
std::deque< double > lastVelocities
Definition: tgBaseString.h:162
tgBaseString(const tgTags &tags, tgBaseString::Config &config, double restLength, double actualLength)
std::deque< double > restLengths
Definition: tgBaseString.h:156
Definition: tgTags.h:43