Skip to content
This repository has been archived by the owner on May 4, 2024. It is now read-only.

Commit

Permalink
Classinated lidar.py
Browse files Browse the repository at this point in the history
  • Loading branch information
RK22000 committed Apr 6, 2024
1 parent 0d6c7a5 commit dd66c09
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 244 deletions.
4 changes: 2 additions & 2 deletions unified_frameworks/sensor_array/LidarClass.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from abc import ABC, abstractmethod
class LidarDisconnectException(Exception):
pass
class Lidar(ABC):
class _Lidar(ABC):
@abstractmethod
def connect(self, max_attempts=3, wait_seconds=1, verbose_attempts=False) -> bool:
"""Make attempts to connect to the Lidar
Expand All @@ -22,7 +22,7 @@ def disconnect(self):
pass
@abstractmethod
def get_measures(self):
"""Get measures from the lidar as a list of 3-tuples (quality, angle degrees, distance meter)"""
"""Get measures from the lidar as a list of 3-tuples (quality, angle degrees, distance millimeter)"""
pass
def test_Lidar(lidar, connection_attempts=3):
import sys, time
Expand Down
6 changes: 3 additions & 3 deletions unified_frameworks/sensor_array/actual_lidar.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
import traceback

try:
from sensor_array.LidarClass import Lidar
from sensor_array.LidarClass import _Lidar
except ModuleNotFoundError:
import sys
import re

sys.path.append((next(re.finditer(".*unified_frameworks", __file__)).group()))
from sensor_array.LidarClass import Lidar
from sensor_array.LidarClass import _Lidar
from rplidar import RPLidar, RPLidarException
import serial.tools.list_ports
from serial.serialutil import PortNotOpenError
Expand All @@ -29,7 +29,7 @@ def getDevicePort():
return None


class ActualLidar(Lidar):
class ActualLidar(_Lidar):
def __init__(self, port=getDevicePort()) -> None:
self.serial_port = port
self.measures = []
Expand Down
4 changes: 2 additions & 2 deletions unified_frameworks/sensor_array/bridge_lidar.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
root = (next(re.finditer(".*unified_frameworks", __file__)).group())
sys.path.append(root) if root not in sys.path else None
from sensor_array.actual_lidar import ActualLidar
from sensor_array.LidarClass import Lidar
from sensor_array.LidarClass import _Lidar
from bridge import rover_side, client_side
from bridge.exceptions import NoOpenBridgeException
from unified_utils import Service
Expand All @@ -13,7 +13,7 @@
config = {
"update_frequency": 20, #Hz
}
class BridgeLidar(Lidar):
class BridgeLidar(_Lidar):
PATH = '/lidar'
def __init__(self) -> None:
if rover_side.bridge_is_up():
Expand Down
4 changes: 2 additions & 2 deletions unified_frameworks/sensor_array/fake_lidar.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
import sys
import re
sys.path.append((next(re.finditer(".*unified_frameworks", __file__)).group()))
from sensor_array.LidarClass import Lidar
from sensor_array.LidarClass import _Lidar
from unified_utils import Service, polar_sum

config = {
"verbose":False
}
class FakeLidar(Lidar):
class FakeLidar(_Lidar):
def __init__(self, points=100, angular_rate=1, translational_rate=1, jitter=0, noise=0, empty_scans=False) -> None:
self.n = points
angles = np.linspace(0, 360, self.n)
Expand Down
Loading

0 comments on commit dd66c09

Please sign in to comment.