From 9b05b45cd983de7211272a3d5834f1c3f764e9fc Mon Sep 17 00:00:00 2001 From: chrehall68 <60240707+chrehall68@users.noreply.github.com> Date: Sat, 30 Mar 2024 14:04:08 -0700 Subject: [PATCH] Dev, Week of March 30th (#106) * Deleted .vscode and stopped its tracking * Created a env_files dir to hold env files for all platforms * Implemented and tested bridge-gps * updated a rover requirement * Created a sphinx Documentation site that can auto load documentation from the docstrings * Added a sphinx build workflow script * Added a requirement to the theme * added explicit dependency to docutils to fetch the latest version * Specified docutils version * Trying to deploy from _build instead of build * Set build dirs in workflow * Switched to deploying from main * Wrote some doc string for a_star_navigator * Added dependencies * Removed pyqt6 dep * Removed RPi dep * Removed sambus dep * Back to min requirements * Added a few dependencies that i think wont break * Rendering sphinx from dev * Anything ending in 'env' in the proj root will be ignored * match files whose file extension ends in .*env * merge requirements.txt into the env files * update readme to reflect dual dependency files * Dev fixes before pull to main * Removed Wireless lidar from the list of lidars in lidar.py * Reenabled the hover to set goal option in Pathfinder Visualizer * remove unnecessary modules, test dependencies on pi (#111) --------- Co-authored-by: Rahul --- .github/workflows/sphinx.yml | 24 ++++ .gitignore | 7 +- .vscode/settings.json | 6 - CommandScripts/AutoHelp.py | 7 +- CommandScripts/GPS_NAV.py | 3 +- CommandScripts/MMT-drive-command.py | 25 ---- CommandScripts/MMT_drive_command.py | 26 ++++ CommandScripts/autonomy.py | 4 +- CommandScripts/drive-command.py | 30 ---- CommandScripts/drive_command.py | 31 ++++ Missions/MMT_testing.py | 85 +++++------ {modules => Missions}/__init__.py | 0 Missions/drive.py | 113 +++++++-------- README.md | 34 +++-- Vision/__init__.py | 0 Vision/depthai-examples/__init.py | 0 .../gen2-box_measurement/__init__.py | 0 Vision/proj_modules/__init__.py | 0 .../{modules => proj_modules}/camera-test.py | 0 .../{modules => proj_modules}/object-width.py | 0 .../stereo-vision-test.py | 0 demos/Compass/run.py | 2 +- demos/GPS-demo/run.py | 2 +- demos/IR_Sensor-demo/run.py | 2 +- demos/MPU6050-demo/run.py | 2 +- demos/Serial-demo/run.py | 2 +- docs/.nojekyll | 0 docs/CommandScripts.rst | 61 ++++++++ docs/Makefile | 20 +++ docs/Missions.rst | 29 ++++ docs/Vision.proj_modules.rst | 37 +++++ docs/Vision.rst | 18 +++ docs/conf.py | 33 +++++ docs/index.rst | 24 ++++ docs/make.bat | 35 +++++ docs/modules.rst | 11 ++ docs/proj_modules.rst | 69 +++++++++ {unified_frameworks => docs}/requirements.txt | 18 +-- docs/unified_frameworks.bridge.rst | 45 ++++++ docs/unified_frameworks.rst | 102 ++++++++++++++ ...ed_frameworks.sensor_array.gps_compass.rst | 53 +++++++ docs/unified_frameworks.sensor_array.rst | 133 ++++++++++++++++++ env_files/all_requirements.txt | 21 +++ env_files/rover_requirements.txt | 11 ++ {modules => proj_modules}/GPS.py | 0 {modules => proj_modules}/IR_Sensor.py | 0 {modules => proj_modules}/LSM303.py | 0 {modules => proj_modules}/MPU6050.py | 0 {modules => proj_modules}/Serial.py | 0 {modules => proj_modules}/WiFi.py | 19 ++- proj_modules/__init__.py | 0 {modules => proj_modules}/old_GPS.py | 0 requirements.txt | 12 -- unified_frameworks/__init__.py | 0 unified_frameworks/a_star_navigator.py | 10 ++ unified_frameworks/bridge/__init__.py | 0 unified_frameworks/captain.py | 8 +- unified_frameworks/pathfinder.py | 15 +- unified_frameworks/pathfinder_visualizer.py | 4 +- unified_frameworks/sensor_array/__init__.py | 0 .../sensor_array/actual_gps_test.py | 20 ++- unified_frameworks/sensor_array/bridge_gps.py | 2 + .../sensor_array/gps_compass/__init__.py | 0 .../gps_compass/actual_gps_compass.py | 12 +- .../gps_compass/gps_compass_class.py | 2 + unified_frameworks/sensor_array/lidar.py | 2 +- .../sensor_array/lidar_visualizer.py | 63 +++++---- unified_frameworks/sensor_array/server_gps.py | 2 +- .../sensor_array/websocket_client.py | 3 +- .../sensor_array/websocket_server.py | 7 +- unified_frameworks/worldview_visualizer.py | 65 ++++----- 71 files changed, 1063 insertions(+), 308 deletions(-) create mode 100644 .github/workflows/sphinx.yml delete mode 100644 .vscode/settings.json delete mode 100644 CommandScripts/MMT-drive-command.py create mode 100644 CommandScripts/MMT_drive_command.py delete mode 100644 CommandScripts/drive-command.py create mode 100644 CommandScripts/drive_command.py rename {modules => Missions}/__init__.py (100%) create mode 100644 Vision/__init__.py create mode 100644 Vision/depthai-examples/__init.py create mode 100644 Vision/depthai-examples/gen2-box_measurement/__init__.py create mode 100644 Vision/proj_modules/__init__.py rename Vision/{modules => proj_modules}/camera-test.py (100%) rename Vision/{modules => proj_modules}/object-width.py (100%) rename Vision/{modules => proj_modules}/stereo-vision-test.py (100%) create mode 100644 docs/.nojekyll create mode 100644 docs/CommandScripts.rst create mode 100644 docs/Makefile create mode 100644 docs/Missions.rst create mode 100644 docs/Vision.proj_modules.rst create mode 100644 docs/Vision.rst create mode 100644 docs/conf.py create mode 100644 docs/index.rst create mode 100644 docs/make.bat create mode 100644 docs/modules.rst create mode 100644 docs/proj_modules.rst rename {unified_frameworks => docs}/requirements.txt (51%) create mode 100644 docs/unified_frameworks.bridge.rst create mode 100644 docs/unified_frameworks.rst create mode 100644 docs/unified_frameworks.sensor_array.gps_compass.rst create mode 100644 docs/unified_frameworks.sensor_array.rst create mode 100644 env_files/all_requirements.txt create mode 100644 env_files/rover_requirements.txt rename {modules => proj_modules}/GPS.py (100%) rename {modules => proj_modules}/IR_Sensor.py (100%) rename {modules => proj_modules}/LSM303.py (100%) rename {modules => proj_modules}/MPU6050.py (100%) rename {modules => proj_modules}/Serial.py (100%) rename {modules => proj_modules}/WiFi.py (91%) create mode 100644 proj_modules/__init__.py rename {modules => proj_modules}/old_GPS.py (100%) delete mode 100644 requirements.txt create mode 100644 unified_frameworks/__init__.py create mode 100644 unified_frameworks/bridge/__init__.py create mode 100644 unified_frameworks/sensor_array/__init__.py create mode 100644 unified_frameworks/sensor_array/gps_compass/__init__.py diff --git a/.github/workflows/sphinx.yml b/.github/workflows/sphinx.yml new file mode 100644 index 0000000..ddb5f8d --- /dev/null +++ b/.github/workflows/sphinx.yml @@ -0,0 +1,24 @@ +name: "Sphinx: Render docs" + +on: push + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/checkout@v4 + - name: Build HTML + uses: ammaraskar/sphinx-action@master + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: html-docs + path: docs/_build/html/ + - name: Deploy + uses: peaceiris/actions-gh-pages@v3 + if: github.ref == 'refs/heads/dev' + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: docs/_build/html diff --git a/.gitignore b/.gitignore index 1cdd6a9..4b5e343 100644 --- a/.gitignore +++ b/.gitignore @@ -4,13 +4,12 @@ __pycache__/ .python-version -.env -.venv -env/ -venv/ +*env +*.*env ENV/ env.bak/ venv.bak/ **.freq frequency_analysis.json +**_build \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index fb8dece..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "python.analysis.extraPaths": [ - "./sensors-modules", - "./modules/LSM303" - ] -} \ No newline at end of file diff --git a/CommandScripts/AutoHelp.py b/CommandScripts/AutoHelp.py index 3143e74..52508b3 100644 --- a/CommandScripts/AutoHelp.py +++ b/CommandScripts/AutoHelp.py @@ -1,6 +1,6 @@ import math #from modules.LSM303 import Compass -from modules.LSM303 import Compass +from proj_modules.LSM303 import Compass import json class AutoHelp: @@ -75,12 +75,15 @@ def jsonify_commands(self, commands): def get_bearing(self, current_GPS, target_GPS): - """Returns the angle between two GPS coordinates + """ + Returns the angle between two GPS coordinates + PARAMS: current_GPS (tuple): (latitude, longitude) target_GPS (tuple): (latitude, longitude) RETURNS: float. angle between the two coordinates + """ try: current_latitude = math.radians(current_GPS[1]) diff --git a/CommandScripts/GPS_NAV.py b/CommandScripts/GPS_NAV.py index 82c6d2a..9ae4436 100644 --- a/CommandScripts/GPS_NAV.py +++ b/CommandScripts/GPS_NAV.py @@ -2,7 +2,7 @@ import os, sys sys.path.insert(0, os.path.abspath("..")) -from modules.LSM303 import Compass +from proj_modules.LSM303 import Compass from CommandScripts import AutoHelp from simple_pid import PID import time @@ -19,6 +19,7 @@ def get_target_angle( self, lidar_data, rover_angle, current_longlat, target_longlat ): """Obstacle avoidance logic that uses vector field histogram (VFH) + PARAMS: lidar_data (list): array of 360 elements. each index is an angle rover_angle (int): the angle that the rover is currently facing diff --git a/CommandScripts/MMT-drive-command.py b/CommandScripts/MMT-drive-command.py deleted file mode 100644 index d024c91..0000000 --- a/CommandScripts/MMT-drive-command.py +++ /dev/null @@ -1,25 +0,0 @@ -import sys -import requests -import serial.tools.list_ports as port_list -import os, sys -sys.path.insert(0, os.path.abspath("..")) -from modules.Serial import SerialSystem - -port = "/dev/ttyUSB0" -get_initial_commands_url = "http://192.168.1.133:5000/drive" - -web_response = requests.get(get_initial_commands_url) -print("Getting data from: " + web_response.text) - -try: - serial = SerialSystem(port, 38400) - print("Using port: " + port) -except: - ports = list(port_list.comports()) - print('====> Designated Port not found. Using Port:', ports[0].device) - port = ports[0].device - serial = SerialSystem(port, 38400) - -while True: - web_response = requests.get(get_initial_commands_url) - serial.read_write_serial(web_response.text) \ No newline at end of file diff --git a/CommandScripts/MMT_drive_command.py b/CommandScripts/MMT_drive_command.py new file mode 100644 index 0000000..9121d49 --- /dev/null +++ b/CommandScripts/MMT_drive_command.py @@ -0,0 +1,26 @@ +import sys +import requests +import serial.tools.list_ports as port_list +import os, sys +sys.path.insert(0, os.path.abspath("..")) +from proj_modules.Serial import SerialSystem + +if __name__=='__main__': + port = "/dev/ttyUSB0" + get_initial_commands_url = "http://192.168.1.133:5000/drive" + + web_response = requests.get(get_initial_commands_url) + print("Getting data from: " + web_response.text) + + try: + serial = SerialSystem(port, 38400) + print("Using port: " + port) + except: + ports = list(port_list.comports()) + print('====> Designated Port not found. Using Port:', ports[0].device) + port = ports[0].device + serial = SerialSystem(port, 38400) + + while True: + web_response = requests.get(get_initial_commands_url) + serial.read_write_serial(web_response.text) \ No newline at end of file diff --git a/CommandScripts/autonomy.py b/CommandScripts/autonomy.py index 713c84c..7ccc58a 100644 --- a/CommandScripts/autonomy.py +++ b/CommandScripts/autonomy.py @@ -7,8 +7,8 @@ sys.path.insert(0, os.path.abspath("..")) from CommandScripts.GPS_NAV import GPS_Nav from CommandScripts import AutoHelp -from modules.LSM303 import Compass -from modules.WiFi import WiFi +from proj_modules.LSM303 import Compass +from proj_modules.WiFi import WiFi import time import threading diff --git a/CommandScripts/drive-command.py b/CommandScripts/drive-command.py deleted file mode 100644 index 37e7838..0000000 --- a/CommandScripts/drive-command.py +++ /dev/null @@ -1,30 +0,0 @@ -import sys -import requests -import serial.tools.list_ports as port_list -import os, sys -sys.path.insert(0, os.path.abspath("..")) -from modules.Serial import SerialSystem - -port = "/dev/ttyUSB0" -get_initial_commands_url = "http://192.168.50.243:5000/drive" - -web_response = requests.get(get_initial_commands_url) -print("Getting data from: " + web_response.text) - -try: - serial = SerialSystem(port, 38400) - print("Using port: " + port) -except: - ports = list(port_list.comports()) - print('====> Designated Port not found. Using Port:', ports[0].device) - port = ports[0].device - serial = SerialSystem(port, 38400) - -homing_end = "Starting control loop..." -while True: - response = serial.read_serial() - if homing_end in response: - while True: - web_response = requests.get(get_initial_commands_url) - serial.read_write_serial(web_response.text) - \ No newline at end of file diff --git a/CommandScripts/drive_command.py b/CommandScripts/drive_command.py new file mode 100644 index 0000000..91c8f08 --- /dev/null +++ b/CommandScripts/drive_command.py @@ -0,0 +1,31 @@ +import sys +import requests +import serial.tools.list_ports as port_list +import os, sys +sys.path.insert(0, os.path.abspath("..")) +from proj_modules.Serial import SerialSystem + +if __name__=='__main__': + port = "/dev/ttyUSB0" + get_initial_commands_url = "http://192.168.50.243:5000/drive" + + web_response = requests.get(get_initial_commands_url) + print("Getting data from: " + web_response.text) + + try: + serial = SerialSystem(port, 38400) + print("Using port: " + port) + except: + ports = list(port_list.comports()) + print('====> Designated Port not found. Using Port:', ports[0].device) + port = ports[0].device + serial = SerialSystem(port, 38400) + + homing_end = "Starting control loop..." + while True: + response = serial.read_serial() + if homing_end in response: + while True: + web_response = requests.get(get_initial_commands_url) + serial.read_write_serial(web_response.text) + \ No newline at end of file diff --git a/Missions/MMT_testing.py b/Missions/MMT_testing.py index 3b0fad8..9391506 100644 --- a/Missions/MMT_testing.py +++ b/Missions/MMT_testing.py @@ -2,9 +2,9 @@ sys.path.insert(0, os.path.abspath("..")) import requests import serial.tools.list_ports as port_list -from modules.Serial import SerialSystem +from proj_modules.Serial import SerialSystem from CommandScripts.autonomy import Autonomy -from modules.old_GPS import gpsRead +from proj_modules.old_GPS import gpsRead import json serial_port = "/dev/ttyACM2" @@ -16,51 +16,52 @@ server = 'http://13.56.207.97:5000' GPS_list = [] -try: - serial = SerialSystem(serial_port, serial_baudrate) - print("Using port: " + serial_port, "For Serial Comms") -except: - ports = list(port_list.comports()) - print('====> Designated Port not found. Using Port:', ports[0].device, "For Serial Connection") - serial_port = ports[0].device - serial = SerialSystem(serial_port, serial_baudrate) +if __name__=='__main__': + try: + serial = SerialSystem(serial_port, serial_baudrate) + print("Using port: " + serial_port, "For Serial Comms") + except: + ports = list(port_list.comports()) + print('====> Designated Port not found. Using Port:', ports[0].device, "For Serial Connection") + serial_port = ports[0].device + serial = SerialSystem(serial_port, serial_baudrate) -try: - GPS = gpsRead(gps_port,gps_baudrate) - print("Using port: " + gps_port, "For GPS") -except: - port_number = 0 - ports = list(port_list.comports()) - print('====> Designated Port not found. Using Port:', ports[port_number].device, "For GPS Connection") - port = ports[port_number].device - GPS = gpsRead(port,gps_baudrate) - while GPS.get_position() == ['error', 'error'] or GPS.get_position() == ["None", "None"]: - print("Port not found, going to next port...") - port_number += 1 - gps_port = ports[port_number].device - try: - GPS = gpsRead(port,gps_baudrate) - except: - continue - break + try: + GPS = gpsRead(gps_port,gps_baudrate) + print("Using port: " + gps_port, "For GPS") + except: + port_number = 0 + ports = list(port_list.comports()) + print('====> Designated Port not found. Using Port:', ports[port_number].device, "For GPS Connection") + port = ports[port_number].device + GPS = gpsRead(port,gps_baudrate) + while GPS.get_position() == ['error', 'error'] or GPS.get_position() == ["None", "None"]: + print("Port not found, going to next port...") + port_number += 1 + gps_port = ports[port_number].device + try: + GPS = gpsRead(port,gps_baudrate) + except: + continue + break -GPS_map_url = f"{server}/gps" -try: - GPS_map = requests.get(GPS_map_url) -except: - print("Could not get GPS map from mission control") - exit(1) + GPS_map_url = f"{server}/gps" + try: + GPS_map = requests.get(GPS_map_url) + except: + print("Could not get GPS map from mission control") + exit(1) -GPS_map = json.loads(GPS_map.text) + GPS_map = json.loads(GPS_map.text) -for i in GPS_map: - GPS_list.append(GPS_map[i]) -print("GPS List:", GPS_list) + for i in GPS_map: + GPS_list.append(GPS_map[i]) + print("GPS List:", GPS_list) -GPS_list = [[-121.8818685, 37.33699716666666], [-121.881868, 37.33696233333334], [-121.88177050000002, 37.336928833333324]] -print("GPS List:", GPS_list) + GPS_list = [[-121.8818685, 37.33699716666666], [-121.881868, 37.33696233333334], [-121.88177050000002, 37.336928833333324]] + print("GPS List:", GPS_list) -rover = Autonomy(serial, server, max_speed, max_angle, GPS, GPS_list) -rover.start_mission() + rover = Autonomy(serial, server, max_speed, max_angle, GPS, GPS_list) + rover.start_mission() diff --git a/modules/__init__.py b/Missions/__init__.py similarity index 100% rename from modules/__init__.py rename to Missions/__init__.py diff --git a/Missions/drive.py b/Missions/drive.py index 17f5a1f..a7e423c 100644 --- a/Missions/drive.py +++ b/Missions/drive.py @@ -3,9 +3,9 @@ sys.path.insert(0, os.path.abspath("..")) import requests import serial.tools.list_ports as port_list -from modules.WiFi import WiFi +from proj_modules.WiFi import WiFi from CommandScripts.autonomy import Autonomy -from modules.GPS import gpsRead +from proj_modules.GPS import gpsRead import json import time @@ -20,64 +20,65 @@ rover_comms = WiFi(server) -try: - GPS = gpsRead(gps_port, gps_baudrate) - print("Using port: " + gps_port, "For GPS") -except: - port_number = 0 - ports = list(port_list.comports()) - print( - "====> Designated Port not found. Using Port:", - ports[port_number].device, - "For GPS Connection", - ) - port = ports[port_number].device - GPS = gpsRead(port, gps_baudrate) - while GPS.get_position() == ["error", "error"] or GPS.get_position() == [ - "None", - "None", - ]: - print("Port not found, going to next port...") - port_number += 1 - gps_port = ports[port_number].device - try: - GPS = gpsRead(port, gps_baudrate) - except: - continue - break +if __name__=='__main__': + try: + GPS = gpsRead(gps_port, gps_baudrate) + print("Using port: " + gps_port, "For GPS") + except: + port_number = 0 + ports = list(port_list.comports()) + print( + "====> Designated Port not found. Using Port:", + ports[port_number].device, + "For GPS Connection", + ) + port = ports[port_number].device + GPS = gpsRead(port, gps_baudrate) + while GPS.get_position() == ["error", "error"] or GPS.get_position() == [ + "None", + "None", + ]: + print("Port not found, going to next port...") + port_number += 1 + gps_port = ports[port_number].device + try: + GPS = gpsRead(port, gps_baudrate) + except: + continue + break -# GPS_map_url = f"{server}/gps_map" -# try: -# GPS_map = requests.get(GPS_map_url) -# except: -# print("Could not get GPS map from mission control") -# exit(1) + # GPS_map_url = f"{server}/gps_map" + # try: + # GPS_map = requests.get(GPS_map_url) + # except: + # print("Could not get GPS map from mission control") + # exit(1) -# GPS_map = json.loads(GPS_map.text) + # GPS_map = json.loads(GPS_map.text) -# for i in GPS_map: -# GPS_list.append(GPS_map[i]) + # for i in GPS_map: + # GPS_list.append(GPS_map[i]) -GPS_list = [ - [-121.8818545, 37.3370768], - [-121.8818535, 37.3370083], - [-121.8817744, 37.3369864], -] -print("GPS List:", GPS_list) + GPS_list = [ + [-121.8818545, 37.3370768], + [-121.8818535, 37.3370083], + [-121.8817744, 37.3369864], + ] + print("GPS List:", GPS_list) -try: - rover = Autonomy(rover_comms, server, max_speed, max_angle, GPS, GPS_list) + try: + rover = Autonomy(rover_comms, server, max_speed, max_angle, GPS, GPS_list) - # start mission - you need to control c your program - rover.start_mission() -except KeyboardInterrupt: - print("stopping...") -except Exception as e: - raise -finally: - rover.rover_comms.write_data( - {"HB": 0, "IO": 1, "WO": 0, "DM": "D", "CMD": [0, 0], "LS": 3} - ) - print("finished stopping") - quit() + # start mission - you need to control c your program + rover.start_mission() + except KeyboardInterrupt: + print("stopping...") + except Exception as e: + raise + finally: + rover.rover_comms.write_data( + {"HB": 0, "IO": 1, "WO": 0, "DM": "D", "CMD": [0, 0], "LS": 3} + ) + print("finished stopping") + quit() diff --git a/README.md b/README.md index 317c1c3..81c0a04 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,20 @@ -# urc-intelligent_systems-2023 - -Contains the intelligent systems module and sensor logic for the SJSU Robotics' 3-Wheeled Mars Rover - -## Setup -To get started, you will need to install the following dependencies, you can do this by using a virtual environment and the requirements.txt file in the root directory of the project. - -```sh -python -m venv venv -source venv/bin/activate -pip install -r requirements.txt -``` - -![classes](https://github.com/SJSURoboticsTeam/urc-intelligent-systems-2023/assets/50222631/3d47c3d4-b21a-463e-9739-bc99b61f450f) +# urc-intelligent_systems-2023 + +Contains the intelligent systems module and sensor logic for the SJSU Robotics' 3-Wheeled Mars Rover + +## Setup + +To get started, you will need to install the following dependencies, you can do this by using a virtual environment and the requirements.txt file in the root directory of the project. + +```sh +python -m venv venv +source venv/bin/activate + +# if you are running not on a Raspberry Pi, run the below +pip install -r env_files/all_requirements.txt + +# If you are running on a Raspberry Pi, run the below +pip install -r env_files/rover_requirements.txt +``` + +![classes](https://github.com/SJSURoboticsTeam/urc-intelligent-systems-2023/assets/50222631/3d47c3d4-b21a-463e-9739-bc99b61f450f) diff --git a/Vision/__init__.py b/Vision/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/Vision/depthai-examples/__init.py b/Vision/depthai-examples/__init.py new file mode 100644 index 0000000..e69de29 diff --git a/Vision/depthai-examples/gen2-box_measurement/__init__.py b/Vision/depthai-examples/gen2-box_measurement/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/Vision/proj_modules/__init__.py b/Vision/proj_modules/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/Vision/modules/camera-test.py b/Vision/proj_modules/camera-test.py similarity index 100% rename from Vision/modules/camera-test.py rename to Vision/proj_modules/camera-test.py diff --git a/Vision/modules/object-width.py b/Vision/proj_modules/object-width.py similarity index 100% rename from Vision/modules/object-width.py rename to Vision/proj_modules/object-width.py diff --git a/Vision/modules/stereo-vision-test.py b/Vision/proj_modules/stereo-vision-test.py similarity index 100% rename from Vision/modules/stereo-vision-test.py rename to Vision/proj_modules/stereo-vision-test.py diff --git a/demos/Compass/run.py b/demos/Compass/run.py index 01b6e5a..6005665 100644 --- a/demos/Compass/run.py +++ b/demos/Compass/run.py @@ -1,7 +1,7 @@ import sys import time sys.path.append( '../../') -from modules.LSM303 import Compass +from proj_modules.LSM303 import Compass if __name__ == '__main__': try: diff --git a/demos/GPS-demo/run.py b/demos/GPS-demo/run.py index eadf2e4..e66a119 100644 --- a/demos/GPS-demo/run.py +++ b/demos/GPS-demo/run.py @@ -3,7 +3,7 @@ import time import serial.tools.list_ports as port_list sys.path.append("../../") -from modules.GPS import gpsRead +from proj_modules.GPS import gpsRead if __name__ == '__main__': try: diff --git a/demos/IR_Sensor-demo/run.py b/demos/IR_Sensor-demo/run.py index 775fa9e..f7e4aba 100644 --- a/demos/IR_Sensor-demo/run.py +++ b/demos/IR_Sensor-demo/run.py @@ -1,7 +1,7 @@ import sys sys.path.append( '../../') import time -from modules.IR_Sensor import IR_Sensor +from proj_modules.IR_Sensor import IR_Sensor sensor = 12 rover_detection = IR_Sensor(sensor) diff --git a/demos/MPU6050-demo/run.py b/demos/MPU6050-demo/run.py index 3db2386..6cc4c7d 100644 --- a/demos/MPU6050-demo/run.py +++ b/demos/MPU6050-demo/run.py @@ -1,6 +1,6 @@ import sys sys.path.append( '../../') -from modules.MPU6050 import MPU6050 +from proj_modules.MPU6050 import MPU6050 mpu = MPU6050() mpu.read_data() \ No newline at end of file diff --git a/demos/Serial-demo/run.py b/demos/Serial-demo/run.py index e5ed5f5..86c733b 100644 --- a/demos/Serial-demo/run.py +++ b/demos/Serial-demo/run.py @@ -1,7 +1,7 @@ import sys import serial.tools.list_ports as port_list sys.path.append( '../../') -from modules.Serial import SerialSystem +from proj_modules.Serial import SerialSystem import json port = "/dev/ttyACM2" diff --git a/docs/.nojekyll b/docs/.nojekyll new file mode 100644 index 0000000..e69de29 diff --git a/docs/CommandScripts.rst b/docs/CommandScripts.rst new file mode 100644 index 0000000..23f7095 --- /dev/null +++ b/docs/CommandScripts.rst @@ -0,0 +1,61 @@ +CommandScripts package +====================== + +Submodules +---------- + +CommandScripts.AutoHelp module +------------------------------ + +.. automodule:: CommandScripts.AutoHelp + :members: + :undoc-members: + :show-inheritance: + +CommandScripts.GPS\_NAV module +------------------------------ + +.. automodule:: CommandScripts.GPS_NAV + :members: + :undoc-members: + :show-inheritance: + +CommandScripts.MMT\_drive\_command module +----------------------------------------- + +.. automodule:: CommandScripts.MMT_drive_command + :members: + :undoc-members: + :show-inheritance: + +CommandScripts.Trajectory module +-------------------------------- + +.. automodule:: CommandScripts.Trajectory + :members: + :undoc-members: + :show-inheritance: + +CommandScripts.autonomy module +------------------------------ + +.. automodule:: CommandScripts.autonomy + :members: + :undoc-members: + :show-inheritance: + +CommandScripts.drive\_command module +------------------------------------ + +.. automodule:: CommandScripts.drive_command + :members: + :undoc-members: + :show-inheritance: + +Module contents +--------------- + +.. automodule:: CommandScripts + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/Makefile b/docs/Makefile new file mode 100644 index 0000000..d4bb2cb --- /dev/null +++ b/docs/Makefile @@ -0,0 +1,20 @@ +# Minimal makefile for Sphinx documentation +# + +# You can set these variables from the command line, and also +# from the environment for the first two. +SPHINXOPTS ?= +SPHINXBUILD ?= sphinx-build +SOURCEDIR = . +BUILDDIR = _build + +# Put it first so that "make" without argument is like "make help". +help: + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +.PHONY: help Makefile + +# Catch-all target: route all unknown targets to Sphinx using the new +# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). +%: Makefile + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/docs/Missions.rst b/docs/Missions.rst new file mode 100644 index 0000000..386dda8 --- /dev/null +++ b/docs/Missions.rst @@ -0,0 +1,29 @@ +Missions package +================ + +Submodules +---------- + +Missions.MMT\_testing module +---------------------------- + +.. automodule:: Missions.MMT_testing + :members: + :undoc-members: + :show-inheritance: + +Missions.drive module +--------------------- + +.. automodule:: Missions.drive + :members: + :undoc-members: + :show-inheritance: + +Module contents +--------------- + +.. automodule:: Missions + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/Vision.proj_modules.rst b/docs/Vision.proj_modules.rst new file mode 100644 index 0000000..f7fb7f1 --- /dev/null +++ b/docs/Vision.proj_modules.rst @@ -0,0 +1,37 @@ +Vision.proj\_modules package +============================ + +Submodules +---------- + +Vision.proj\_modules.camera\-test module +---------------------------------------- + +.. automodule:: Vision.proj_modules.camera-test + :members: + :undoc-members: + :show-inheritance: + +Vision.proj\_modules.object\-width module +----------------------------------------- + +.. automodule:: Vision.proj_modules.object-width + :members: + :undoc-members: + :show-inheritance: + +Vision.proj\_modules.stereo\-vision\-test module +------------------------------------------------ + +.. automodule:: Vision.proj_modules.stereo-vision-test + :members: + :undoc-members: + :show-inheritance: + +Module contents +--------------- + +.. automodule:: Vision.proj_modules + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/Vision.rst b/docs/Vision.rst new file mode 100644 index 0000000..a5e1fd7 --- /dev/null +++ b/docs/Vision.rst @@ -0,0 +1,18 @@ +Vision package +============== + +Subpackages +----------- + +.. toctree:: + :maxdepth: 4 + + Vision.proj_modules + +Module contents +--------------- + +.. automodule:: Vision + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/conf.py b/docs/conf.py new file mode 100644 index 0000000..60da475 --- /dev/null +++ b/docs/conf.py @@ -0,0 +1,33 @@ +# Configuration file for the Sphinx documentation builder. +# +# For the full list of built-in configuration values, see the documentation: +# https://www.sphinx-doc.org/en/master/usage/configuration.html + +# -- Path setup ---------------------------------------------- +import os +import sys +sys.path.insert(0, '..') + +# -- Project information ----------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information + +project = 'Autonomy@SJSU-Robotics' +copyright = '2024, Rahul' +author = 'Rahul' +release = '0.1.0' + +# -- General configuration --------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration + +extensions = ['sphinx.ext.autodoc'] + +templates_path = ['_templates'] +exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] + + + +# -- Options for HTML output ------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output + +html_theme = 'sphinx_rtd_theme' +html_static_path = ['_static'] diff --git a/docs/index.rst b/docs/index.rst new file mode 100644 index 0000000..e68b0a4 --- /dev/null +++ b/docs/index.rst @@ -0,0 +1,24 @@ +.. Autonomy@SJSU-Robotics documentation master file, created by + sphinx-quickstart on Sat Mar 23 20:26:36 2024. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +Welcome to Autonomy@SJSU-Robotics's documentation! +================================================== + +Hi Welcome to documentation + +.. toctree:: + :maxdepth: 10 + :caption: Contents: + + modules + + + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` diff --git a/docs/make.bat b/docs/make.bat new file mode 100644 index 0000000..32bb245 --- /dev/null +++ b/docs/make.bat @@ -0,0 +1,35 @@ +@ECHO OFF + +pushd %~dp0 + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set SOURCEDIR=. +set BUILDDIR=_build + +%SPHINXBUILD% >NUL 2>NUL +if errorlevel 9009 ( + echo. + echo.The 'sphinx-build' command was not found. Make sure you have Sphinx + echo.installed, then set the SPHINXBUILD environment variable to point + echo.to the full path of the 'sphinx-build' executable. Alternatively you + echo.may add the Sphinx directory to PATH. + echo. + echo.If you don't have Sphinx installed, grab it from + echo.https://www.sphinx-doc.org/ + exit /b 1 +) + +if "%1" == "" goto help + +%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% +goto end + +:help +%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% + +:end +popd diff --git a/docs/modules.rst b/docs/modules.rst new file mode 100644 index 0000000..c7e07d1 --- /dev/null +++ b/docs/modules.rst @@ -0,0 +1,11 @@ +autonomy_setup_test +=================== + +.. toctree:: + :maxdepth: 4 + + CommandScripts + Missions + Vision + proj_modules + unified_frameworks diff --git a/docs/proj_modules.rst b/docs/proj_modules.rst new file mode 100644 index 0000000..3a0591e --- /dev/null +++ b/docs/proj_modules.rst @@ -0,0 +1,69 @@ +proj\_modules package +===================== + +Submodules +---------- + +proj\_modules.GPS module +------------------------ + +.. automodule:: proj_modules.GPS + :members: + :undoc-members: + :show-inheritance: + +proj\_modules.IR\_Sensor module +------------------------------- + +.. automodule:: proj_modules.IR_Sensor + :members: + :undoc-members: + :show-inheritance: + +proj\_modules.LSM303 module +--------------------------- + +.. automodule:: proj_modules.LSM303 + :members: + :undoc-members: + :show-inheritance: + +proj\_modules.MPU6050 module +---------------------------- + +.. automodule:: proj_modules.MPU6050 + :members: + :undoc-members: + :show-inheritance: + +proj\_modules.Serial module +--------------------------- + +.. automodule:: proj_modules.Serial + :members: + :undoc-members: + :show-inheritance: + +proj\_modules.WiFi module +------------------------- + +.. automodule:: proj_modules.WiFi + :members: + :undoc-members: + :show-inheritance: + +proj\_modules.old\_GPS module +----------------------------- + +.. automodule:: proj_modules.old_GPS + :members: + :undoc-members: + :show-inheritance: + +Module contents +--------------- + +.. automodule:: proj_modules + :members: + :undoc-members: + :show-inheritance: diff --git a/unified_frameworks/requirements.txt b/docs/requirements.txt similarity index 51% rename from unified_frameworks/requirements.txt rename to docs/requirements.txt index d3cc44a..84269a4 100644 --- a/unified_frameworks/requirements.txt +++ b/docs/requirements.txt @@ -1,12 +1,8 @@ -pyserial -matplotlib -ipython -shapely -requests -ipympl -numpy -jupyterlab -voila -rplidar-roboticia -pyqt6 +docutils==0.20.1 +sphinx-rtd-theme +numpy +matplotlib +shapely +requests +rplidar-roboticia websockets \ No newline at end of file diff --git a/docs/unified_frameworks.bridge.rst b/docs/unified_frameworks.bridge.rst new file mode 100644 index 0000000..1a7f619 --- /dev/null +++ b/docs/unified_frameworks.bridge.rst @@ -0,0 +1,45 @@ +unified\_frameworks.bridge package +================================== + +Submodules +---------- + +unified\_frameworks.bridge.acync\_demos module +---------------------------------------------- + +.. automodule:: unified_frameworks.bridge.acync_demos + :members: + :undoc-members: + :show-inheritance: + +unified\_frameworks.bridge.client\_side module +---------------------------------------------- + +.. automodule:: unified_frameworks.bridge.client_side + :members: + :undoc-members: + :show-inheritance: + +unified\_frameworks.bridge.exceptions module +-------------------------------------------- + +.. automodule:: unified_frameworks.bridge.exceptions + :members: + :undoc-members: + :show-inheritance: + +unified\_frameworks.bridge.rover\_side module +--------------------------------------------- + +.. automodule:: unified_frameworks.bridge.rover_side + :members: + :undoc-members: + :show-inheritance: + +Module contents +--------------- + +.. automodule:: unified_frameworks.bridge + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/unified_frameworks.rst b/docs/unified_frameworks.rst new file mode 100644 index 0000000..712de85 --- /dev/null +++ b/docs/unified_frameworks.rst @@ -0,0 +1,102 @@ +unified\_frameworks package +=========================== + +Subpackages +----------- + +.. toctree:: + :maxdepth: 4 + + unified_frameworks.bridge + unified_frameworks.sensor_array + +Submodules +---------- + +unified\_frameworks.NavigatorClass module +----------------------------------------- + +.. automodule:: unified_frameworks.NavigatorClass + :members: + :undoc-members: + :show-inheritance: + +unified\_frameworks.a\_star\_navigator module +--------------------------------------------- + +.. automodule:: unified_frameworks.a_star_navigator + :members: + :undoc-members: + :show-inheritance: + +unified\_frameworks.captain module +---------------------------------- + +.. automodule:: unified_frameworks.captain + :members: + :undoc-members: + :show-inheritance: + +unified\_frameworks.pathfinder module +------------------------------------- + +.. automodule:: unified_frameworks.pathfinder + :members: + :undoc-members: + :show-inheritance: + +unified\_frameworks.pathfinder\_visualizer module +------------------------------------------------- + +.. automodule:: unified_frameworks.pathfinder_visualizer + :members: + :undoc-members: + :show-inheritance: + +unified\_frameworks.rapid\_random\_tree module +---------------------------------------------- + +.. automodule:: unified_frameworks.rapid_random_tree + :members: + :undoc-members: + :show-inheritance: + +unified\_frameworks.straight\_shot module +----------------------------------------- + +.. automodule:: unified_frameworks.straight_shot + :members: + :undoc-members: + :show-inheritance: + +unified\_frameworks.unified\_utils module +----------------------------------------- + +.. automodule:: unified_frameworks.unified_utils + :members: + :undoc-members: + :show-inheritance: + +unified\_frameworks.worldview module +------------------------------------ + +.. automodule:: unified_frameworks.worldview + :members: + :undoc-members: + :show-inheritance: + +unified\_frameworks.worldview\_visualizer module +------------------------------------------------ + +.. automodule:: unified_frameworks.worldview_visualizer + :members: + :undoc-members: + :show-inheritance: + +Module contents +--------------- + +.. automodule:: unified_frameworks + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/unified_frameworks.sensor_array.gps_compass.rst b/docs/unified_frameworks.sensor_array.gps_compass.rst new file mode 100644 index 0000000..82e267e --- /dev/null +++ b/docs/unified_frameworks.sensor_array.gps_compass.rst @@ -0,0 +1,53 @@ +unified\_frameworks.sensor\_array.gps\_compass package +====================================================== + +Submodules +---------- + +unified\_frameworks.sensor\_array.gps\_compass.actual\_gps\_compass module +-------------------------------------------------------------------------- + +.. automodule:: unified_frameworks.sensor_array.gps_compass.actual_gps_compass + :members: + :undoc-members: + :show-inheritance: + +unified\_frameworks.sensor\_array.gps\_compass.fake\_gps\_compass module +------------------------------------------------------------------------ + +.. automodule:: unified_frameworks.sensor_array.gps_compass.fake_gps_compass + :members: + :undoc-members: + :show-inheritance: + +unified\_frameworks.sensor\_array.gps\_compass.gps\_compass module +------------------------------------------------------------------ + +.. automodule:: unified_frameworks.sensor_array.gps_compass.gps_compass + :members: + :undoc-members: + :show-inheritance: + +unified\_frameworks.sensor\_array.gps\_compass.gps\_compass\_class module +------------------------------------------------------------------------- + +.. automodule:: unified_frameworks.sensor_array.gps_compass.gps_compass_class + :members: + :undoc-members: + :show-inheritance: + +unified\_frameworks.sensor\_array.gps\_compass.wireless\_gps\_compass module +---------------------------------------------------------------------------- + +.. automodule:: unified_frameworks.sensor_array.gps_compass.wireless_gps_compass + :members: + :undoc-members: + :show-inheritance: + +Module contents +--------------- + +.. automodule:: unified_frameworks.sensor_array.gps_compass + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/unified_frameworks.sensor_array.rst b/docs/unified_frameworks.sensor_array.rst new file mode 100644 index 0000000..87f2840 --- /dev/null +++ b/docs/unified_frameworks.sensor_array.rst @@ -0,0 +1,133 @@ +unified\_frameworks.sensor\_array package +========================================= + +Subpackages +----------- + +.. toctree:: + :maxdepth: 4 + + unified_frameworks.sensor_array.gps_compass + +Submodules +---------- + +unified\_frameworks.sensor\_array.LidarClass module +--------------------------------------------------- + +.. automodule:: unified_frameworks.sensor_array.LidarClass + :members: + :undoc-members: + :show-inheritance: + +unified\_frameworks.sensor\_array.actual\_gps\_test module +---------------------------------------------------------- + +.. automodule:: unified_frameworks.sensor_array.actual_gps_test + :members: + :undoc-members: + :show-inheritance: + +unified\_frameworks.sensor\_array.actual\_lidar module +------------------------------------------------------ + +.. automodule:: unified_frameworks.sensor_array.actual_lidar + :members: + :undoc-members: + :show-inheritance: + +unified\_frameworks.sensor\_array.bridge\_gps module +---------------------------------------------------- + +.. automodule:: unified_frameworks.sensor_array.bridge_gps + :members: + :undoc-members: + :show-inheritance: + +unified\_frameworks.sensor\_array.bridge\_lidar module +------------------------------------------------------ + +.. automodule:: unified_frameworks.sensor_array.bridge_lidar + :members: + :undoc-members: + :show-inheritance: + +unified\_frameworks.sensor\_array.client\_bridge\_lidar module +-------------------------------------------------------------- + +.. automodule:: unified_frameworks.sensor_array.client_bridge_lidar + :members: + :undoc-members: + :show-inheritance: + +unified\_frameworks.sensor\_array.client\_lidar module +------------------------------------------------------ + +.. automodule:: unified_frameworks.sensor_array.client_lidar + :members: + :undoc-members: + :show-inheritance: + +unified\_frameworks.sensor\_array.fake\_lidar module +---------------------------------------------------- + +.. automodule:: unified_frameworks.sensor_array.fake_lidar + :members: + :undoc-members: + :show-inheritance: + +unified\_frameworks.sensor\_array.lidar module +---------------------------------------------- + +.. automodule:: unified_frameworks.sensor_array.lidar + :members: + :undoc-members: + :show-inheritance: + +unified\_frameworks.sensor\_array.lidar\_visualizer module +---------------------------------------------------------- + +.. automodule:: unified_frameworks.sensor_array.lidar_visualizer + :members: + :undoc-members: + :show-inheritance: + +unified\_frameworks.sensor\_array.server\_gps module +---------------------------------------------------- + +.. automodule:: unified_frameworks.sensor_array.server_gps + :members: + :undoc-members: + :show-inheritance: + +unified\_frameworks.sensor\_array.server\_lidar module +------------------------------------------------------ + +.. automodule:: unified_frameworks.sensor_array.server_lidar + :members: + :undoc-members: + :show-inheritance: + +unified\_frameworks.sensor\_array.websocket\_client module +---------------------------------------------------------- + +.. automodule:: unified_frameworks.sensor_array.websocket_client + :members: + :undoc-members: + :show-inheritance: + +unified\_frameworks.sensor\_array.websocket\_server module +---------------------------------------------------------- + +.. automodule:: unified_frameworks.sensor_array.websocket_server + :members: + :undoc-members: + :show-inheritance: + +Module contents +--------------- + +.. automodule:: unified_frameworks.sensor_array + :members: + :undoc-members: + :show-inheritance: diff --git a/env_files/all_requirements.txt b/env_files/all_requirements.txt new file mode 100644 index 0000000..0cef400 --- /dev/null +++ b/env_files/all_requirements.txt @@ -0,0 +1,21 @@ +pyserial +matplotlib +ipython +shapely +requests +ipympl +numpy +jupyterlab +voila +rplidar-roboticia +pyqt6 +websockets +Sphinx +sphinx-rtd-theme +adafruit-circuitpython-lsm303dlh-mag +simple-pid +RPi.GPIO +smbus; sys_platform == 'linux' +blobconverter==1.2.* +depthai==2.22.* +opencv-python==4.5.*; platform_machine != "aarch64" \ No newline at end of file diff --git a/env_files/rover_requirements.txt b/env_files/rover_requirements.txt new file mode 100644 index 0000000..d818bd1 --- /dev/null +++ b/env_files/rover_requirements.txt @@ -0,0 +1,11 @@ +pyserial +requests +numpy +rplidar-roboticia +websockets +adafruit-circuitpython-lsm303dlh-mag +simple_pid==2.0.* +RPi.GPIO +simple-pid +blobconverter==1.2.* +depthai==2.22.* \ No newline at end of file diff --git a/modules/GPS.py b/proj_modules/GPS.py similarity index 100% rename from modules/GPS.py rename to proj_modules/GPS.py diff --git a/modules/IR_Sensor.py b/proj_modules/IR_Sensor.py similarity index 100% rename from modules/IR_Sensor.py rename to proj_modules/IR_Sensor.py diff --git a/modules/LSM303.py b/proj_modules/LSM303.py similarity index 100% rename from modules/LSM303.py rename to proj_modules/LSM303.py diff --git a/modules/MPU6050.py b/proj_modules/MPU6050.py similarity index 100% rename from modules/MPU6050.py rename to proj_modules/MPU6050.py diff --git a/modules/Serial.py b/proj_modules/Serial.py similarity index 100% rename from modules/Serial.py rename to proj_modules/Serial.py diff --git a/modules/WiFi.py b/proj_modules/WiFi.py similarity index 91% rename from modules/WiFi.py rename to proj_modules/WiFi.py index 40b1d65..c68c97c 100644 --- a/modules/WiFi.py +++ b/proj_modules/WiFi.py @@ -9,6 +9,7 @@ def __init__(self, address_url): def read_data(self, max_retries=3, wait_time=1): """Gets data from mission control. Expected response: {"HB":int, "IO":int, "WO":int, "DM":char, "CMD":list} + PARAMS: max_retries [int]: max number of requests we send to web server before giving up RETURNS: @@ -31,6 +32,7 @@ def read_data(self, max_retries=3, wait_time=1): def write_data(self, data): """Sends data to mission control using an http post request + PARAMS: data [dict]: something RETURNS: @@ -49,6 +51,7 @@ def send_command(self, data): self.write_data(data) def get_status(self, max_retries=3, wait_time=1): """Gets data from mission control. Expected response: {"HB":int, "IO":int, "WO":int, "DM":char, "CMD":list} + PARAMS: max_retries [int]: max number of requests we send to web server before giving up RETURNS: @@ -77,13 +80,15 @@ def make_drive_command(mode=None, speed_percent=None, angle_degrees=None): Parameters ---------- - mode: Specify the mode in which to interpret command - D: Drive, S: Spin, T: Translate - Default to "D" - speed_percent: Specify the speed as a % of max speed. Can be +- - angle_degree: Specify angle the rover should deviate by - Look forward to this parameter being modified in the future - """ + mode: str + Specify the mode in which to interpret command + D: Drive, S: Spin, T: Translate + Default to "D" + speed_percent: int + Specify the speed as a % of max speed. Can be +- + angle_degree: int + Specify angle the rover should deviate by + Look forward to this parameter being modified in the future""" command = { "HB": 0, # Heart Beat "IO": 1, # Is Operational diff --git a/proj_modules/__init__.py b/proj_modules/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/modules/old_GPS.py b/proj_modules/old_GPS.py similarity index 100% rename from modules/old_GPS.py rename to proj_modules/old_GPS.py diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 8516879..0000000 --- a/requirements.txt +++ /dev/null @@ -1,12 +0,0 @@ -Adafruit_Blinka==8.6.* -blobconverter==1.2.* -board==1.0 -depthai==2.22.* -opencv-python==4.5.*; platform_machine != "aarch64" -pyserial==3.5.* -requests==2.31.* -rplidar==0.9.* -rplidar_roboticia==0.9.* -scikit_learn==1.3.* -simple_pid==2.0.* -smbus==1.1.post2; sys_platform == 'linux' diff --git a/unified_frameworks/__init__.py b/unified_frameworks/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/unified_frameworks/a_star_navigator.py b/unified_frameworks/a_star_navigator.py index 53d5e32..77358ac 100644 --- a/unified_frameworks/a_star_navigator.py +++ b/unified_frameworks/a_star_navigator.py @@ -1,3 +1,13 @@ +""" +This is a navigator that implementes an A* stearch in a continous space +to find a path from the current position to the destination position +bla bla bla + +""" +import sys +import re +root = (next(re.finditer(".*unified_frameworks", __file__)).group()) +sys.path.append(root) if root not in sys.path else None from numpy import ndarray from NavigatorClass import Navigator from math import pi diff --git a/unified_frameworks/bridge/__init__.py b/unified_frameworks/bridge/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/unified_frameworks/captain.py b/unified_frameworks/captain.py index aec7a14..5084c1e 100644 --- a/unified_frameworks/captain.py +++ b/unified_frameworks/captain.py @@ -1,15 +1,19 @@ """This script is responsible for taking in the path from pathfinder and determining a command to send to the rover""" +import sys +import re +root = (next(re.finditer(".*unified_frameworks", __file__)).group()) +sys.path.append(root) if root not in sys.path else None from math import pi from unified_utils import Service import sys, os try: - from modules.WiFi import WiFi, make_drive_command, Modes + from proj_modules.WiFi import WiFi, make_drive_command, Modes except: sys.path.append(os.path.realpath(__file__ + os.sep + ".." + os.sep + "..")) - from modules.WiFi import WiFi, make_drive_command, Modes + from proj_modules.WiFi import WiFi, make_drive_command, Modes from unified_frameworks.sensor_array.gps_compass import gps_compass import pathfinder_visualizer import time diff --git a/unified_frameworks/pathfinder.py b/unified_frameworks/pathfinder.py index 30c5774..635ca4d 100644 --- a/unified_frameworks/pathfinder.py +++ b/unified_frameworks/pathfinder.py @@ -4,16 +4,17 @@ Thoughts on further development -- Currently this limits charting by number of iterations, make it so that its - always charting a route and only resets the obstacles every once in a while. -- Update get neighbors to get neighbors with realistic constraints, like no - sharp turns +- Currently this limits charting by number of iterations, make it so that its always charting a route and only resets the obstacles every once in a while. +- Update get neighbors to get neighbors with realistic constraints, like no sharp turns - Update cost function to have higher cost for points near obstacles. -- ^this can be used to create a potential field, and that potential field could be - used to update an existing path for a new environment instead of invalidating it - due to a new environment +- ^this can be used to create a potential field, and that potential field could be used to update an existing path for a new environment instead of invalidating it due to a new environment + """ +import sys +import re +root = (next(re.finditer(".*unified_frameworks", __file__)).group()) +sys.path.append(root) if root not in sys.path else None import worldview import importlib importlib.reload(worldview) diff --git a/unified_frameworks/pathfinder_visualizer.py b/unified_frameworks/pathfinder_visualizer.py index 9d61e85..b23406c 100644 --- a/unified_frameworks/pathfinder_visualizer.py +++ b/unified_frameworks/pathfinder_visualizer.py @@ -101,8 +101,8 @@ def on_mouse_move(event): def show_visual(get_pathfinder): def on_hover_point(point_polar): - return - # get_pathfinder().set_goal(point_polar) if not point_polar is None else None + # return + get_pathfinder().set_goal(point_polar) if not point_polar is None else None fig, update_func = run_visualizer(get_pathfinder, on_hover_point) anime = anim.FuncAnimation(fig, update_func, 1, interval=50, blit=config['blit']) plt.show() diff --git a/unified_frameworks/sensor_array/__init__.py b/unified_frameworks/sensor_array/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/unified_frameworks/sensor_array/actual_gps_test.py b/unified_frameworks/sensor_array/actual_gps_test.py index 33ea860..e2a97b3 100644 --- a/unified_frameworks/sensor_array/actual_gps_test.py +++ b/unified_frameworks/sensor_array/actual_gps_test.py @@ -1,9 +1,15 @@ +import sys +import re +root = (next(re.finditer(".*sensor_array", __file__)).group()) +sys.path.append(root) if root not in sys.path else None from gps_compass.actual_gps_compass import ActualGPSCompass import time -gps = ActualGPSCompass() -try: - while 1: - print(gps.get_cur_gps(), gps.get_cur_angle()) - time.sleep(1) -except KeyboardInterrupt: - gps.disconnect() + +if __name__=='__main__': + gps = ActualGPSCompass() + try: + while 1: + print(gps.get_cur_gps(), gps.get_cur_angle()) + time.sleep(1) + except KeyboardInterrupt: + gps.disconnect() diff --git a/unified_frameworks/sensor_array/bridge_gps.py b/unified_frameworks/sensor_array/bridge_gps.py index 6d3fbe3..68c0fe9 100644 --- a/unified_frameworks/sensor_array/bridge_gps.py +++ b/unified_frameworks/sensor_array/bridge_gps.py @@ -1,7 +1,9 @@ import traceback try: from gps_compass.actual_gps_compass import ActualGPSCompass + print("Bridge GPS did import ActualGPSCompass") except: + print("Bridge GPS did not import ActualGPSCompass") pass diff --git a/unified_frameworks/sensor_array/gps_compass/__init__.py b/unified_frameworks/sensor_array/gps_compass/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/unified_frameworks/sensor_array/gps_compass/actual_gps_compass.py b/unified_frameworks/sensor_array/gps_compass/actual_gps_compass.py index c810b7a..aefeca5 100644 --- a/unified_frameworks/sensor_array/gps_compass/actual_gps_compass.py +++ b/unified_frameworks/sensor_array/gps_compass/actual_gps_compass.py @@ -2,13 +2,17 @@ from gps_compass.gps_compass_class import GPSCompass import sys import serial.tools.list_ports as port_list +import re +import os -root = __file__[: __file__.index("\\unified_frameworks")] -sys.path.append(root + "\\modules") +root = (next(re.finditer(".*unified_frameworks", __file__)).group()) +sys.path.append(root) if root not in sys.path else None +root = os.path.realpath(os.path.join(root, '..')) +sys.path.append(root) if root not in sys.path else None # import from modules -import GPS -import LSM303 +from proj_modules import GPS +from proj_modules import LSM303 class ActualGPSCompass(GPSCompass): diff --git a/unified_frameworks/sensor_array/gps_compass/gps_compass_class.py b/unified_frameworks/sensor_array/gps_compass/gps_compass_class.py index f364961..534d2a1 100644 --- a/unified_frameworks/sensor_array/gps_compass/gps_compass_class.py +++ b/unified_frameworks/sensor_array/gps_compass/gps_compass_class.py @@ -43,11 +43,13 @@ def get_distance( def get_bearing(current_GPS, target_GPS): """Returns the angle between two GPS coordinates + PARAMS: current_GPS (tuple): (latitude, longitude) target_GPS (tuple): (latitude, longitude) RETURNS: float. angle between the two coordinates + """ try: current_latitude = math.radians(current_GPS[1]) diff --git a/unified_frameworks/sensor_array/lidar.py b/unified_frameworks/sensor_array/lidar.py index c3c0865..83c1907 100644 --- a/unified_frameworks/sensor_array/lidar.py +++ b/unified_frameworks/sensor_array/lidar.py @@ -20,7 +20,7 @@ importlib.reload(sensor_array.client_lidar) config = { - "lidar_preference": [ActualLidar, BridgeLidar, WirelessLidar, FakeLidar], + "lidar_preference": [ActualLidar, BridgeLidar, FakeLidar], "update_frequency": 20, # Hz "history_size": 1, "rover_radius": 0.7, diff --git a/unified_frameworks/sensor_array/lidar_visualizer.py b/unified_frameworks/sensor_array/lidar_visualizer.py index b94e475..1786a21 100644 --- a/unified_frameworks/sensor_array/lidar_visualizer.py +++ b/unified_frameworks/sensor_array/lidar_visualizer.py @@ -8,38 +8,39 @@ import time # lidar.config[''] -lidar.start_lidar_service() -# time.sleep(20) -try: - fig = plt.figure() - ax = plt.subplot(111, projection='polar') - obstacle_points = ax.scatter([],[], s=1) - obstacle_groups = LineCollection([], color=(0,0,0,0.5), linewidths=5) - ax.add_collection(obstacle_groups) +if __name__=='__main__': + lidar.start_lidar_service() + # time.sleep(20) + try: + fig = plt.figure() + ax = plt.subplot(111, projection='polar') + obstacle_points = ax.scatter([],[], s=1) + obstacle_groups = LineCollection([], color=(0,0,0,0.5), linewidths=5) + ax.add_collection(obstacle_groups) - rmax=10 - rmax_=0.01 - ax.set_rmax(rmax) - def update_plot(_): - modded = [] - # Visualizing Point Cloud - point_clouds = lidar.get_point_clouds() - measures = sum(point_clouds, []) if point_clouds is not None else [] - if measures: - obstacle_points.set_offsets(measures) - modded.append(obstacle_points) # - #--------------------- - # Visualizing Obstacles - # obstacle_groups.set_segments(obstacles) - obstacle_groups.set_segments(lidar.get_obstacles()) - modded.append(obstacle_groups) - #--------------------- - return modded + rmax=10 + rmax_=0.01 + ax.set_rmax(rmax) + def update_plot(_): + modded = [] + # Visualizing Point Cloud + point_clouds = lidar.get_point_clouds() + measures = sum(point_clouds, []) if point_clouds is not None else [] + if measures: + obstacle_points.set_offsets(measures) + modded.append(obstacle_points) # + #--------------------- + # Visualizing Obstacles + # obstacle_groups.set_segments(obstacles) + obstacle_groups.set_segments(lidar.get_obstacles()) + modded.append(obstacle_groups) + #--------------------- + return modded - anime = anim.FuncAnimation(fig, update_plot, 1, interval=50, blit=True) + anime = anim.FuncAnimation(fig, update_plot, 1, interval=50, blit=True) - plt.show() -except: - pass -lidar.stop_lidar_service() + plt.show() + except: + pass + lidar.stop_lidar_service() diff --git a/unified_frameworks/sensor_array/server_gps.py b/unified_frameworks/sensor_array/server_gps.py index a598604..74ef444 100644 --- a/unified_frameworks/sensor_array/server_gps.py +++ b/unified_frameworks/sensor_array/server_gps.py @@ -3,7 +3,7 @@ import json from gps_compass.actual_gps_compass import ActualGPSCompass -gps = ActualGPSCompass() +# gps = ActualGPSCompass() # Commented this cuz it should not run if the file is not __main__ print("successfully made actual gps") clients = [] # @note List of clients connected in the server diff --git a/unified_frameworks/sensor_array/websocket_client.py b/unified_frameworks/sensor_array/websocket_client.py index 9e43501..246f72a 100644 --- a/unified_frameworks/sensor_array/websocket_client.py +++ b/unified_frameworks/sensor_array/websocket_client.py @@ -10,4 +10,5 @@ async def receive_data(): print(f"Received: {data}") count+=1 -asyncio.get_event_loop().run_until_complete(receive_data()) +if __name__=='__main__': + asyncio.get_event_loop().run_until_complete(receive_data()) diff --git a/unified_frameworks/sensor_array/websocket_server.py b/unified_frameworks/sensor_array/websocket_server.py index a38f770..6e9f74d 100644 --- a/unified_frameworks/sensor_array/websocket_server.py +++ b/unified_frameworks/sensor_array/websocket_server.py @@ -11,7 +11,8 @@ async def data_stream(websocket, path): await websocket.send(data) await asyncio.sleep(1) # Adjust the delay as needed -start_server = websockets.serve(data_stream, "localhost", 8765) +if __name__=='__main__': + start_server = websockets.serve(data_stream, "localhost", 8765) -asyncio.get_event_loop().run_until_complete(start_server) -asyncio.get_event_loop().run_forever() \ No newline at end of file + asyncio.get_event_loop().run_until_complete(start_server) + asyncio.get_event_loop().run_forever() \ No newline at end of file diff --git a/unified_frameworks/worldview_visualizer.py b/unified_frameworks/worldview_visualizer.py index dd00b66..355b9ec 100644 --- a/unified_frameworks/worldview_visualizer.py +++ b/unified_frameworks/worldview_visualizer.py @@ -7,39 +7,40 @@ import worldview import time -# worldview.config[''] -worldview.start_worldview_service() -# time.sleep(20) -try: - fig = plt.figure() - ax = plt.subplot(111, projection='polar') - obstacle_points = ax.scatter([],[], s=1) - obstacle_groups = LineCollection([], color=(0,0,0,0.5), linewidths=5) - ax.add_collection(obstacle_groups) +if __name__=='__main__': + # worldview.config[''] + worldview.start_worldview_service() + # time.sleep(20) + try: + fig = plt.figure() + ax = plt.subplot(111, projection='polar') + obstacle_points = ax.scatter([],[], s=1) + obstacle_groups = LineCollection([], color=(0,0,0,0.5), linewidths=5) + ax.add_collection(obstacle_groups) - rmax=10 - rmax_=0.01 - ax.set_rmax(rmax) - def update_plot(_): - modded = [] - # Visualizing Point Cloud - # point_clouds = worldview.get_point_clouds() - # measures = sum(point_clouds, []) if point_clouds is not None else [] - # if measures: - # obstacle_points.set_offsets(measures) - # modded.append(obstacle_points) # - #--------------------- - # Visualizing Obstacles - # obstacle_groups.set_segments(obstacles) - obstacle_groups.set_segments(worldview.get_obstacles()) - modded.append(obstacle_groups) - #--------------------- - return modded + rmax=10 + rmax_=0.01 + ax.set_rmax(rmax) + def update_plot(_): + modded = [] + # Visualizing Point Cloud + # point_clouds = worldview.get_point_clouds() + # measures = sum(point_clouds, []) if point_clouds is not None else [] + # if measures: + # obstacle_points.set_offsets(measures) + # modded.append(obstacle_points) # + #--------------------- + # Visualizing Obstacles + # obstacle_groups.set_segments(obstacles) + obstacle_groups.set_segments(worldview.get_obstacles()) + modded.append(obstacle_groups) + #--------------------- + return modded - anime = anim.FuncAnimation(fig, update_plot, 1, interval=50, blit=True) + anime = anim.FuncAnimation(fig, update_plot, 1, interval=50, blit=True) - plt.show() -except: - pass -worldview.stop_worldview_service() + plt.show() + except: + pass + worldview.stop_worldview_service()