MBSim

Project Page
gear.h
1 /* Copyright (C) 2004-2011 MBSim Development Team
2  *
3  * This library is free software; you can redistribute it and/or
4  * modify it under the terms of the GNU Lesser General Public
5  * License as published by the Free Software Foundation; either
6  * version 2.1 of the License, or (at your option) any later version.
7  *
8  * This library is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  * Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public
14  * License along with this library; if not, write to the Free Software
15  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16  *
17  * Contact: martin.o.foerg@gmail.com
18  */
19 
20 #ifndef _GEAR_H_
21 #define _GEAR_H_
22 
23 #include "mbsim/link_mechanics.h"
24 #include "mbsim/rigid_body.h"
25 
26 namespace MBSim {
27 
28  class Gear : public LinkMechanics {
29  protected:
31  std::vector<RigidBody*> body;
32  std::vector<double> ratio[2];
34  public:
35  Gear(const std::string &name);
36  void updateh(double, int i=0);
37  void updateW(double, int i=0);
38  void updateg(double);
39  void updategd(double);
40  void updatewb(double t, int i=0);
41  void updatehRef(const fmatvec::Vec &hParent, int j=0);
42  void updateWRef(const fmatvec::Mat &WParent, int j=0);
43  void setDependentBody(RigidBody* body_) {body[0] = body_;}
44  void addDependency(RigidBody* body_, double ratio1, double ratio2=0);
45  void connect(Frame* frame_) {frame = frame_;}
46  // {LinkMechanics::connect(frame);}
47 
48  bool isActive() const { return true; }
49  bool gActiveChanged() { return false; }
50  std::string getType() const { return "Gear"; }
51  void init(InitStage stage);
52  bool isSetValued() const;
53  virtual void calclaSize();
54  virtual void calcgSize();
55  virtual void calcgdSize();
56 
57  void setForceFunction(Function2<double,double,double> *func_) { func=func_; }
58 
59  void plot(double t, double dt=1);
60 
61  private:
62  };
63 
64 }
65 
66 #endif