All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
torsional_stiffness.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 _TORSIONAL_STIFFNESS_H_
20 #define _TORSIONAL_STIFFNESS_H_
21 
22 #include "mbsim/link_mechanics.h"
23 #include <mbsim/frame.h>
24 #include "mbsim/functions/function.h"
25 
26 #ifdef HAVE_OPENMBVCPPINTERFACE
27 #include "mbsim/utils/boost_parameters.h"
28 #include "mbsim/utils/openmbv_utils.h"
29 #endif
30 
31 namespace MBSim {
32  class RigidBody;
33 }
34 
35 namespace MBSimPowertrain {
36 
37  const MBXMLUtils::NamespaceURI MBSIMPOWERTRAIN("http://www.mbsim-env.de/MBSimPowertrain");
38 
40  protected:
41  MBSim::Function<double(double,double)> *func;
42  std::vector<MBSim::RigidBody*> body;
43  MBSim::Frame C;
44 #ifdef HAVE_OPENMBVCPPINTERFACE
45  boost::shared_ptr<OpenMBV::CoilSpring> coilspringOpenMBV;
46 #endif
47  public:
48  TorsionalStiffness(const std::string &name="");
49  void updateh(double, int i=0);
50  void updateg(double);
51  void updategd(double);
52 
54  //void connect(Frame *frame1, Frame* frame2);
55 
56  bool isActive() const { return true; }
57  bool gActiveChanged() { return false; }
58  virtual bool isSingleValued() const { return true; }
59  std::string getType() const { return "RotationalSpringDamper"; }
60  void init(InitStage stage) {
62  func->init(stage);
63  }
64 
70  void setGeneralizedForceFunction(MBSim::Function<double(double,double)> *func_) {
71  func=func_;
72  func->setParent(this);
73  func->setName("GeneralizedForce");
74  }
75 
83  void setRigidBodyFirstSide(MBSim::RigidBody* body_) { body[0] = body_; }
84  void setRigidBodySecondSide(MBSim::RigidBody* body_) { body[1] = body_; }
85 
86  void plot(double t, double dt=1);
87  void initializeUsingXML(xercesc::DOMElement *element);
88 
89  void updatehRef(const fmatvec::Vec &hParent, int j=0);
90 
91 #ifdef HAVE_OPENMBVCPPINTERFACE
92  BOOST_PARAMETER_MEMBER_FUNCTION( (void), enableOpenMBVCoilSpring, MBSim::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))) {
93  MBSim::OpenMBVCoilSpring ombv(springRadius,crossSectionRadius,1,numberOfCoils,nominalLength,type,diffuseColor,transparency);
94  coilspringOpenMBV=ombv.createOpenMBV();
95  }
96 
98  BOOST_PARAMETER_MEMBER_FUNCTION( (void), enableOpenMBVForce, MBSim::tag, (optional (scaleLength,(double),1)(scaleSize,(double),1)(referencePoint,(OpenMBV::Arrow::ReferencePoint),OpenMBV::Arrow::toPoint)(diffuseColor,(const fmatvec::Vec3&),"[-1;1;1]")(transparency,(double),0))) {
99  MBSim::OpenMBVArrow ombv(diffuseColor,transparency,OpenMBV::Arrow::toHead,referencePoint,scaleLength,scaleSize);
100  std::vector<bool> which; which.resize(2, true);
101  LinkMechanics::setOpenMBVForceArrow(ombv.createOpenMBV(), which);
102  }
103 
105  BOOST_PARAMETER_MEMBER_FUNCTION( (void), enableOpenMBVMoment, MBSim::tag, (optional (scaleLength,(double),1)(scaleSize,(double),1)(referencePoint,(OpenMBV::Arrow::ReferencePoint),OpenMBV::Arrow::toPoint)(diffuseColor,(const fmatvec::Vec3&),"[-1;1;1]")(transparency,(double),0))) {
106  MBSim::OpenMBVArrow ombv(diffuseColor,transparency,OpenMBV::Arrow::toDoubleHead,referencePoint,scaleLength,scaleSize);
107  std::vector<bool> which; which.resize(2, true);
108  LinkMechanics::setOpenMBVMomentArrow(ombv.createOpenMBV(), which);
109  }
110 #endif
111  private:
112  std::string saved_body1, saved_body2;
113  };
114 
115 }
116 
117 #endif
118 
bool isActive() const
Connect the RelativeRotationalSpringDamper to frame1 and frame2.
Definition: torsional_stiffness.h:56
virtual void init(InitStage stage)
Definition: torsional_stiffness.h:39
void setGeneralizedForceFunction(MBSim::Function< double(double, double)> *func_)
Set function for the torque calculation. The first input parameter to that function is the relative r...
Definition: torsional_stiffness.h:70
void setRigidBodyFirstSide(MBSim::RigidBody *body_)
Set a projection direction for the resulting torque If this function is not set, or frame is NULL...
Definition: torsional_stiffness.h:83

Impressum / Disclaimer / Datenschutz Generated by doxygen 1.8.5 Valid HTML