MBSim

Project Page
gearing.h
00001 /* Copyright (C) 2004-2011 MBSim Development Team
00002  *
00003  * This library is free software; you can redistribute it and/or 
00004  * modify it under the terms of the GNU Lesser General Public 
00005  * License as published by the Free Software Foundation; either 
00006  * version 2.1 of the License, or (at your option) any later version. 
00007  *  
00008  * This library is distributed in the hope that it will be useful, 
00009  * but WITHOUT ANY WARRANTY; without even the implied warranty of 
00010  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
00011  * Lesser General Public License for more details. 
00012  *  
00013  * You should have received a copy of the GNU Lesser General Public 
00014  * License along with this library; if not, write to the Free Software 
00015  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
00016  *
00017  * Contact: martin.o.foerg@gmail.com
00018  */
00019 
00020 #ifndef _GEARING_H_
00021 #define _GEARING_H_
00022 
00023 #include "mbsim/link_mechanics.h"
00024 #include "mbsim/rigid_body.h"
00025 #include "mbsim/frame.h"
00026 
00027 namespace MBSim {
00028 
00029   class Gearing : public LinkMechanics {
00030     protected:
00031       Function<double(double,double)> *func;
00032       double r0, r1;
00033       bool reverse;
00034       Frame Z0, Z1;
00035       Frame *P0, *P1;
00036       fmatvec::Vec3 WrP0Z, WrP1Z;
00037       fmatvec::Vec3 Wt;
00038     public:
00039       Gearing(const std::string &name);
00040       void updateh(double, int i=0);
00041       void updateW(double, int i=0);
00042       void updateJacobians(double t, int j=0);
00043       void updateg(double);
00044       void updategd(double);
00045       void updatewb(double t, int i=0);
00046       void updatehRef(const fmatvec::Vec &hParent, int j=0);
00047       void updateWRef(const fmatvec::Mat &WParent, int j=0);
00048       void connect(double r1, Frame* frame1_, double r2, Frame* frame2_);
00049       virtual void updatexd(double t);
00050       virtual void updatedx(double t, double dt);
00051       virtual void calcxSize();
00052 
00053       bool isActive() const { return true; }
00054       bool gActiveChanged() { return false; }
00055       std::string getType() const { return "Gearing"; }
00056       void init(InitStage stage);
00057       bool isSetValued() const;
00058       virtual void calclaSize(int j);
00059       virtual void calcgSize(int j);
00060       virtual void calcgdSize(int j);
00061 
00062       void setForceFunction(Function<double(double,double)> *func_) {
00063         func=func_;
00064         func->setParent(this);
00065         func->setName("Force");
00066       }
00067       void setReverse(bool reverse_) { reverse = reverse_; }
00068 
00069       void plot(double t, double dt=1);
00070 
00071     private:
00072   };
00073 
00074 }
00075 
00076 #endif