mbsimphysics  4.0.0
MBSim Physics Module
weight.h
1 /* Copyright (C) 2004-2018 MBSim Development Team
2  * This library is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU Lesser General Public
4  * License as published by the Free Software Foundation; either
5  * version 2.1 of the License, or (at your option) any later version.
6  *
7  * This library is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10  * Lesser General Public License for more details.
11  *
12  * You should have received a copy of the GNU Lesser General Public
13  * License along with this library; if not, write to the Free Software
14  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15  *
16  * Contact: martin.o.foerg@googlemail.com
17  */
18 
19 #ifndef _WEIGHT_H
20 #define _WEIGHT_H
21 
22 #include "mbsim/links/mechanical_link.h"
23 #include "mbsim/frames/floating_relative_frame.h"
24 
25 #include "mbsim/utils/boost_parameters.h"
26 #include "mbsim/utils/openmbv_utils.h"
27 
28 namespace MBSim {
29  class RigidBody;
30  class Frame;
31  template <class Sig> class Function;
32 }
33 
34 namespace MBSimPhysics {
35 
36  class Weight : public MBSim::MechanicalLink {
37  public:
38  Weight(const std::string &name="");
39  ~Weight() override;
40  void resetUpToDate() override;
41  void init(InitStage stage, const MBSim::InitConfigSet &config) override;
42  void initializeUsingXML(xercesc::DOMElement *element) override;
43 
44  void connect(MBSim::RigidBody *body_) { body = body_; }
45  void connect(MBSim::Frame* frame_, MBSim::RigidBody *body_);
46 
47  void plot() override;
48 
49  void setGravityFunction(MBSim::Function<double(double)> *func);
50 
51  void updatePositions(MBSim::Frame *frame) override;
52  void updateGeneralizedPositions() override;
53  void updatePositions() override;
54  void updatelaF();
55  void updateForce() override;
56  void updateh(int i=0) override;
57 
58  const fmatvec::Vec3& evalGlobalRelativePosition() { if(updPos) updatePositions(); return WrP0P1; }
59 
60  bool isActive() const override { return true; }
61  bool gActiveChanged() override { return false; }
62  bool isSingleValued() const override { return true; }
63 
64  void updateWRef(fmatvec::Mat& ref, int i=0) override { }
65  void updateVRef(fmatvec::Mat& ref, int i=0) override { }
66  void updatehRef(fmatvec::Vec &hRef, int i=0) override;
67  virtual void updatedhdqRef(fmatvec::Mat& ref, int i=0);
68  virtual void updatedhduRef(fmatvec::SqrMat& ref, int i=0);
69  virtual void updatedhdtRef(fmatvec::Vec& ref, int i=0);
70  void updaterRef(fmatvec::Vec &ref, int i=0) override { }
71 
72  BOOST_PARAMETER_MEMBER_FUNCTION( (void), enableOpenMBV, MBSim::tag, (optional (sideOfInteraction,(MBSim::OpenMBVInteractionArrow::SideOfInteraction),MBSim::OpenMBVInteractionArrow::action)(scaleLength,(double),1)(scaleSize,(double),1)(referencePoint,(MBSim::OpenMBVArrow::ReferencePoint),MBSim::OpenMBVArrow::toPoint)(colorRepresentation,(MBSim::OpenMBVArrow::ColorRepresentation),MBSim::OpenMBVArrow::none)(minimalColorValue,(double),0)(maximalColorValue,(double),1)(diffuseColor,(const fmatvec::Vec3&),"[-1;1;1]")(transparency,(double),0)(pointSize,(double),0)(lineWidth,(double),0))) {
73  ombvArrow = std::shared_ptr<MBSim::OpenMBVInteractionArrow>(new MBSim::OpenMBVInteractionArrow(sideOfInteraction,scaleLength,scaleSize,MBSim::OpenMBVArrow::toHead,referencePoint,colorRepresentation,minimalColorValue,maximalColorValue,diffuseColor,transparency,pointSize,lineWidth));
74  }
75 
76  protected:
77  MBSim::RigidBody* body{nullptr};
78  MBSim::Frame* frame{nullptr};
79  MBSim::Function<double(double)> *fg{nullptr};
80  fmatvec::Vec3 WrP0P1;
81  bool updPos;
82 
84 
86  std::vector<std::shared_ptr<OpenMBV::Arrow>> openMBVForce;
87 
88  private:
89  std::string saved_ref1, saved_ref2;
90  };
91 
92 }
93 
94 #endif
Definition: weight.h:36
Definition: aerodynamics.h:29
std::string name