source: flair-src/trunk/lib/FlairSimulator/src/Simulator.cpp@ 290

Last change on this file since 290 was 286, checked in by Sanahuja Guillaume, 5 years ago

draw vrpn axis in simulator

File size: 1.8 KB
Line 
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
26using namespace std;
27using namespace flair::core;
28
29namespace {
30flair::simulator::Simulator *simu = NULL;
31}
32
33namespace flair {
34namespace simulator {
35
36Simulator *getSimulator(void) { return simu; }
37
38Simulator::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
47Simulator::~Simulator() { delete pimpl_; }
48
49Quaternion 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
58Vector3D<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
68float Simulator::Yaw(void) const { return pimpl_->yaw_rad; }
69
70void Simulator::RunSimu(void) { pimpl_->RunSimu(); }
71
72} // end namespace simulator
73} // end namespace flair
Note: See TracBrowser for help on using the repository browser.