19 #ifndef _SPRINGDAMPER_H_
20 #define _SPRINGDAMPER_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"
43 Function<double(double,double)> *func;
44 #ifdef HAVE_OPENMBVCPPINTERFACE
45 boost::shared_ptr<OpenMBV::CoilSpring> coilspringOpenMBV;
50 void updateh(
double,
int i=0);
52 void updategd(
double);
61 std::string
getType()
const {
return "SpringDamper"; }
72 func->setParent(
this);
73 func->setName(
"Force");
76 void plot(
double t,
double dt=1);
77 void initializeUsingXML(xercesc::DOMElement *element);
79 #ifdef HAVE_OPENMBVCPPINTERFACE
81 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))) {
82 OpenMBVCoilSpring ombv(springRadius,crossSectionRadius,1,numberOfCoils,nominalLength,type,diffuseColor,transparency);
83 coilspringOpenMBV=ombv.createOpenMBV();
87 BOOST_PARAMETER_MEMBER_FUNCTION( (
void), enableOpenMBVForce, 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))) {
88 OpenMBVArrow ombv(diffuseColor,transparency,OpenMBV::Arrow::toHead,referencePoint,scaleLength,scaleSize);
89 std::vector<bool> which; which.resize(2,
true);
90 LinkMechanics::setOpenMBVForceArrow(ombv.createOpenMBV(), which);
94 std::string saved_ref1, saved_ref2;
104 Function<double(double,double)> *func;
106 fmatvec::Vec3 forceDir, WforceDir, WrP0P1;
108 #ifdef HAVE_OPENMBVCPPINTERFACE
109 boost::shared_ptr<OpenMBV::CoilSpring> coilspringOpenMBV;
114 void updateh(
double,
int i=0);
115 void updateg(
double);
116 void updategd(
double);
125 std::string
getType()
const {
return "DirectionalSpringDamper"; }
136 func->setParent(
this);
137 func->setName(
"Force");
145 void plot(
double t,
double dt=1);
146 void initializeUsingXML(xercesc::DOMElement *element);
148 #ifdef HAVE_OPENMBVCPPINTERFACE
149 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))) {
150 OpenMBVCoilSpring ombv(springRadius,crossSectionRadius,1,numberOfCoils,nominalLength,type,diffuseColor,transparency);
151 coilspringOpenMBV=ombv.createOpenMBV();
155 BOOST_PARAMETER_MEMBER_FUNCTION( (
void), enableOpenMBVForce, 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))) {
156 OpenMBVArrow ombv(diffuseColor,transparency,OpenMBV::Arrow::toHead,referencePoint,scaleLength,scaleSize);
157 std::vector<bool> which; which.resize(2,
true);
158 LinkMechanics::setOpenMBVForceArrow(ombv.createOpenMBV(), which);
162 std::string saved_ref1, saved_ref2;
167 Function<double(double,double)> *func;
168 std::vector<RigidBody*> body;
169 #ifdef HAVE_OPENMBVCPPINTERFACE
170 boost::shared_ptr<OpenMBV::CoilSpring> coilspringOpenMBV;
175 void updateh(
double,
int i=0);
176 void updateg(
double);
177 void updategd(
double);
182 std::string
getType()
const {
return "GeneralizedSpringDamper"; }
188 func->setParent(
this);
189 func->setName(
"GeneralizedFoce");
192 void setRigidBodyFirstSide(
RigidBody* body_) { body[0] = body_; }
193 void setRigidBodySecondSide(RigidBody* body_) { body[1] = body_; }
195 void plot(
double t,
double dt=1);
196 void initializeUsingXML(xercesc::DOMElement *element);
200 #ifdef HAVE_OPENMBVCPPINTERFACE
201 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))) {
202 OpenMBVCoilSpring ombv(springRadius,crossSectionRadius,1,numberOfCoils,nominalLength,type,diffuseColor,transparency);
203 coilspringOpenMBV=ombv.createOpenMBV();
207 BOOST_PARAMETER_MEMBER_FUNCTION( (
void), enableOpenMBVForce, 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))) {
208 OpenMBVArrow ombv(diffuseColor,transparency,OpenMBV::Arrow::toHead,referencePoint,scaleLength,scaleSize);
209 std::vector<bool> which; which.resize(2,
true);
210 LinkMechanics::setOpenMBVForceArrow(ombv.createOpenMBV(), which);
214 BOOST_PARAMETER_MEMBER_FUNCTION( (
void), enableOpenMBVMoment, 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))) {
215 OpenMBVArrow ombv(diffuseColor,transparency,OpenMBV::Arrow::toDoubleHead,referencePoint,scaleLength,scaleSize);
216 std::vector<bool> which; which.resize(2,
true);
217 LinkMechanics::setOpenMBVMomentArrow(ombv.createOpenMBV(), which);
221 std::string saved_body1, saved_body2;
std::string getType() const
Definition: spring_damper.h:125
bool gActiveChanged()
Definition: spring_damper.h:123
void init(InitStage stage)
plots time series header
Definition: spring_damper.cc:360
bool gActiveChanged()
Definition: spring_damper.h:59
void setGeneralizedForceFunction(Function< double(double, double)> *func_)
Set the function for the generalized force.
Definition: spring_damper.h:186
void connect(Frame *frame1, Frame *frame2)
Connect the SpringDamper to frame1 and frame2.
Definition: spring_damper.cc:203
std::string getType() const
Definition: spring_damper.h:182
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: spring_damper.h:101
void setForceDirection(const fmatvec::Vec3 &dir)
Definition: spring_damper.h:143
void init(InitStage stage)
plots time series header
Definition: spring_damper.cc:208
void plot(double t, double dt=1)
plots time dependent data
Definition: spring_damper.cc:249
Definition: spring_damper.h:165
void setForceFunction(Function< double(double, double)> *func_)
Set function for the force calculation. The first input parameter to that function is the distance g ...
Definition: spring_damper.h:134
virtual bool isSingleValued() const
asks the link if it contains single valued force laws that contribute to the right-hand side vector h...
Definition: spring_damper.h:181
void plot(double t, double dt=1)
plots time dependent data
Definition: spring_damper.cc:112
void setForceFunction(Function< double(double, double)> *func_)
Set function for the force calculation. The first input parameter to that function is the distance g ...
Definition: spring_damper.h:70
bool isActive() const
Definition: spring_damper.h:179
bool isActive() const
Definition: spring_damper.h:122
void updatehRef(const fmatvec::Vec &hParent, int j=0)
references to complete and link smooth force vector of dynamic system parent
Definition: spring_damper.cc:317
void plot(double t, double dt=1)
plots time dependent data
Definition: spring_damper.cc:403
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: spring_damper.h:124
void connect(Frame *frame1, Frame *frame2)
Connect the SpringDamper to frame1 and frame2.
Definition: spring_damper.cc:74
std::string name
name of element
Definition: element.h:290
bool isActive() const
Definition: spring_damper.h:58
cartesian frame on bodies used for application of e.g. links and loads
Definition: frame.h:39
std::string getType() const
Definition: spring_damper.h:61
general link to one or more objects
Definition: link_mechanics.h:48
bool isSingleValued() const
asks the link if it contains single valued force laws that contribute to the right-hand side vector h...
Definition: spring_damper.h:60
void init(InitStage stage)
plots time series header
Definition: spring_damper.cc:79
bool gActiveChanged()
Definition: spring_damper.h:180
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: spring_damper.h:39
rigid bodies with arbitrary kinematics
Definition: rigid_body.h:53