Skip to content

dataproxy

DataProxy #

Bases: QObject

DataProxy class

Receive points from the Lidar, store them et send them to the data model.

Attributes:

Name Type Description
update_data Signal

Qt signal emitted when new points are available

Source code in cogip/tools/lidarusb/dataproxy.py
 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
class DataProxy(QtCore.QObject):
    """DataProxy class

    Receive points from the Lidar, store them et send them to the data model.

    Attributes:
        update_data: Qt signal emitted when new points are available
    """

    update_data: qtSignal = qtSignal()

    def __init__(
        self,
        angle_values: list[int],
        distance_values: list[int],
        intensity_values: list[int],
    ):
        """Class constructor

        Arguments:
            angle_values: angle list to update
            distance_values: distance list to update
            intensity_values: intensity list to update
        """
        super().__init__()
        self.angle_values = angle_values
        self.distance_values = distance_values
        self.intensity_values = intensity_values
        self.filter = 0

    def set_filter(self, filter: int):
        """
        Qt Slot

        Set filter.

        Arguments:
            filter: new filter
        """
        self.filter = filter

    def filter_distance(self, distance: int, intensity: int) -> int:
        """
        Compute the filtered distance based on current raw distance, intensity and filter.

        Arguments:
            distance: current raw distance
            intensity: current intensity
        """
        if self.filter == 0:
            return distance
        if intensity == 0:
            return self.filter
        if 0 < distance <= self.filter:
            return distance
        return self.filter

    def new_data(self, points: list[tuple[float, int, int]]) -> None:
        """
        Get new list of points.

        Arguments:
            points: new points
        """
        for i, (angle, distance, intensity) in enumerate(points):
            self.angle_values[i] = angle
            self.distance_values[i] = self.filter_distance(distance, intensity)
            self.intensity_values[i] = intensity
            self.update_data.emit()

__init__(angle_values, distance_values, intensity_values) #

Class constructor

Parameters:

Name Type Description Default
angle_values list[int]

angle list to update

required
distance_values list[int]

distance list to update

required
intensity_values list[int]

intensity list to update

required
Source code in cogip/tools/lidarusb/dataproxy.py
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
def __init__(
    self,
    angle_values: list[int],
    distance_values: list[int],
    intensity_values: list[int],
):
    """Class constructor

    Arguments:
        angle_values: angle list to update
        distance_values: distance list to update
        intensity_values: intensity list to update
    """
    super().__init__()
    self.angle_values = angle_values
    self.distance_values = distance_values
    self.intensity_values = intensity_values
    self.filter = 0

filter_distance(distance, intensity) #

Compute the filtered distance based on current raw distance, intensity and filter.

Parameters:

Name Type Description Default
distance int

current raw distance

required
intensity int

current intensity

required
Source code in cogip/tools/lidarusb/dataproxy.py
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
def filter_distance(self, distance: int, intensity: int) -> int:
    """
    Compute the filtered distance based on current raw distance, intensity and filter.

    Arguments:
        distance: current raw distance
        intensity: current intensity
    """
    if self.filter == 0:
        return distance
    if intensity == 0:
        return self.filter
    if 0 < distance <= self.filter:
        return distance
    return self.filter

new_data(points) #

Get new list of points.

Parameters:

Name Type Description Default
points list[tuple[float, int, int]]

new points

required
Source code in cogip/tools/lidarusb/dataproxy.py
62
63
64
65
66
67
68
69
70
71
72
73
def new_data(self, points: list[tuple[float, int, int]]) -> None:
    """
    Get new list of points.

    Arguments:
        points: new points
    """
    for i, (angle, distance, intensity) in enumerate(points):
        self.angle_values[i] = angle
        self.distance_values[i] = self.filter_distance(distance, intensity)
        self.intensity_values[i] = intensity
        self.update_data.emit()

set_filter(filter) #

Qt Slot

Set filter.

Parameters:

Name Type Description Default
filter int

new filter

required
Source code in cogip/tools/lidarusb/dataproxy.py
35
36
37
38
39
40
41
42
43
44
def set_filter(self, filter: int):
    """
    Qt Slot

    Set filter.

    Arguments:
        filter: new filter
    """
    self.filter = filter