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

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

draw vrpn axis in simulator

File size: 1.8 KB
RevLine 
[10]1// %flair:license{
[15]2// This file is part of the Flair framework distributed under the
3// CECILL-C 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
26using namespace std;
27using namespace flair::core;
28
[15]29namespace {
30flair::simulator::Simulator *simu = NULL;
[8]31}
32
[15]33namespace flair {
34namespace simulator {
[8]35
[15]36Simulator *getSimulator(void) { return simu; }
[8]37
[286]38Simulator::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]47Simulator::~Simulator() { delete pimpl_; }
[8]48
49Quaternion 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]58Vector3D<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]68float Simulator::Yaw(void) const { return pimpl_->yaw_rad; }
[8]69
[15]70void Simulator::RunSimu(void) { pimpl_->RunSimu(); }
[8]71
72} // end namespace simulator
73} // end namespace flair
Note: See TracBrowser for help on using the repository browser.