19 #ifndef _TORSIONAL_STIFFNESS_H_
20 #define _TORSIONAL_STIFFNESS_H_
22 #include "mbsim/link_mechanics.h"
23 #include <mbsim/frame.h>
24 #include "mbsim/functions/function.h"
26 #ifdef HAVE_OPENMBVCPPINTERFACE
27 #include "mbsim/utils/boost_parameters.h"
28 #include "mbsim/utils/openmbv_utils.h"
35 namespace MBSimPowertrain {
37 const MBXMLUtils::NamespaceURI MBSIMPOWERTRAIN(
"http://www.mbsim-env.de/MBSimPowertrain");
41 MBSim::Function<double(double,double)> *func;
42 std::vector<MBSim::RigidBody*> body;
44 #ifdef HAVE_OPENMBVCPPINTERFACE
45 boost::shared_ptr<OpenMBV::CoilSpring> coilspringOpenMBV;
49 void updateh(
double,
int i=0);
51 void updategd(
double);
57 bool gActiveChanged() {
return false; }
58 virtual bool isSingleValued()
const {
return true; }
59 std::string getType()
const {
return "RotationalSpringDamper"; }
60 void init(InitStage stage) {
72 func->setParent(
this);
73 func->setName(
"GeneralizedForce");
86 void plot(
double t,
double dt=1);
87 void initializeUsingXML(xercesc::DOMElement *element);
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();
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);
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);
112 std::string saved_body1, saved_body2;
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