[10]  1  // %flair:license{


[15]  2  // This file is part of the Flair framework distributed under the


 3  // CECILLC License, Version 1.0.


[10]  4  // %flair:license}


[8]  5  // created: 2013/03/25


 6  // filename: Simulator.cpp


 7  //


 8  // author: Guillaume Sanahuja


 9  // Copyright Heudiasyc UMR UTC/CNRS 7253


 10  //


 11  // version: $Id: $


 12  //


 13  // purpose: classe de base du Simulator


 14  //


 15  /*********************************************************************/


 16 


 17  #include "Simulator.h"


 18  #include "Simulator_impl.h"


 19  #include "Euler.h"


 20  #include "Quaternion.h"


 21  #include "Vector3D.h"


 22  #ifdef GL


 23  #include "Gui.h"


 24  #endif


 25 


 26  using namespace std;


 27  using namespace flair::core;


 28 


[15]  29  namespace {


 30  flair::simulator::Simulator *simu = NULL;


[8]  31  }


 32 


[15]  33  namespace flair {


 34  namespace simulator {


[8]  35 


[15]  36  Simulator *getSimulator(void) { return simu; }


[8]  37 


[286]  38  Simulator::Simulator(string name, int optitrack_mstime, float yaw_deg, int port)


[15]  39  : FrameworkManager(name) {


 40  if (simu != NULL)


 41  Err("Simulator should be instanced only one time\n");


[8]  42 


[286]  43  pimpl_ = new Simulator_impl(this, optitrack_mstime, yaw_deg,port);


[15]  44  simu = this;


[8]  45  }


 46 


[15]  47  Simulator::~Simulator() { delete pimpl_; }


[8]  48 


 49  Quaternion Simulator::ToVRPNReference(Quaternion quat_in) {


[15]  50  Quaternion yaw_rot_quat;


 51  Euler yaw_rot_euler(


 52  0, 0, pimpl_>yaw_rad); // yaw_rad is vrpn rotation in earth reference


 53  yaw_rot_euler.ToQuaternion(yaw_rot_quat);


[8]  54 


[15]  55  return yaw_rot_quat * quat_in;


[8]  56  }


 57 


[167]  58  Vector3D<double> Simulator::ToVRPNReference(Vector3D<double> point_in) {


[15]  59  Quaternion yaw_rot_quat;


 60  Euler yaw_rot_euler(


 61  0, 0, pimpl_>yaw_rad); // yaw_rad is vrpn rotation in earth reference


 62  yaw_rot_euler.ToQuaternion(yaw_rot_quat);


 63  point_in.Rotate(yaw_rot_quat);


[8]  64 


[15]  65  return point_in;


[8]  66  }


 67 


[15]  68  float Simulator::Yaw(void) const { return pimpl_>yaw_rad; }


[8]  69 


[15]  70  void Simulator::RunSimu(void) { pimpl_>RunSimu(); }


[8]  71 


 72  } // end namespace simulator


 73  } // end namespace flair

