00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef _COORDINATES_OBSERVER_H__
00021 #define _COORDINATES_OBSERVER_H__
00022 #include "mbsim/observer.h"
00023
00024 #ifdef HAVE_OPENMBVCPPINTERFACE
00025 #include <openmbvcppinterface/arrow.h>
00026 namespace OpenMBV {
00027 class Frame;
00028 }
00029 #endif
00030
00031 namespace MBSim {
00032 class Frame;
00033
00034 class CoordinatesObserver : public Observer {
00035 protected:
00036 Frame* frame;
00037 #ifdef HAVE_OPENMBVCPPINTERFACE
00038 OpenMBV::Group *openMBVPosGrp, *openMBVVelGrp, *openMBVAccGrp;
00039 OpenMBV::Arrow *openMBVPosition, *openMBVVelocity, *openMBVAcceleration;
00040 OpenMBV::Frame* openMBVFrame;
00041 #endif
00042
00043 public:
00044 CoordinatesObserver(const std::string &name="");
00045 void setFrame(Frame *frame_) { frame = frame_; }
00046
00047 void init(InitStage stage);
00048 virtual void plot(double t, double dt);
00049 virtual void initializeUsingXML(MBXMLUtils::TiXmlElement *element);
00050
00051 #ifdef HAVE_OPENMBVCPPINTERFACE
00052 void setOpenMBVPositionArrow(OpenMBV::Arrow *arrow) { openMBVPosition = arrow; }
00053 void setOpenMBVVelocityArrow(OpenMBV::Arrow *arrow) { openMBVVelocity = arrow; }
00054 void setOpenMBVAccelerationArrow(OpenMBV::Arrow *arrow) { openMBVAcceleration = arrow; }
00055
00056 virtual void enableOpenMBVPosition(double diameter=0.5, double headDiameter=1, double headLength=1, double color=0.5);
00057 virtual void enableOpenMBVVelocity(double scale=1, OpenMBV::Arrow::ReferencePoint refPoint=OpenMBV::Arrow::fromPoint, double diameter=0.5, double headDiameter=1, double headLength=1, double color=0.5);
00058 virtual void enableOpenMBVAcceleration(double scale=1, OpenMBV::Arrow::ReferencePoint refPoint=OpenMBV::Arrow::fromPoint, double diameter=0.5, double headDiameter=1, double headLength=1, double color=0.5);
00059 virtual void enableOpenMBVFrame(double size=1, double offset=1);
00060
00061 #endif
00062
00063 private:
00064 std::string saved_frame;
00065 };
00066
00067 class CartesianCoordinatesObserver : public CoordinatesObserver {
00068 private:
00069 fmatvec::Vec3 ex, ey, ez;
00070 fmatvec::SqrMat3 A;
00071 #ifdef HAVE_OPENMBVCPPINTERFACE
00072 OpenMBV::Arrow *openMBVXPosition, *openMBVYPosition, *openMBVZPosition, *openMBVXVelocity, *openMBVYVelocity, *openMBVZVelocity, *openMBVXAcceleration, *openMBVYAcceleration, *openMBVZAcceleration;
00073 #endif
00074
00075 public:
00076 CartesianCoordinatesObserver(const std::string &name="");
00077
00078 void init(InitStage stage);
00079 virtual void plot(double t, double dt);
00080 };
00081
00082 class CylinderCoordinatesObserver : public CoordinatesObserver {
00083 private:
00084 fmatvec::Vec3 ez;
00085 #ifdef HAVE_OPENMBVCPPINTERFACE
00086 OpenMBV::Arrow *openMBVRadialPosition, *openMBVZPosition, *openMBVRadialVelocity, *openMBVCircularVelocity, *openMBVZVelocity, *openMBVRadialAcceleration, *openMBVCircularAcceleration, *openMBVZAcceleration;
00087 #endif
00088
00089 public:
00090 CylinderCoordinatesObserver(const std::string &name="");
00091
00092 void init(InitStage stage);
00093 virtual void plot(double t, double dt);
00094 };
00095
00096 class NaturalCoordinatesObserver : public CoordinatesObserver {
00097 private:
00098 #ifdef HAVE_OPENMBVCPPINTERFACE
00099 OpenMBV::Arrow *openMBVTangentialAcceleration, *openMBVNormalAcceleration;
00100 #endif
00101
00102 public:
00103 NaturalCoordinatesObserver(const std::string &name="");
00104
00105 void init(InitStage stage);
00106 virtual void plot(double t, double dt);
00107 };
00108
00109 }
00110
00111 #endif
00112