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 "fmatvec/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 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_) { func = func_; }
00058 void setGeneralizedNormalForce(double laN_) { laN = laN_; }
00059
00060 void setRigidBodyFirstSide(RigidBody* body_) { body[0] = body_; }
00061 void setRigidBodySecondSide(RigidBody* body_) { body[1] = body_; }
00062
00063 void plot(double t, double dt=1);
00064 void initializeUsingXML(xercesc::DOMElement *element);
00065
00066 void updatehRef(const fmatvec::Vec &hParent, int j=0);
00067
00068 #ifdef HAVE_OPENMBVCPPINTERFACE
00069
00070 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))) {
00071 OpenMBVArrow ombv(diffuseColor,transparency,OpenMBV::Arrow::toHead,referencePoint,scaleLength,scaleSize);
00072 std::vector<bool> which; which.resize(2, true);
00073 LinkMechanics::setOpenMBVForceArrow(ombv.createOpenMBV(), which);
00074 }
00075
00077 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))) {
00078 OpenMBVArrow ombv(diffuseColor,transparency,OpenMBV::Arrow::toDoubleHead,referencePoint,scaleLength,scaleSize);
00079 std::vector<bool> which; which.resize(2, true);
00080 LinkMechanics::setOpenMBVMomentArrow(ombv.createOpenMBV(), which);
00081 }
00082 #endif
00083 private:
00084 std::string saved_body1, saved_body2;
00085 };
00086
00087 }
00088
00089 #endif
00090