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

Commit

Permalink
fix local import errors
Browse files Browse the repository at this point in the history
  • Loading branch information
chrehall68 committed Apr 13, 2024
1 parent 27efc8f commit a659aae
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 103 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from typing import Tuple
from .gps_compass_class import _GPSCompass
from sensor_array.gps_compass.gps_compass_class import _GPSCompass
import sys
import serial.tools.list_ports as port_list
import re
Expand Down Expand Up @@ -30,10 +30,9 @@ def __init__(self, port: str = None) -> None:
print("====> No port specified. Using Port:", ports[port_number].device)
port = ports[port_number].device
self.gps = GPS.gpsRead(port, 57600)
while (
self.gps.get_position() == ["error"] * 2
or self.gps.get_position() is None
):
while self.gps.get_position() == [
"error"
] * 2 or self.gps.get_position() == ["None", "None"]:
print(f"Port {port} not working, going to next port...")
port_number += 1
port = ports[port_number].device
Expand All @@ -43,6 +42,8 @@ def __init__(self, port: str = None) -> None:
except:
continue
self.cur_gps = self.gps.get_position()
if self.cur_gps is None:
raise Exception("Unable to get proper GPS lock.")

self.compass = LSM303.Compass()

Expand Down
11 changes: 8 additions & 3 deletions unified_frameworks/sensor_array/gps_compass/bridge_gps.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from typing import Tuple
from gps_compass.actual_gps_compass import ActualGPSCompass
import time
import sys
import re
Expand All @@ -9,7 +8,13 @@
from bridge import rover_side, client_side
from bridge.exceptions import NoOpenBridgeException
from unified_utils import Service
from .gps_compass_class import _GPSCompass

try:
from sensor_array.gps_compass.actual_gps_compass import ActualGPSCompass
except ImportError as e:
print(e.msg)
print("Assuming this means on client side.")
from sensor_array.gps_compass.gps_compass_class import _GPSCompass

import json

Expand Down Expand Up @@ -83,9 +88,9 @@ def get_cur_gps(self) -> Tuple[int, int]:
rover_side.service.start_service()
gps = BridgeGPS()
gps.connect()
time.sleep(3) # give time for threads to start
while True:
try:
# time.sleep(2)
print(f"GPS: {gps.get_cur_gps()}, Heading: {gps.get_cur_angle()}")
time.sleep(1)
except KeyboardInterrupt:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

root = __file__[: __file__.index("/unified_frameworks")]
sys.path.append(root + "/unified_frameworks")
from .gps_compass_class import _GPSCompass
from sensor_array.gps_compass.gps_compass_class import _GPSCompass
import math


Expand Down

This file was deleted.

0 comments on commit a659aae

Please sign in to comment.