forked from YehyaSHARIF/Sensor_Characterization_Plateform
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Distance_Sensor.py
44 lines (25 loc) · 1.01 KB
/
Distance_Sensor.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
# -*- coding: utf-8 -*-
"""
Created on Tue Jan 25 17:23:53 2022
@author: pchaillo and Yehya SHARIF
This file represents all required functions to initialise the distance sensor
and read the measured distance of this sensor from the arduino.
"""
from Sensor import Sensor
import hc_c1100_p.HG_C1100_P as hc
class Distance_Sensor(Sensor):
def __init__(self, port, baud):
super().__init__(port, baud) #The super() function is used to give access to methods and properties of a parent or sibling class.
self.sensor = hc.SerialDuino(port, baud)
def UpdateSensor(self):
"""
It's only to update and split the message of the arduino and get the output distance
measured from the laser sensor in the experiment
Returns
-------
the measured value (the distance in mm)
"""
self.sensor.UpdateSensors()
def get_value(self):
self.value = self.sensor.GetDist()
return self.value