Formula Student Autonomous Systems
The code for the main driverless system
Loading...
Searching...
No Matches
sensorBase.hpp
Go to the documentation of this file.
1#ifndef PACSIMISENSORBASE_HPP
2#define PACSIMISENSORBASE_HPP
3
4#include <queue>
5
6template <typename T> class SensorBase
7{
8public:
9 double getRate() { return this->rate; }
10
12 {
13 T elem = this->deadTimeQueue.front();
14 this->deadTimeQueue.pop();
15 return elem;
16 }
17
18 bool availableDeadTime(double time)
19 {
20 if (this->deadTimeQueue.size() >= 1)
21 {
22 T elem = this->deadTimeQueue.front();
23 if (time >= (elem.timestamp + this->deadTime))
24 {
25 return true;
26 }
27 }
28 return false;
29 }
30
31 bool sampleReady(double time) { return (time >= (this->lastSampleTime + 1 / this->rate)); }
32
34 {
35 this->lastSampleTime += 1.0 / this->rate;
36 return;
37 }
38
39 Eigen::Vector3d getPosition() { return this->position; }
40
41 Eigen::Vector3d getOrientation() { return this->orientation; }
42
43protected:
44 Eigen::Vector3d position;
45 Eigen::Vector3d orientation;
46
47 double rate;
49 double deadTime;
50 std::queue<T> deadTimeQueue;
52};
53
54#endif /* PACSIMISENSORBASE_HPP */
bool sampleReady(double time)
Eigen::Vector3d getOrientation()
double lastSampleTime
double getRate()
Definition sensorBase.hpp:9
bool availableDeadTime(double time)
Eigen::Vector3d orientation
void registerSampling()
Eigen::Vector3d getPosition()
double deadTime
double rate
std::queue< T > deadTimeQueue
Eigen::Vector3d position