|
mbsimpowertrain
4.0.0
|
00001 /* Copyright (C) 2004-2009 MBSim Development Team 00002 * This library is free software; you can redistribute it and/or 00003 * modify it under the terms of the GNU Lesser General Public 00004 * License as published by the Free Software Foundation; either 00005 * version 2.1 of the License, or (at your option) any later version. 00006 * 00007 * This library is distributed in the hope that it will be useful, 00008 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00009 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00010 * Lesser General Public License for more details. 00011 * 00012 * You should have received a copy of the GNU Lesser General Public 00013 * License along with this library; if not, write to the Free Software 00014 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00015 * 00016 * Contact: martin.o.foerg@googlemail.com 00017 */ 00018 00019 #ifndef _TORSIONAL_STIFFNESS_H_ 00020 #define _TORSIONAL_STIFFNESS_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 class RigidBody; 00033 } 00034 00035 namespace MBSimPowertrain { 00036 00037 const MBXMLUtils::NamespaceURI MBSIMPOWERTRAIN("http://mbsim.berlios.de/MBSimPowertrain"); 00038 00039 class TorsionalStiffness : public MBSim::LinkMechanics { 00040 protected: 00041 fmatvec::Function<double(double,double)> *func; 00042 std::vector<MBSim::RigidBody*> body; 00043 MBSim::Frame C; 00044 #ifdef HAVE_OPENMBVCPPINTERFACE 00045 OpenMBV::CoilSpring *coilspringOpenMBV; 00046 #endif 00047 public: 00048 TorsionalStiffness(const std::string &name=""); 00049 void updateh(double, int i=0); 00050 void updateg(double); 00051 void updategd(double); 00052 00054 //void connect(Frame *frame1, Frame* frame2); 00055 00056 bool isActive() const { return true; } 00057 bool gActiveChanged() { return false; } 00058 virtual bool isSingleValued() const { return true; } 00059 std::string getType() const { return "RotationalSpringDamper"; } 00060 void init(InitStage stage); 00061 00067 void setGeneralizedForceFunction(fmatvec::Function<double(double,double)> *func_) { func=func_; } 00068 00076 void setRigidBodyFirstSide(MBSim::RigidBody* body_) { body[0] = body_; } 00077 void setRigidBodySecondSide(MBSim::RigidBody* body_) { body[1] = body_; } 00078 00079 void plot(double t, double dt=1); 00080 void initializeUsingXML(xercesc::DOMElement *element); 00081 00082 void updatehRef(const fmatvec::Vec &hParent, int j=0); 00083 00084 #ifdef HAVE_OPENMBVCPPINTERFACE 00085 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))) { 00086 MBSim::OpenMBVCoilSpring ombv(springRadius,crossSectionRadius,1,numberOfCoils,nominalLength,type,diffuseColor,transparency); 00087 coilspringOpenMBV=ombv.createOpenMBV(); 00088 } 00089 00091 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))) { 00092 MBSim::OpenMBVArrow ombv(diffuseColor,transparency,OpenMBV::Arrow::toHead,referencePoint,scaleLength,scaleSize); 00093 std::vector<bool> which; which.resize(2, true); 00094 LinkMechanics::setOpenMBVForceArrow(ombv.createOpenMBV(), which); 00095 } 00096 00098 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))) { 00099 MBSim::OpenMBVArrow ombv(diffuseColor,transparency,OpenMBV::Arrow::toDoubleHead,referencePoint,scaleLength,scaleSize); 00100 std::vector<bool> which; which.resize(2, true); 00101 LinkMechanics::setOpenMBVMomentArrow(ombv.createOpenMBV(), which); 00102 } 00103 #endif 00104 private: 00105 std::string saved_body1, saved_body2; 00106 }; 00107 00108 } 00109 00110 #endif 00111
1.8.0