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/frames/frame.h>
24 #include "mbsim/functions/function.h"
25 
26 #include "mbsim/utils/boost_parameters.h"
27 #include "mbsim/utils/openmbv_utils.h"
28 
29 namespace MBSim {
30  class RigidBody;
31 }
32 
33 namespace MBSimPowertrain {
34 
35  const MBXMLUtils::NamespaceURI MBSIMPOWERTRAIN("http://www.mbsim-env.de/MBSimPowertrain");
36 
37  class TorsionalStiffness : public MBSim::LinkMechanics {
38  protected:
40  std::vector<MBSim::RigidBody*> body;
41  MBSim::Frame C;
42  std::shared_ptr<OpenMBV::CoilSpring> coilspringOpenMBV;
43  public:
44  TorsionalStiffness(const std::string &name="");
45  void updateh(double, int i=0);
46  void updateg(double);
47  void updategd(double);
48 
50  //void connect(Frame *frame1, Frame* frame2);
51 
52  bool isActive() const { return true; }
53  bool gActiveChanged() { return false; }
54  virtual bool isSingleValued() const { return true; }
55  std::string getType() const { return "RotationalSpringDamper"; }
56  void init(InitStage stage) {
57  MBSim::LinkMechanics::init(stage);
58  func->init(stage);
59  }
60 
66  void setGeneralizedForceFunction(MBSim::Function<double(double,double)> *func_) {
67  func=func_;
68  func->setParent(this);
69  func->setName("GeneralizedForce");
70  }
71 
79  void setRigidBodyFirstSide(MBSim::RigidBody* body_) { body[0] = body_; }
80  void setRigidBodySecondSide(MBSim::RigidBody* body_) { body[1] = body_; }
81 
82  void plot();
83  void initializeUsingXML(xercesc::DOMElement *element);
84 
85  void updatehRef(const fmatvec::Vec &hParent, int j=0);
86 
87  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))) {
88  MBSim::OpenMBVCoilSpring ombv(springRadius,crossSectionRadius,1,numberOfCoils,nominalLength,type,diffuseColor,transparency);
89  coilspringOpenMBV=ombv.createOpenMBV();
90  }
91 
93  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))) {
94  MBSim::OpenMBVArrow ombv(diffuseColor,transparency,OpenMBV::Arrow::toHead,referencePoint,scaleLength,scaleSize);
95  std::vector<bool> which; which.resize(2, true);
96  LinkMechanics::setOpenMBVForceArrow(ombv.createOpenMBV(), which);
97  }
98 
100  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))) {
101  MBSim::OpenMBVArrow ombv(diffuseColor,transparency,OpenMBV::Arrow::toDoubleHead,referencePoint,scaleLength,scaleSize);
102  std::vector<bool> which; which.resize(2, true);
103  LinkMechanics::setOpenMBVMomentArrow(ombv.createOpenMBV(), which);
104  }
105  private:
106  std::string saved_body1, saved_body2;
107  };
108 
109 }
110 
111 #endif
112 
bool isActive() const
Connect the RelativeRotationalSpringDamper to frame1 and frame2.
Definition: torsional_stiffness.h:52
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)))
Visualize a force arrow acting on each of both connected frames.
Definition: torsional_stiffness.h:93
Definition: torsional_stiffness.h:37
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:66
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:79
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)))
Visualize a torque arrow acting on each of both connected frames.
Definition: torsional_stiffness.h:100

Impressum / Disclaimer / Datenschutz Generated by doxygen 1.8.5 Valid HTML