All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
kinematic_excitation.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 _KINEMATIC_EXCITATION_H_
21 #define _KINEMATIC_EXCITATION_H_
22 
23 #include "mbsim/link_mechanics.h"
24 #include "mbsim/rigid_body.h"
25 #include "mbsim/frame.h"
26 
27 #ifdef HAVE_OPENMBVCPPINTERFACE
28 #include "mbsim/utils/boost_parameters.h"
29 #include "mbsim/utils/openmbv_utils.h"
30 #endif
31 
32 namespace MBSim {
33 
35  protected:
36  Function<fmatvec::VecV(fmatvec::VecV,fmatvec::VecV)> *func;
37  RigidBody* body;
38  Frame C;
39  public:
40  KinematicExcitation(const std::string &name);
41  void updateh(double, int i=0);
42  void updateW(double, int i=0);
43  void updateJacobians(double t, int j=0);
44  void updatehRef(const fmatvec::Vec &hParent, int j=0);
45  void updateWRef(const fmatvec::Mat &WParent, int j=0);
46  void setDependentBody(RigidBody* body_) {body = body_;}
47 
48  bool isActive() const { return true; }
49  bool gActiveChanged() { return false; }
50  void init(InitStage stage);
51  bool isSetValued() const;
52  void calclaSize(int j);
53  void calcgSize(int j);
54  void calcgdSize(int j);
55 
56  void setForceFunction(Function<fmatvec::VecV(fmatvec::VecV,fmatvec::VecV)> *func_) {
57  func=func_;
58  func->setParent(this);
59  func->setName("Force");
60  }
61 
62  void plot(double t, double dt=1);
63 
64 #ifdef HAVE_OPENMBVCPPINTERFACE
65 
66  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))) {
67  OpenMBVArrow ombv(diffuseColor,transparency,OpenMBV::Arrow::toHead,referencePoint,scaleLength,scaleSize);
68  FArrow=ombv.createOpenMBV();
69  }
70  void setOpenMBVForce(const boost::shared_ptr<OpenMBV::Arrow> &arrow) { FArrow=arrow; }
71 
73  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))) {
74  OpenMBVArrow ombv(diffuseColor,transparency,OpenMBV::Arrow::toHead,referencePoint,scaleLength,scaleSize);
75  MArrow=ombv.createOpenMBV();
76  }
77  void setOpenMBVMoment(const boost::shared_ptr<OpenMBV::Arrow> &arrow) { MArrow=arrow; }
78 #endif
79 
80  protected:
81 #ifdef HAVE_OPENMBVCPPINTERFACE
82  boost::shared_ptr<OpenMBV::Arrow> FArrow, MArrow;
83 #endif
84 
85  };
86 
88  protected:
89  Function<fmatvec::VecV(double)> *f;
90  public:
91  GeneralizedPositionExcitation(const std::string &name) : KinematicExcitation(name) {}
92 
93  void calcxSize();
94 
95  void updatexd(double t);
96  void updateg(double t);
97  void updategd(double t);
98  void updatewb(double t, int i=0);
99 
100  std::string getType() const { return "GeneralizedPositionExcitation"; }
101 
102  void setExcitationFunction(Function<fmatvec::VecV(double)>* f_) {
103  f = f_;
104  f->setParent(this);
105  f->setName("Excitation");
106  }
107 
108  void init(Element::InitStage stage) {
110  f->init(stage);
111  }
112  };
113 
115  protected:
116  Function<fmatvec::VecV(fmatvec::VecV,double)> *f;
117  public:
118  GeneralizedVelocityExcitation(const std::string &name) : KinematicExcitation(name) {}
119 
120  void calcxSize();
121 
122  void updatexd(double t);
123  void updateg(double t);
124  void updategd(double t);
125  void updatewb(double t, int i=0);
126 
127  std::string getType() const { return "GeneralizedVelocityExcitation"; }
128 
129  void setExcitationFunction(Function<fmatvec::VecV(fmatvec::VecV,double)>* f_) {
130  f = f_;
131  f->setParent(this);
132  f->setName("Excitation");
133  }
134  void setExcitationFunction(Function<fmatvec::VecV(fmatvec::VecV)>* f_) {
135  setExcitationFunction(new StateDependentFunction<fmatvec::VecV>(f_));
136  }
137  void setExcitationFunction(Function<fmatvec::VecV(double)>* f_) {
138  setExcitationFunction(new TimeDependentFunction<fmatvec::VecV>(f_));
139  }
140  };
141 
143  protected:
144  Function<fmatvec::VecV(fmatvec::VecV,double)> *f;
145  public:
146  GeneralizedAccelerationExcitation(const std::string &name) : KinematicExcitation(name) {}
147 
148  void calcxSize();
149 
150  void updatexd(double t);
151  void updateg(double t);
152  void updategd(double t);
153  void updatewb(double t, int i=0);
154 
155  std::string getType() const { return "GeneralizedAccelerationExcitation"; }
156 
157  void setExcitationFunction(Function<fmatvec::VecV(fmatvec::VecV,double)>* f_) {
158  f = f_;
159  f->setParent(this);
160  f->setName("Excitation");
161  }
162  void setExcitationFunction(Function<fmatvec::VecV(fmatvec::VecV)>* f_) {
163  setExcitationFunction(new StateDependentFunction<fmatvec::VecV>(f_));
164  }
165  void setExcitationFunction(Function<fmatvec::VecV(double)>* f_) {
166  setExcitationFunction(new TimeDependentFunction<fmatvec::VecV>(f_));
167  }
168 
169  void init(Element::InitStage stage) {
171  f->init(stage);
172  }
173  };
174 
175 }
176 
177 #endif
std::string getType() const
Definition: kinematic_excitation.h:127
Definition: kinematic_excitation.h:87
void plot(double t, double dt=1)
plots time dependent data
Definition: kinematic_excitation.cc:145
Definition: kinematic_excitation.h:142
void init(Element::InitStage stage)
plots time series header
Definition: kinematic_excitation.h:169
bool isSetValued() const
asks the link if it contains force laws that contribute to the lagrange multiplier and is therefore s...
Definition: kinematic_excitation.cc:93
void calclaSize(int j)
calculates size of contact force parameters
Definition: kinematic_excitation.cc:34
void init(Element::InitStage stage)
plots time series header
Definition: kinematic_excitation.h:108
InitStage
The stages of the initialization.
Definition: element.h:97
Definition: kinematic_excitation.h:34
void calcgSize(int j)
calculates size of relative distances
Definition: kinematic_excitation.cc:37
std::string name
name of element
Definition: element.h:290
bool isActive() const
Definition: kinematic_excitation.h:48
Definition: kinematic_excitation.h:114
void init(InitStage stage)
plots time series header
Definition: kinematic_excitation.cc:97
cartesian frame on bodies used for application of e.g. links and loads
Definition: frame.h:39
general link to one or more objects
Definition: link_mechanics.h:48
void updatehRef(const fmatvec::Vec &hParent, int j=0)
references to complete and link smooth force vector of dynamic system parent
Definition: kinematic_excitation.cc:72
void updateWRef(const fmatvec::Mat &WParent, int j=0)
references to contact force direction matrix of dynamic system parent
Definition: kinematic_excitation.cc:63
bool gActiveChanged()
Definition: kinematic_excitation.h:49
std::string getType() const
Definition: kinematic_excitation.h:155
std::string getType() const
Definition: kinematic_excitation.h:100
rigid bodies with arbitrary kinematics
Definition: rigid_body.h:53
void calcgdSize(int j)
calculates size of gap velocities
Definition: kinematic_excitation.cc:40

Impressum / Disclaimer / Datenschutz Generated by doxygen 1.8.5 Valid HTML