[324] | 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}
|
---|
| 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 | flair::simulator::Simulator *simu = NULL;
|
---|
| 31 | }
|
---|
| 32 |
|
---|
| 33 | namespace flair {
|
---|
| 34 | namespace simulator {
|
---|
| 35 |
|
---|
| 36 | Simulator *getSimulator(void) { return simu; }
|
---|
| 37 |
|
---|
| 38 | Simulator::Simulator(string name, int optitrack_mstime, float yaw_deg, int port)
|
---|
| 39 | : FrameworkManager(name) {
|
---|
| 40 | if (simu != NULL)
|
---|
| 41 | Err("Simulator should be instanced only one time\n");
|
---|
| 42 |
|
---|
| 43 | pimpl_ = new Simulator_impl(this, optitrack_mstime, yaw_deg,port);
|
---|
| 44 | simu = this;
|
---|
| 45 | }
|
---|
| 46 |
|
---|
| 47 | Simulator::~Simulator() { delete pimpl_; }
|
---|
| 48 |
|
---|
| 49 | Quaternion Simulator::ToVRPNReference(Quaternion quat_in) {
|
---|
| 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);
|
---|
| 54 |
|
---|
| 55 | return yaw_rot_quat * quat_in;
|
---|
| 56 | }
|
---|
| 57 |
|
---|
| 58 | Vector3D<double> Simulator::ToVRPNReference(Vector3D<double> point_in) {
|
---|
| 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);
|
---|
| 64 |
|
---|
| 65 | return point_in;
|
---|
| 66 | }
|
---|
| 67 |
|
---|
| 68 | float Simulator::Yaw(void) const { return pimpl_->yaw_rad; }
|
---|
| 69 |
|
---|
| 70 | void Simulator::RunSimu(void) { pimpl_->RunSimu(); }
|
---|
| 71 |
|
---|
| 72 | } // end namespace simulator
|
---|
| 73 | } // end namespace flair
|
---|