All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
directional_spring_damper.h
1 /* Copyright (C) 2004-2009 MBSim Development Team
2  * This library is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU Lesser General Public
4  * License as published by the Free Software Foundation; either
5  * version 2.1 of the License, or (at your option) any later version.
6  *
7  * This library is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10  * Lesser General Public License for more details.
11  *
12  * You should have received a copy of the GNU Lesser General Public
13  * License along with this library; if not, write to the Free Software
14  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15  *
16  * Contact: martin.o.foerg@googlemail.com
17  */
18 
19 #ifndef _DIRECTIONAL_SPRING_DAMPER_H_
20 #define _DIRECTIONAL_SPRING_DAMPER_H_
21 
22 #include "mbsim/links/floating_frame_link.h"
23 #include "mbsim/functions/function.h"
24 
25 #include "mbsim/utils/boost_parameters.h"
26 #include "mbsim/utils/openmbv_utils.h"
27 
28 namespace MBSim {
29 
35  protected:
36  double dist;
38  double l0;
39  std::shared_ptr<OpenMBV::CoilSpring> coilspringOpenMBV;
40  public:
41  DirectionalSpringDamper(const std::string &name="");
43 
44  void updatePositions(Frame *frame);
45  void updateGeneralizedPositions();
46  void updateGeneralizedVelocities();
47  void updatelaF();
48 
49  /*INHERITED INTERFACE OF LINK*/
50  bool isActive() const { return true; }
51  bool gActiveChanged() { return false; }
52  bool isSingleValued() const { return true; }
53  std::string getType() const { return "DirectionalSpringDamper"; }
54  void init(InitStage stage);
55  /*****************************/
56 
62  void setForceFunction(Function<double(double,double)> *func_) {
63  func=func_;
64  func->setParent(this);
65  func->setName("Force");
66  }
67 
69  void setUnloadedLength(double l0_) { l0 = l0_; }
70 
74  void setForceDirection(const fmatvec::Vec3 &dir) { forceDir=dir/nrm2(dir); }
75 
76  void plot();
77  void initializeUsingXML(xercesc::DOMElement *element);
78 
79  BOOST_PARAMETER_MEMBER_FUNCTION( (void), enableOpenMBVCoilSpring, tag, (optional (numberOfCoils,(int),3)(springRadius,(double),1)(crossSectionRadius,(double),-1)(nominalLength,(double),-1)(type,(OpenMBV::CoilSpring::Type),OpenMBV::CoilSpring::tube)(diffuseColor,(const fmatvec::Vec3&),"[-1;1;1]")(transparency,(double),0)(minimalColorValue,(double),0)(maximalColorValue,(double),1))) {
80  OpenMBVCoilSpring ombv(springRadius,crossSectionRadius,1,numberOfCoils,nominalLength,type,diffuseColor,transparency,minimalColorValue,maximalColorValue);
81  coilspringOpenMBV=ombv.createOpenMBV();
82  }
83  };
84 
85 }
86 
87 #endif
std::string getType() const
Definition: directional_spring_damper.h:53
bool gActiveChanged()
Definition: directional_spring_damper.h:51
void setUnloadedLength(double l0_)
Set unloaded length.
Definition: directional_spring_damper.h:69
Definition: openmbv_utils.h:147
A spring damper force law. This class connects two frames and applies a force in it, which depends in the distance and relative velocity between the two frames.
Definition: directional_spring_damper.h:34
void setForceDirection(const fmatvec::Vec3 &dir)
Definition: directional_spring_damper.h:74
void init(InitStage stage)
plots time series header
Definition: directional_spring_damper.cc:64
void setForceFunction(Function< double(double, double)> *func_)
Set function for the force calculation. The first input parameter to that function is the distance re...
Definition: directional_spring_damper.h:62
void plot()
plots time dependent data
Definition: directional_spring_damper.cc:82
bool isActive() const
Definition: directional_spring_damper.h:50
InitStage
The stages of the initialization.
Definition: element.h:97
bool isSingleValued() const
asks the link if it contains single valued force laws that contribute to the right-hand side vector h...
Definition: directional_spring_damper.h:52
std::string name
name of element
Definition: element.h:298
cartesian frame on bodies used for application of e.g. links and loads
Definition: frame.h:37
void setName(const std::string &str)
Definition: element.h:163

Impressum / Disclaimer / Datenschutz Generated by doxygen 1.8.5 Valid HTML