All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
gear.h
1 /* Copyright (C) 2004-2015 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 #ifdef HAVE_OPENMBVCPPINTERFACE
27 #include "mbsim/utils/boost_parameters.h"
28 #include "mbsim/utils/openmbv_utils.h"
29 #endif
30 
31 namespace MBSim {
32 
33  class Transmission;
34 
35  class Gear : public LinkMechanics {
36  protected:
37  Function<double(double,double)> *func;
38  std::vector<RigidBody*> body;
39  std::vector<double> ratio;
40  std::vector<Frame> C;
41  std::string saved_DependentBody;
42  std::vector<std::string> saved_IndependentBody;
43  public:
44  Gear(const std::string &name="");
45  void updateh(double, int i=0);
46  void updateW(double, int i=0);
47  void updateg(double);
48  void updategd(double);
49  void updateJacobians(double t, int j=0);
50  void updatewb(double t, int i=0);
51  void updatehRef(const fmatvec::Vec &hParent, int j=0);
52  void updateWRef(const fmatvec::Mat &WParent, int j=0);
53  void setDependentBody(RigidBody* body_) {body[0] = body_;}
54  void addTransmission(const Transmission &transmission);
55 
56  bool isActive() const { return true; }
57  bool gActiveChanged() { return false; }
58  std::string getType() const { return "Gear"; }
59  void init(InitStage stage);
60  bool isSetValued() const;
61  bool isSingleValued() const { return not(isSetValued()); }
62  virtual void calclaSize(int j);
63  virtual void calcgSize(int j);
64  virtual void calcgdSize(int j);
65 
66  void setGeneralizedForceFunction(Function<double(double,double)> *func_) {
67  func=func_;
68  func->setParent(this);
69  func->setName("GeneralizedForce");
70  }
71 
72  void plot(double t, double dt=1);
73 
74  void initializeUsingXML(xercesc::DOMElement * element);
75 
76 #ifdef HAVE_OPENMBVCPPINTERFACE
77 
78  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))) {
79  OpenMBVArrow ombv(diffuseColor,transparency,OpenMBV::Arrow::toHead,referencePoint,scaleLength,scaleSize);
80  setOpenMBVForce(ombv.createOpenMBV());
81  }
82  void setOpenMBVForce(const boost::shared_ptr<OpenMBV::Arrow> &arrow) { FArrow[0]=arrow; }
83 
85  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))) {
86  OpenMBVArrow ombv(diffuseColor,transparency,OpenMBV::Arrow::toHead,referencePoint,scaleLength,scaleSize);
87  setOpenMBVMoment(ombv.createOpenMBV());
88  }
89  void setOpenMBVMoment(const boost::shared_ptr<OpenMBV::Arrow> &arrow) { MArrow[0]=arrow; }
90 #endif
91 
92  protected:
93 #ifdef HAVE_OPENMBVCPPINTERFACE
94  std::vector<boost::shared_ptr<OpenMBV::Arrow> > FArrow, MArrow;
95 #endif
96 
97  };
98 
99 }
100 
101 #endif
void plot(double t, double dt=1)
plots time dependent data
Definition: gear.cc:229
Definition: gear.h:35
virtual void calcgSize(int j)
calculates size of relative distances
Definition: gear.cc:50
bool gActiveChanged()
Definition: gear.h:57
Definition: constraint.h:49
std::string getType() const
Definition: gear.h:58
void updatehRef(const fmatvec::Vec &hParent, int j=0)
references to complete and link smooth force vector of dynamic system parent
Definition: gear.cc:104
void init(InitStage stage)
plots time series header
Definition: gear.cc:151
bool isActive() const
Definition: gear.h:56
virtual void calclaSize(int j)
calculates size of contact force parameters
Definition: gear.cc:47
InitStage
The stages of the initialization.
Definition: element.h:97
void updateWRef(const fmatvec::Mat &WParent, int j=0)
references to contact force direction matrix of dynamic system parent
Definition: gear.cc:93
std::string name
name of element
Definition: element.h:290
general link to one or more objects
Definition: link_mechanics.h:48
bool isSingleValued() const
asks the link if it contains single valued force laws that contribute to the right-hand side vector h...
Definition: gear.h:61
bool isSetValued() const
asks the link if it contains force laws that contribute to the lagrange multiplier and is therefore s...
Definition: gear.cc:142
virtual void calcgdSize(int j)
calculates size of gap velocities
Definition: gear.cc:53
rigid bodies with arbitrary kinematics
Definition: rigid_body.h:53

Impressum / Disclaimer / Datenschutz Generated by doxygen 1.8.5 Valid HTML