mbsim 4.0.0 MBSim Kernel

mechanical_link_observer.h
1 /* Copyright (C) 2004-2016 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 _MECHANICAL_LINK_OBSERVER_H__
21 #define _MECHANICAL_LINK_OBSERVER_H__
22
23 #include "mbsim/observers/observer.h"
24
25 #include <mbsim/utils/boost_parameters.h>
26 #include <mbsim/utils/openmbv_utils.h>
27 #include <mbsim/utils/index.h>
28
29 namespace MBSim {
30
31 class MechanicalLink;
32
33 class MechanicalLinkObserver : public Observer {
34 protected:
35 MechanicalLink* link;
36 std::string saved_link;
37 std::shared_ptr<OpenMBVInteractionArrow> ombvForce, ombvMoment;
38 std::vector<std::shared_ptr<OpenMBV::Arrow>> openMBVForce, openMBVMoment;
39 #ifndef SWIG
40 double (MechanicalLinkObserver::*evalOMBVForceColorRepresentation[2])();
41 double (MechanicalLinkObserver::*evalOMBVMomentColorRepresentation[2])();
42 #endif
43 double evalNone() { return 1; }
44 double evalAbsoluteForce();
45 double evalAbsoluteMoment();
46 Frame *outputFrame { nullptr };
47
48 public:
49 MechanicalLinkObserver(const std::string &name="");
50 void setMechanicalLink(MechanicalLink *link_) { link = link_; }
51 void setOutputFrame(Frame *outputFrame_) { outputFrame = outputFrame_; }
52
53 void init(InitStage stage, const InitConfigSet &config) override;
54 void plot() override;
55 void initializeUsingXML(xercesc::DOMElement *element) override;
56
57 BOOST_PARAMETER_MEMBER_FUNCTION( (void), enableOpenMBVForce, tag, (optional (sideOfInteraction,(OpenMBVInteractionArrow::SideOfInteraction),OpenMBVInteractionArrow::action)(scaleLength,(double),1)(scaleSize,(double),1)(referencePoint,(OpenMBVArrow::ReferencePoint),OpenMBVArrow::toPoint)(colorRepresentation,(OpenMBVArrow::ColorRepresentation),OpenMBVArrow::none)(minimalColorValue,(double),0)(maximalColorValue,(double),1)(diffuseColor,(const fmatvec::Vec3&),fmatvec::Vec3(std::vector<double>{-1,1,1}))(transparency,(double),0)(pointSize,(double),0)(lineWidth,(double),0))) {
58 ombvForce = std::shared_ptr<OpenMBVInteractionArrow>(new OpenMBVInteractionArrow(sideOfInteraction,scaleLength,scaleSize,OpenMBVArrow::toHead,referencePoint,colorRepresentation,minimalColorValue,maximalColorValue,diffuseColor,transparency,pointSize,lineWidth));
59 }
60 void setOMBVForce(const std::shared_ptr<OpenMBVInteractionArrow> &arrow) { ombvForce=arrow; }
61 BOOST_PARAMETER_MEMBER_FUNCTION( (void), enableOpenMBVMoment, tag, (optional (sideOfInteraction,(OpenMBVInteractionArrow::SideOfInteraction),OpenMBVInteractionArrow::action)(scaleLength,(double),1)(scaleSize,(double),1)(referencePoint,(OpenMBVArrow::ReferencePoint),OpenMBVArrow::toPoint)(colorRepresentation,(OpenMBVArrow::ColorRepresentation),OpenMBVArrow::none)(minimalColorValue,(double),0)(maximalColorValue,(double),1)(diffuseColor,(const fmatvec::Vec3&),fmatvec::Vec3(std::vector<double>{-1,1,1}))(transparency,(double),0)(pointSize,(double),0)(lineWidth,(double),0))) {
62 ombvMoment = std::shared_ptr<OpenMBVInteractionArrow>(new OpenMBVInteractionArrow(sideOfInteraction,scaleLength,scaleSize,OpenMBVArrow::toDoubleHead,referencePoint,colorRepresentation,minimalColorValue,maximalColorValue,diffuseColor,transparency,pointSize,lineWidth));
63 }
64 void setOMBVMoment(const std::shared_ptr<OpenMBVInteractionArrow> &arrow) { ombvMoment=arrow; }
65 private:
66 std::string saved_outputFrame;
67 };
68
69 }
70
71 #endif
MBSim::MechanicalLinkObserver
Definition: mechanical_link_observer.h:33
MBSim::MechanicalLinkObserver::plot
void plot() override
plots time dependent data
Definition: mechanical_link_observer.cc:93
MBSim::OpenMBVInteractionArrow
Definition: openmbv_utils.h:111
MBSim::MechanicalLinkObserver::init
void init(InitStage stage, const InitConfigSet &config) override
plots time series header
Definition: mechanical_link_observer.cc:44
MBSim::Element::InitStage
InitStage
The stages of the initialization.
Definition: element.h:62
MBSim::Element::name
std::string name
name of element
Definition: element.h:260
MBSim::Frame
cartesian frame on bodies used for application of e.g. links and loads
Definition: frame.h:39
MBSim::MechanicalLink
mechanical link
Definition: mechanical_link.h:33
MBSim::Observer
Definition: observer.h:26
MBSim
namespace MBSim
Definition: bilateral_constraint.cc:30