-
Notifications
You must be signed in to change notification settings - Fork 23
/
SensorBase.py
98 lines (82 loc) · 2.87 KB
/
SensorBase.py
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""'abstract class for sensors, define the general call interface'
By xiaobo
Contact [email protected]
Created on 六月 20 22:35 2019
"""
# Copyright (C)
#
# This file is part of QuadrotorFly
#
# GWpy is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# GWpy is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GWpy. If not, see <http://www.gnu.org/licenses/>.
import numpy as np
import enum
from enum import Enum
import abc
"""
********************************************************************************************************
**-------------------------------------------------------------------------------------------------------
** Compiler : python 3.6
** Module Name: SensorBase
** Module Date: 2019/6/20
** Module Auth: xiaobo
** Version : V0.1
** Description: 'Replace the content between'
**-------------------------------------------------------------------------------------------------------
** Reversion :
** Modified By:
** Date :
** Content :
** Notes :
********************************************************************************************************/
"""
class SensorType(Enum):
"""Define the sensor types"""
none = enum.auto()
imu = enum.auto()
compass = enum.auto()
gps = enum.auto()
class SensorBase(object, metaclass=abc.ABCMeta):
"""Define the abstract sensor_base class"""
sensorType = SensorType.none
def __init__(self):
super(SensorBase, self).__init__()
# the update tick of last one
self._lastTick = 0
self._isUpdated = False
@property
def last_tick(self):
"""the update tick of last one"""
return self._lastTick
@property
def is_updated(self):
return self._isUpdated
def observe(self):
"""return the sensor data"""
pass
def update(self, real_state, ts):
"""Calculating the output data of sensor according to real state of vehicle,
the difference between update and get_data is that this method will be called when system update,
but the get_data is called when user need the sensor data.
:param real_state: real system state from vehicle
:param ts: the system tick
"""
pass
def reset(self, real_state):
"""reset the sensor"""
pass
def get_name(self):
"""get the name of sensor, format: type:model-no"""
pass