[10] | 1 | // %flair:license{
|
---|
| 2 | // This file is part of the Flair framework distributed under the
|
---|
| 3 | // CECILL-C License, Version 1.0.
|
---|
| 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 |
|
---|
| 29 | namespace
|
---|
| 30 | {
|
---|
| 31 | flair::simulator::Simulator* simu=NULL;
|
---|
| 32 | }
|
---|
| 33 |
|
---|
| 34 | namespace flair
|
---|
| 35 | {
|
---|
| 36 | namespace simulator
|
---|
| 37 | {
|
---|
| 38 |
|
---|
| 39 | Simulator* getSimulator(void) {
|
---|
| 40 | return simu;
|
---|
| 41 | }
|
---|
| 42 |
|
---|
| 43 | Simulator::Simulator(string name,int optitrack_mstime,float yaw_deg): FrameworkManager(name)
|
---|
| 44 | {
|
---|
| 45 | if(simu!=NULL) Err("Simulator should be instanced only one time\n");
|
---|
| 46 |
|
---|
| 47 | pimpl_=new Simulator_impl(this,optitrack_mstime,yaw_deg);
|
---|
| 48 | simu=this;
|
---|
| 49 | }
|
---|
| 50 |
|
---|
| 51 | Simulator::~Simulator()
|
---|
| 52 | {
|
---|
| 53 | delete pimpl_;
|
---|
| 54 | }
|
---|
| 55 |
|
---|
| 56 | Quaternion Simulator::ToVRPNReference(Quaternion quat_in) {
|
---|
| 57 | Quaternion yaw_rot_quat;
|
---|
| 58 | Euler yaw_rot_euler(0,0,-pimpl_->yaw_rad);//yaw_rad is vrpn rotation in earth reference
|
---|
| 59 | yaw_rot_euler.ToQuaternion(yaw_rot_quat);
|
---|
| 60 |
|
---|
| 61 | return yaw_rot_quat*quat_in;
|
---|
| 62 | }
|
---|
| 63 |
|
---|
| 64 | Vector3D Simulator::ToVRPNReference(Vector3D point_in) {
|
---|
| 65 | Quaternion yaw_rot_quat;
|
---|
| 66 | Euler yaw_rot_euler(0,0,-pimpl_->yaw_rad);//yaw_rad is vrpn rotation in earth reference
|
---|
| 67 | yaw_rot_euler.ToQuaternion(yaw_rot_quat);
|
---|
| 68 | point_in.Rotate(yaw_rot_quat);
|
---|
| 69 |
|
---|
| 70 | return point_in;
|
---|
| 71 | }
|
---|
| 72 |
|
---|
| 73 | float Simulator::Yaw(void) const
|
---|
| 74 | {
|
---|
| 75 | return pimpl_->yaw_rad;
|
---|
| 76 | }
|
---|
| 77 |
|
---|
| 78 | void Simulator::RunSimu(void)
|
---|
| 79 | {
|
---|
| 80 | pimpl_->RunSimu();
|
---|
| 81 | }
|
---|
| 82 |
|
---|
| 83 | } // end namespace simulator
|
---|
| 84 | } // end namespace flair
|
---|