diff --git a/mil_common/utils/mil_tools/scripts/mil-preflight/README.md b/mil_common/utils/mil_tools/scripts/mil-preflight/README.md new file mode 100644 index 000000000..88a138a4c --- /dev/null +++ b/mil_common/utils/mil_tools/scripts/mil-preflight/README.md @@ -0,0 +1 @@ +#Preflight diff --git a/mil_common/utils/mil_tools/scripts/mil-preflight/dist/mil_preflight-0.1.2-py3-none-any.whl b/mil_common/utils/mil_tools/scripts/mil-preflight/dist/mil_preflight-0.1.2-py3-none-any.whl new file mode 100644 index 000000000..0689d158c Binary files /dev/null and b/mil_common/utils/mil_tools/scripts/mil-preflight/dist/mil_preflight-0.1.2-py3-none-any.whl differ diff --git a/mil_common/utils/mil_tools/scripts/mil-preflight/dist/mil_preflight-0.1.2.tar.gz b/mil_common/utils/mil_tools/scripts/mil-preflight/dist/mil_preflight-0.1.2.tar.gz new file mode 100644 index 000000000..1752f2d48 Binary files /dev/null and b/mil_common/utils/mil_tools/scripts/mil-preflight/dist/mil_preflight-0.1.2.tar.gz differ diff --git a/mil_common/utils/mil_tools/scripts/preflight/Tests/RunTests.py b/mil_common/utils/mil_tools/scripts/mil-preflight/old-code/RunTests.py similarity index 100% rename from mil_common/utils/mil_tools/scripts/preflight/Tests/RunTests.py rename to mil_common/utils/mil_tools/scripts/mil-preflight/old-code/RunTests.py diff --git a/mil_common/utils/mil_tools/scripts/preflight/Tests/TestLib.py b/mil_common/utils/mil_tools/scripts/mil-preflight/old-code/TestLib.py similarity index 100% rename from mil_common/utils/mil_tools/scripts/preflight/Tests/TestLib.py rename to mil_common/utils/mil_tools/scripts/mil-preflight/old-code/TestLib.py diff --git a/mil_common/utils/mil_tools/scripts/mil-preflight/poetry.lock b/mil_common/utils/mil_tools/scripts/mil-preflight/poetry.lock new file mode 100644 index 000000000..11c22946c --- /dev/null +++ b/mil_common/utils/mil_tools/scripts/mil-preflight/poetry.lock @@ -0,0 +1,146 @@ +# This file is automatically @generated by Poetry 1.7.1 and should not be changed by hand. + +[[package]] +name = "click" +version = "8.1.7" +description = "Composable command line interface toolkit" +optional = false +python-versions = ">=3.7" +files = [ + {file = "click-8.1.7-py3-none-any.whl", hash = "sha256:ae74fb96c20a0277a1d615f1e4d73c8414f5a98db8b799a7931d1582f3390c28"}, + {file = "click-8.1.7.tar.gz", hash = "sha256:ca9853ad459e787e2192211578cc907e7594e294c7ccc834310722b41b9ca6de"}, +] + +[package.dependencies] +colorama = {version = "*", markers = "platform_system == \"Windows\""} + +[[package]] +name = "colorama" +version = "0.4.6" +description = "Cross-platform colored terminal text." +optional = false +python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" +files = [ + {file = "colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6"}, + {file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"}, +] + +[[package]] +name = "markdown-it-py" +version = "3.0.0" +description = "Python port of markdown-it. Markdown parsing, done right!" +optional = false +python-versions = ">=3.8" +files = [ + {file = "markdown-it-py-3.0.0.tar.gz", hash = "sha256:e3f60a94fa066dc52ec76661e37c851cb232d92f9886b15cb560aaada2df8feb"}, + {file = "markdown_it_py-3.0.0-py3-none-any.whl", hash = "sha256:355216845c60bd96232cd8d8c40e8f9765cc86f46880e43a8fd22dc1a1a8cab1"}, +] + +[package.dependencies] +mdurl = ">=0.1,<1.0" + +[package.extras] +benchmarking = ["psutil", "pytest", "pytest-benchmark"] +code-style = ["pre-commit (>=3.0,<4.0)"] +compare = ["commonmark (>=0.9,<1.0)", "markdown (>=3.4,<4.0)", "mistletoe (>=1.0,<2.0)", "mistune (>=2.0,<3.0)", "panflute (>=2.3,<3.0)"] +linkify = ["linkify-it-py (>=1,<3)"] +plugins = ["mdit-py-plugins"] +profiling = ["gprof2dot"] +rtd = ["jupyter_sphinx", "mdit-py-plugins", "myst-parser", "pyyaml", "sphinx", "sphinx-copybutton", "sphinx-design", "sphinx_book_theme"] +testing = ["coverage", "pytest", "pytest-cov", "pytest-regressions"] + +[[package]] +name = "mdurl" +version = "0.1.2" +description = "Markdown URL utilities" +optional = false +python-versions = ">=3.7" +files = [ + {file = "mdurl-0.1.2-py3-none-any.whl", hash = "sha256:84008a41e51615a49fc9966191ff91509e3c40b939176e643fd50a5c2196b8f8"}, + {file = "mdurl-0.1.2.tar.gz", hash = "sha256:bb413d29f5eea38f31dd4754dd7377d4465116fb207585f97bf925588687c1ba"}, +] + +[[package]] +name = "pygments" +version = "2.17.2" +description = "Pygments is a syntax highlighting package written in Python." +optional = false +python-versions = ">=3.7" +files = [ + {file = "pygments-2.17.2-py3-none-any.whl", hash = "sha256:b27c2826c47d0f3219f29554824c30c5e8945175d888647acd804ddd04af846c"}, + {file = "pygments-2.17.2.tar.gz", hash = "sha256:da46cec9fd2de5be3a8a784f434e4c4ab670b4ff54d605c4c2717e9d49c4c367"}, +] + +[package.extras] +plugins = ["importlib-metadata"] +windows-terminal = ["colorama (>=0.4.6)"] + +[[package]] +name = "rich" +version = "13.7.0" +description = "Render rich text, tables, progress bars, syntax highlighting, markdown and more to the terminal" +optional = false +python-versions = ">=3.7.0" +files = [ + {file = "rich-13.7.0-py3-none-any.whl", hash = "sha256:6da14c108c4866ee9520bbffa71f6fe3962e193b7da68720583850cd4548e235"}, + {file = "rich-13.7.0.tar.gz", hash = "sha256:5cb5123b5cf9ee70584244246816e9114227e0b98ad9176eede6ad54bf5403fa"}, +] + +[package.dependencies] +markdown-it-py = ">=2.2.0" +pygments = ">=2.13.0,<3.0.0" +typing-extensions = {version = ">=4.0.0,<5.0", markers = "python_version < \"3.9\""} + +[package.extras] +jupyter = ["ipywidgets (>=7.5.1,<9)"] + +[[package]] +name = "shellingham" +version = "1.5.4" +description = "Tool to Detect Surrounding Shell" +optional = false +python-versions = ">=3.7" +files = [ + {file = "shellingham-1.5.4-py2.py3-none-any.whl", hash = "sha256:7ecfff8f2fd72616f7481040475a65b2bf8af90a56c89140852d1120324e8686"}, + {file = "shellingham-1.5.4.tar.gz", hash = "sha256:8dbca0739d487e5bd35ab3ca4b36e11c4078f3a234bfce294b0a0291363404de"}, +] + +[[package]] +name = "typer" +version = "0.9.0" +description = "Typer, build great CLIs. Easy to code. Based on Python type hints." +optional = false +python-versions = ">=3.6" +files = [ + {file = "typer-0.9.0-py3-none-any.whl", hash = "sha256:5d96d986a21493606a358cae4461bd8cdf83cbf33a5aa950ae629ca3b51467ee"}, + {file = "typer-0.9.0.tar.gz", hash = "sha256:50922fd79aea2f4751a8e0408ff10d2662bd0c8bbfa84755a699f3bada2978b2"}, +] + +[package.dependencies] +click = ">=7.1.1,<9.0.0" +colorama = {version = ">=0.4.3,<0.5.0", optional = true, markers = "extra == \"all\""} +rich = {version = ">=10.11.0,<14.0.0", optional = true, markers = "extra == \"all\""} +shellingham = {version = ">=1.3.0,<2.0.0", optional = true, markers = "extra == \"all\""} +typing-extensions = ">=3.7.4.3" + +[package.extras] +all = ["colorama (>=0.4.3,<0.5.0)", "rich (>=10.11.0,<14.0.0)", "shellingham (>=1.3.0,<2.0.0)"] +dev = ["autoflake (>=1.3.1,<2.0.0)", "flake8 (>=3.8.3,<4.0.0)", "pre-commit (>=2.17.0,<3.0.0)"] +doc = ["cairosvg (>=2.5.2,<3.0.0)", "mdx-include (>=1.4.1,<2.0.0)", "mkdocs (>=1.1.2,<2.0.0)", "mkdocs-material (>=8.1.4,<9.0.0)", "pillow (>=9.3.0,<10.0.0)"] +test = ["black (>=22.3.0,<23.0.0)", "coverage (>=6.2,<7.0)", "isort (>=5.0.6,<6.0.0)", "mypy (==0.910)", "pytest (>=4.4.0,<8.0.0)", "pytest-cov (>=2.10.0,<5.0.0)", "pytest-sugar (>=0.9.4,<0.10.0)", "pytest-xdist (>=1.32.0,<4.0.0)", "rich (>=10.11.0,<14.0.0)", "shellingham (>=1.3.0,<2.0.0)"] + +[[package]] +name = "typing-extensions" +version = "4.9.0" +description = "Backported and Experimental Type Hints for Python 3.8+" +optional = false +python-versions = ">=3.8" +files = [ + {file = "typing_extensions-4.9.0-py3-none-any.whl", hash = "sha256:af72aea155e91adfc61c3ae9e0e342dbc0cba726d6cba4b6c72c1f34e47291cd"}, + {file = "typing_extensions-4.9.0.tar.gz", hash = "sha256:23478f88c37f27d76ac8aee6c905017a143b0b1b886c3c9f66bc2fd94f9f5783"}, +] + +[metadata] +lock-version = "2.0" +python-versions = "^3.8" +content-hash = "7e4e54aaa562d12214312d56749ecc2f12e61a29eedb2de9b72dd3f0c48541ad" diff --git a/mil_common/utils/mil_tools/scripts/mil-preflight/pyproject.toml b/mil_common/utils/mil_tools/scripts/mil-preflight/pyproject.toml new file mode 100644 index 000000000..262030cba --- /dev/null +++ b/mil_common/utils/mil_tools/scripts/mil-preflight/pyproject.toml @@ -0,0 +1,17 @@ +[tool.poetry] +name = "mil-preflight" +version = "0.1.2" +description = "" +authors = ["Anthony Liao ","Keith Khadar ","Joshua Thomas "] +readme = "README.md" + +[tool.poetry.dependencies] +python = "^3.8" +typer = {extras = ["all"], version = "^0.9.0"} + +[tool.poetry.scripts] +preflight = "mil_preflight.main:app" + +[build-system] +requires = ["poetry-core"] +build-backend = "poetry.core.masonry.api" diff --git a/mil_common/utils/mil_tools/scripts/mil-preflight/tests/__init__.py b/mil_common/utils/mil_tools/scripts/mil-preflight/tests/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/mil_common/utils/mil_tools/scripts/preflight/preflight.py b/mil_common/utils/mil_tools/scripts/preflight/preflight.py deleted file mode 100644 index ba1fef7ce..000000000 --- a/mil_common/utils/mil_tools/scripts/preflight/preflight.py +++ /dev/null @@ -1,122 +0,0 @@ -import subprocess - -import preflight_menus -import rosnode -import rospy -import rostopic -import typer -from PyInquirer import prompt -from rich.progress import track - -app = typer.Typer() - -hardwareChecklist = [ - { - "type": "checkbox", - "message": "Hardware Checklist:", - "name": "HardwareTests: \nPlease check that all of the following are in working order. \nYou cannot continue until everything has been checked.", - "choices": [ - {"name": "check thing 1"}, - {"name": "check thing 2"}, - {"name": "check thing 3"}, - {"name": "check thing 4"}, - {"name": "check thing 5"}, - ], - }, -] -actuatorChecklist = [ - { - "type": "list", - "message": "Select which system you want to run. BE CAREFUL make sure everyone's fingures are secured.", - "name": "Mechanical Systems Check:", - "choices": ["thrusters", "Gripper"], - }, -] - -topics = [ - "/camera/front/right/image_raw", - "/camera/down/image_raw", - "/camera/front/left/image_raw", - "/dvl", - "/depth", - "/imu/data_raw", - "/imu/mag", -] - -nodes = ["/odom_estimator"] - -actuatorsList = ["/thrusters/thrust"] - - -@app.command("Start") -def main(): - # Display Modes/Options - subprocess.run("clear", shell=True) - mode = preflight_menus.display_start_menu() - - if mode == "Run Preflight Full Test": - hardware() - software() - actuators() - - # Complete the actuator tests - subprocess.run("clear", shell=True) - - -def hardware(): - # Complete the hardware tests - subprocess.run("clear", shell=True) - answers = prompt(hardwareChecklist) - while len(next(iter(answers.values()))) != 5: - subprocess.run("clear", shell=True) - answers = prompt(hardwareChecklist) - - -def software(): - # Complete the software tests - subprocess.run("clear", shell=True) - rospy.init_node("preflight") - - # Check Nodes - answers = [] - for node in track(nodes, description="Checking Nodes..."): - try: - answers.append({node: rosnode.rosnode_ping(node, 5)}) - except Exception: - answers.append({node: False}) - print(answers) - - # Check Topics - answers = [] - for topic in track(topics, description="Checking Topics..."): - try: - topicType, topicStr, _ = rostopic.get_topic_class(topic) # get topic class - rospy.wait_for_message( - topicStr, - topicType, - 5, - ) # try to get a message from that topic - answers.append({topic: True}) - except Exception: - answers.append({topic: False}) - print(answers) - - print( - prompt( - [ - { - "type": "confirm", - "name": "continue", - "message": "Continue?", - }, - ], - ), - ) - - -def actuators(): - subprocess.run("clear", shell=True) - - -if __name__ == "__main__": - app() diff --git a/mil_common/utils/mil_tools/scripts/preflight/preflight_menus.py b/mil_common/utils/mil_tools/scripts/preflight/preflight_menus.py deleted file mode 100644 index db5be62d2..000000000 --- a/mil_common/utils/mil_tools/scripts/preflight/preflight_menus.py +++ /dev/null @@ -1,42 +0,0 @@ -from PyInquirer import prompt -from rich.console import Console - - -def display_start_menu(): - console = Console() - - # Title - console.print( - "[bold green]Preflight Program - Autonomous Robot Verification[/bold green]\n", - ) - - # Description - console.print( - "Welcome to the Preflight Program, a tool inspired by the preflight checklists used by pilots before " - "flying a plane. This program is designed to verify the functionality of all software and hardware " - "systems on your autonomous robot. It ensures that everything is in working order, allowing you to " - "safely deploy your robot with confidence.\n", - ) - - # Authors section - console.print("\n[italic]Authors:[/italic]") - console.print("Keith Khadar") - console.print("Anthony Liao") - console.print("Joshua Thomas\n") - - # Menu options - start_menu = [ - { - "type": "list", - "name": "mode selection", - "message": "Menu", - "choices": [ - "Run Preflight Full Test", - "View Report", - "Run Specific Test", - "View Documentation", - ], - }, - ] - option = prompt(start_menu) - return next(iter(option.values())) diff --git a/preflight-test/bin/python b/preflight-test/bin/python new file mode 120000 index 000000000..b8a0adbbb --- /dev/null +++ b/preflight-test/bin/python @@ -0,0 +1 @@ +python3 \ No newline at end of file diff --git a/preflight-test/bin/python3 b/preflight-test/bin/python3 new file mode 120000 index 000000000..ae65fdaa1 --- /dev/null +++ b/preflight-test/bin/python3 @@ -0,0 +1 @@ +/usr/bin/python3 \ No newline at end of file diff --git a/preflight-test/lib64 b/preflight-test/lib64 new file mode 120000 index 000000000..7951405f8 --- /dev/null +++ b/preflight-test/lib64 @@ -0,0 +1 @@ +lib \ No newline at end of file diff --git a/preflight-test/pyvenv.cfg b/preflight-test/pyvenv.cfg new file mode 100644 index 000000000..853404e23 --- /dev/null +++ b/preflight-test/pyvenv.cfg @@ -0,0 +1,3 @@ +home = /usr/bin +include-system-site-packages = false +version = 3.8.10 diff --git a/requirements.txt b/requirements.txt index 1a77082c7..d32a3e353 100644 --- a/requirements.txt +++ b/requirements.txt @@ -34,6 +34,7 @@ sphinx-copybutton==0.5.0 # Terminal typer[all]==4.8.0 PyInquirer==1.0.3 +~/catkin_ws/src/mil/mil_common/utils/mil_tools/scripts/mil-preflight/dist/mil_preflight-0.1.2-py3-none-any.whl==0.1.2 # External Devices pyserial==3.5