| 1 | // created: 2013/03/25
|
---|
| 2 | // filename: Simulator.cpp
|
---|
| 3 | //
|
---|
| 4 | // author: Guillaume Sanahuja
|
---|
| 5 | // Copyright Heudiasyc UMR UTC/CNRS 7253
|
---|
| 6 | //
|
---|
| 7 | // version: $Id: $
|
---|
| 8 | //
|
---|
| 9 | // purpose: classe de base du Simulator
|
---|
| 10 | //
|
---|
| 11 | /*********************************************************************/
|
---|
| 12 |
|
---|
| 13 | #include "Simulator.h"
|
---|
| 14 | #include "Simulator_impl.h"
|
---|
| 15 | #include "Euler.h"
|
---|
| 16 | #include "Quaternion.h"
|
---|
| 17 | #include "Vector3D.h"
|
---|
| 18 | #ifdef GL
|
---|
| 19 | #include "Gui.h"
|
---|
| 20 | #endif
|
---|
| 21 |
|
---|
| 22 | using namespace std;
|
---|
| 23 | using namespace flair::core;
|
---|
| 24 |
|
---|
| 25 | namespace
|
---|
| 26 | {
|
---|
| 27 | flair::simulator::Simulator* simu=NULL;
|
---|
| 28 | }
|
---|
| 29 |
|
---|
| 30 | namespace flair
|
---|
| 31 | {
|
---|
| 32 | namespace simulator
|
---|
| 33 | {
|
---|
| 34 |
|
---|
| 35 | Simulator* getSimulator(void) {
|
---|
| 36 | return simu;
|
---|
| 37 | }
|
---|
| 38 |
|
---|
| 39 | Simulator::Simulator(string name,int optitrack_mstime,float yaw_deg): FrameworkManager(name)
|
---|
| 40 | {
|
---|
| 41 | if(simu!=NULL) Err("Simulator should be instanced only one time\n");
|
---|
| 42 |
|
---|
| 43 | pimpl_=new Simulator_impl(this,optitrack_mstime,yaw_deg);
|
---|
| 44 | simu=this;
|
---|
| 45 | }
|
---|
| 46 |
|
---|
| 47 | Simulator::~Simulator()
|
---|
| 48 | {
|
---|
| 49 | delete pimpl_;
|
---|
| 50 | }
|
---|
| 51 |
|
---|
| 52 | Quaternion Simulator::ToVRPNReference(Quaternion quat_in) {
|
---|
| 53 | Quaternion yaw_rot_quat;
|
---|
| 54 | Euler yaw_rot_euler(0,0,-pimpl_->yaw_rad);//yaw_rad is vrpn rotation in earth reference
|
---|
| 55 | yaw_rot_euler.ToQuaternion(yaw_rot_quat);
|
---|
| 56 |
|
---|
| 57 | return yaw_rot_quat*quat_in;
|
---|
| 58 | }
|
---|
| 59 |
|
---|
| 60 | Vector3D Simulator::ToVRPNReference(Vector3D point_in) {
|
---|
| 61 | Quaternion yaw_rot_quat;
|
---|
| 62 | Euler yaw_rot_euler(0,0,-pimpl_->yaw_rad);//yaw_rad is vrpn rotation in earth reference
|
---|
| 63 | yaw_rot_euler.ToQuaternion(yaw_rot_quat);
|
---|
| 64 | point_in.Rotate(yaw_rot_quat);
|
---|
| 65 |
|
---|
| 66 | return point_in;
|
---|
| 67 | }
|
---|
| 68 |
|
---|
| 69 | float Simulator::Yaw(void) const
|
---|
| 70 | {
|
---|
| 71 | return pimpl_->yaw_rad;
|
---|
| 72 | }
|
---|
| 73 |
|
---|
| 74 | void Simulator::RunSimu(void)
|
---|
| 75 | {
|
---|
| 76 | pimpl_->RunSimu();
|
---|
| 77 | }
|
---|
| 78 |
|
---|
| 79 | } // end namespace simulator
|
---|
| 80 | } // end namespace flair
|
---|