1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*
 * Copyright 2022-2024 Riccardo Monica
 * 
 * This software is distributed under the 3-clause BSD license.
 * You should have received a copy of the 3-clause BSD license
 * along with this software. If not, see
 * <https://opensource.org/license/bsd-3-clause>
 */

#ifndef STATISTICS_TRACKER_H
#define STATISTICS_TRACKER_H

#if _MSC_VER // this is defined when compiling with Visual Studio
#define EXPORT_API __declspec(dllexport) // Visual Studio needs annotating exported functions with this
#else
#define EXPORT_API
#endif

#include "tracking_commons.h"

#include <vector>
#include <stdint.h>
#include <iostream>

#include <Eigen/Dense>
#include <Eigen/StdVector>

namespace Tracking
{
  class StatisticsTracker
  {
    public:
    typedef std::vector<float> FloatVector;
    typedef std::vector<Eigen::Affine3f> Affine3fVector;

    const int READ_PREV_FRAMES = 30;

    StatisticsTracker()
    {
      m_last_vibration_met = 0.0f;
      m_last_vibration_rad = 0.0f;
    }

    EXPORT_API void Update(const Eigen::Affine3f & world_to_motive,
                           const Eigen::Affine3f & world_to_oculus);

    float GetVibrationRad() const {return m_last_vibration_rad; }
    float GetVibrationMet() const {return m_last_vibration_met; }

    EIGEN_MAKE_ALIGNED_OPERATOR_NEW;

    private:
    Affine3fVector m_last_world_to_oculus;

    float m_last_vibration_rad;
    float m_last_vibration_met;

    Eigen::Affine3f m_prev_world_to_motive;
    Eigen::Affine3f m_prev_world_to_oculus;
  };
}

#endif // STATISTICS_TRACKER_H