mbsimcontrol  4.0.0
MBSim Control Module
frame_chaser_observer.h
1 /* Copyright (C) 2004-2017 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 _MBSIMCONTROl_FRAME_CHASER_OBSERVER_H__
21 #define _MBSIMCONTROl_FRAME_CHASER_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 <variant>
28 
29 namespace MBSim {
30  class Frame;
31 }
32 
33 namespace MBSimControl {
34 
35  class Signal;
36 
38  protected:
39  MBSim::Frame* frame { nullptr };
40 
41  std::string saved_frame;
42  std::string saved_signalX, saved_signalY, saved_signalZ;
43  std::string saved_signalRotationX, saved_signalRotationY, saved_signalRotationZ;
44 
45  std::shared_ptr<MBSim::OpenMBVFrame> ombvFrame;
46  std::shared_ptr<OpenMBV::Frame> openMBVFrame;
47 
48  // overrite a component of the frame observer with a double or value from a Signal
49  std::variant<std::monostate, double, Signal*> x;
50  std::variant<std::monostate, double, Signal*> y;
51  std::variant<std::monostate, double, Signal*> z;
52  std::variant<std::monostate, double, Signal*> rotX;
53  std::variant<std::monostate, double, Signal*> rotY;
54  std::variant<std::monostate, double, Signal*> rotZ;
55 
56  public:
57  FrameChaserObserver(const std::string &name="");
58  void setFrame(MBSim::Frame *frame_) { frame = frame_; }
59 
60  void setConstantX(double x_) { x=x_; }
61  void setConstantY(double y_) { y=y_; }
62  void setConstantZ(double z_) { z=z_; }
63  void setConstantRotationX(double angle) { rotX=angle; }
64  void setConstantRotationY(double angle) { rotY=angle; }
65  void setConstantRotationZ(double angle) { rotZ=angle; }
66  void setSignalX(Signal* x_) { x=x_; }
67  void setSignalY(Signal* y_) { y=y_; }
68  void setSignalZ(Signal* z_) { z=z_; }
69  void setSignalRotationX(Signal* angle) { rotX=angle; }
70  void setSignalRotationY(Signal* angle) { rotY=angle; }
71  void setSignalRotationZ(Signal* angle) { rotZ=angle; }
72  void unsetX() { x=std::monostate(); }
73  void unsetY() { y=std::monostate(); }
74  void unsetZ() { z=std::monostate(); }
75  void unsetRotationX() { x=std::monostate(); }
76  void unsetRotationY() { y=std::monostate(); }
77  void unsetRotationZ() { z=std::monostate(); }
78 
79  void init(InitStage stage, const MBSim::InitConfigSet &config);
80  void plot();
81  void initializeUsingXML(xercesc::DOMElement *element);
82 
83  BOOST_PARAMETER_MEMBER_FUNCTION( (void), enableOpenMBV, MBSim::tag, (optional (size,(double),1)(offset,(double),1)
84  (transparency,(double),0)(pointSize,(double),0)(lineWidth,(double),0))) {
85  ombvFrame = std::shared_ptr<MBSim::OpenMBVFrame>(new MBSim::OpenMBVFrame(size, offset, fmatvec::Vec3({-1,1,1}),
86  transparency, pointSize, lineWidth));
87  }
88  };
89 
90 }
91 
92 #endif
Signal.
Definition: signal_.h:38
Definition: frame_chaser_observer.h:37
std::string name