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, worldview.py (#126)
Browse files Browse the repository at this point in the history
* Classinated lidar.py

* Classinated worldview.py

* Adapted A_Star_Navigator to use the Classinated worldview
  • Loading branch information
RK22000 authored Apr 10, 2024
1 parent 0d6c7a5 commit 7558971
Show file tree
Hide file tree
Showing 12 changed files with 161 additions and 319 deletions.
4 changes: 2 additions & 2 deletions unified_frameworks/a_star_navigator.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ def service_func(is_running):
sleep(1/config['grow_frequency'])
self._update_path()
self._service = Service(service_func, service_name)
self.worldview.start_worldview_service()
self.worldview.start_service()
self._service.start_service()
pass
def stop_pathfinder_service(self):
self._service.stop_service()
self.worldview.stop_worldview_service()
self.worldview.stop_service()
pass
def _is_colision(self,cart1, cart2, cart_obstacles: list[Geometry]):
if cart1 is None or cart2 is None: return False
Expand Down
2 changes: 1 addition & 1 deletion unified_frameworks/pathfinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

import a_star_navigator # Import any other navigator you like
importlib.reload(a_star_navigator) # Ensures you have instance with latest code reloaded from changes made on the fly
pf = a_star_navigator.A_Star_Navigator(worldview)
pf = a_star_navigator.A_Star_Navigator(worldview.Worldview())
# pf = Pf(worldview)
def get_pathfinder():
return pf
Expand Down
3 changes: 0 additions & 3 deletions unified_frameworks/pathfinder_visualizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,6 @@ def on_hover_point(point_polar):

if __name__=='__main__':
import pathfinder
# import worldview # At least for when this comment is written path finder has its own worldview
# pathfinder = StraightShot(worldview)
# import pathfinder
import matplotlib
from unified_utils import time_tracking_service
time_tracking_service.start_service()
Expand Down
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 7558971

Please sign in to comment.