Module DynAIkonTrap.sensor
An interface to the sensor board. The logs from sensor readings are taken by the SensorLogs
and can be accessed via the SensorLogger.get()
function, by timestamp. The intended usage is to retrieve a sensor log taken at a similar time to a frame.
Classes
class Reading (value: float, units: str)
-
Representation of a sensor reading, which has a value and units of measurement
Class variables
var units : str
var value : float
class Sensor (port: str, baud: int)
-
Provides an interface to the weather sensor board
Args
port
:str
- The path to the port to which the sensor is attached, most likely
'/dev/ttyUSB0'
baud
:int
- Baudrate to use in communication with the sensor board
Raises
SerialException
- If the sensor board could not be found
Methods
def read(self) ‑> SensorLog
class SensorLog (timestamp: float, brightness: Union[Reading, type(None)], humidity: Union[Reading, type(None)], pressure: Union[Reading, type(None)], temperature: type(None) = None)
-
A log of sensor readings taken at a given moment in time. Time is represented as a UNIX-style timestamp. If a reading could not be taken for any of the attached sensors, the sensor may be represented by
None
in the log.Class variables
var brightness : Union[Reading, NoneType]
var humidity : Union[Reading, NoneType]
var pressure : Union[Reading, NoneType]
var temperature : NoneType
var timestamp : float
class SensorLogs (settings: SensorSettings)
-
A data structure to hold all sensor logs. The class includes a dedicated process to perform the sensor logging and handle sensor log lookup requests.
Args
settings
:SensorSettings
- Settings for the sensor logger
Raises
SerialException
- If the sensor board could not be found
Instance variables
var read_interval
Methods
def get(self, timestamp: float) ‑> Union[SensorLog, NoneType]
-
Get the log closest to the given timestamp and return it.
Also deletes logs older than this timestamp.
Args
timestamp
:float
- Timestamp of the image for which sensor readings are to be retrieved
Returns
Union[SensorLog, None]
- The retrieved log of sensor readings or
None
if none could be retrieved.