00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef _FRICTION_H_
00020 #define _FRICTION_H_
00021
00022 #include "mbsim/link_mechanics.h"
00023 #include <mbsim/frame.h>
00024 #include "mbsim/functions/function.h"
00025
00026 #ifdef HAVE_OPENMBVCPPINTERFACE
00027 #include "mbsim/utils/boost_parameters.h"
00028 #include "mbsim/utils/openmbv_utils.h"
00029 #endif
00030
00031 namespace MBSim {
00032
00033 class RigidBody;
00034 class FrictionForceLaw;
00035
00036 class GeneralizedFriction : public LinkMechanics {
00037 protected:
00038
00039 FrictionForceLaw *func;
00040 Function<double(double)> *laN;
00041 std::vector<RigidBody*> body;
00042 public:
00043 GeneralizedFriction(const std::string &name="");
00044 ~GeneralizedFriction();
00045 void updateh(double, int i=0);
00046 void updateg(double) { }
00047 void updategd(double);
00048
00049 bool isActive() const { return true; }
00050 bool gActiveChanged() { return false; }
00051 virtual bool isSingleValued() const { return true; }
00052 std::string getType() const { return "GeneralizedFriction"; }
00053 void init(InitStage stage);
00054
00056
00057 void setGeneralizedFrictionForceLaw(FrictionForceLaw *func_);
00058 void setGeneralizedNormalForceFunction(Function<double(double)> *laN_) {
00059 laN = laN_;
00060 laN->setParent(this);
00061 }
00062
00063 void setRigidBodyFirstSide(RigidBody* body_) { body[0] = body_; }
00064 void setRigidBodySecondSide(RigidBody* body_) { body[1] = body_; }
00065
00066 void plot(double t, double dt=1);
00067 void initializeUsingXML(xercesc::DOMElement *element);
00068
00069 void updatehRef(const fmatvec::Vec &hParent, int j=0);
00070
00071 #ifdef HAVE_OPENMBVCPPINTERFACE
00072
00073 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))) {
00074 OpenMBVArrow ombv(diffuseColor,transparency,OpenMBV::Arrow::toHead,referencePoint,scaleLength,scaleSize);
00075 std::vector<bool> which; which.resize(2, true);
00076 LinkMechanics::setOpenMBVForceArrow(ombv.createOpenMBV(), which);
00077 }
00078
00080 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))) {
00081 OpenMBVArrow ombv(diffuseColor,transparency,OpenMBV::Arrow::toDoubleHead,referencePoint,scaleLength,scaleSize);
00082 std::vector<bool> which; which.resize(2, true);
00083 LinkMechanics::setOpenMBVMomentArrow(ombv.createOpenMBV(), which);
00084 }
00085 #endif
00086 private:
00087 std::string saved_body1, saved_body2;
00088 };
00089
00090 }
00091
00092 #endif
00093