|
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 "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 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 MBSim::Function<double(double,double)> *func; 00042 std::vector<MBSim::RigidBody*> body; 00043 MBSim::Frame C; 00044 #ifdef HAVE_OPENMBVCPPINTERFACE 00045 boost::shared_ptr<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 MBSim::LinkMechanics::init(stage); 00062 func->init(stage); 00063 } 00064 00070 void setGeneralizedForceFunction(MBSim::Function<double(double,double)> *func_) { 00071 func=func_; 00072 func->setParent(this); 00073 func->setName("GeneralizedForce"); 00074 } 00075 00083 void setRigidBodyFirstSide(MBSim::RigidBody* body_) { body[0] = body_; } 00084 void setRigidBodySecondSide(MBSim::RigidBody* body_) { body[1] = body_; } 00085 00086 void plot(double t, double dt=1); 00087 void initializeUsingXML(xercesc::DOMElement *element); 00088 00089 void updatehRef(const fmatvec::Vec &hParent, int j=0); 00090 00091 #ifdef HAVE_OPENMBVCPPINTERFACE 00092 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))) { 00093 MBSim::OpenMBVCoilSpring ombv(springRadius,crossSectionRadius,1,numberOfCoils,nominalLength,type,diffuseColor,transparency); 00094 coilspringOpenMBV=ombv.createOpenMBV(); 00095 } 00096 00098 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))) { 00099 MBSim::OpenMBVArrow ombv(diffuseColor,transparency,OpenMBV::Arrow::toHead,referencePoint,scaleLength,scaleSize); 00100 std::vector<bool> which; which.resize(2, true); 00101 LinkMechanics::setOpenMBVForceArrow(ombv.createOpenMBV(), which); 00102 } 00103 00105 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))) { 00106 MBSim::OpenMBVArrow ombv(diffuseColor,transparency,OpenMBV::Arrow::toDoubleHead,referencePoint,scaleLength,scaleSize); 00107 std::vector<bool> which; which.resize(2, true); 00108 LinkMechanics::setOpenMBVMomentArrow(ombv.createOpenMBV(), which); 00109 } 00110 #endif 00111 private: 00112 std::string saved_body1, saved_body2; 00113 }; 00114 00115 } 00116 00117 #endif 00118
1.8.0