diff --git a/README.md b/README.md index 80ff025..9252c7e 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # ROV Code + ## Setup **Warning: if you are connected via ethernet to a router without internet connection (i.e., have the computer as a part of the surface station), you may run into weird errors, even if you have a network connection via a separate wifi connection. Therefore, make sure you are connected to the internet, and not connected to any networks without internet, to avoid issues during setup.** @@ -7,9 +8,9 @@ Install Godot, and make sure to add Godot to your path (or whatever the equivalent is on your operating system). -This project is currently made with Godot 3.5.1, standard version (Mono/C# not needed): https://github.com/godotengine/godot/releases/tag/3.5.1-stable +This project is currently made with Godot 3.5.1, standard version (Mono/C# not needed): -If you are getting a 'file not found' error around subprocesses, recheck that Godot is in your path. Otherwise contact Alnis with other errors. +If you are getting a 'file not found' error around subprocesses, recheck that Godot is in your path. Otherwise contact Alnis with other errors. On macOS, to ensure you can run Godot stuff from command line (this pretends to add Godot to path): @@ -24,6 +25,7 @@ wget https://downloads.tuxfamily.org/godotengine/3.5.1/Godot_v3.5.1-stable_x11.6 unzip Godot_v3.5.1-stable_x11.64.zip cp Godot_v3.5.1-stable_x11.64 ~/.local/bin/godot ``` + This will download Godot and add it to `PATH` (eg. you can call `godot` to launch it). ### Python Installation @@ -35,17 +37,20 @@ Also, make sure Visual Studio Code's Python package is installed. macOS: TODO Windows: -* Get installer (3.12.2) from here: https://www.python.org/downloads/release/python-3122/ + +* Get installer (3.12.2) from here: * Make sure "Add python.exe to path" is checked * Default installation is OK * Alternatively... you can type `python` into a terminal and it will launch the Microsoft Store, where you can try pressing "Get" for python. Maybe that will work (it sometimes throws an error). Linux: Use deadsnakes PPA (also installs pip) + ``` sudo add-apt-repository ppa:deadsnakes/ppa sudo apt update sudo apt install python3.12 python3.12-pip ``` + This will work for Ubuntu and other Debian-based distros. On Fedora, use `dnf` instead of `apt`, on Arch, use `pacman` instead, etc. Also make sure you have the following packages: @@ -60,21 +65,23 @@ Test websocket connection locally: ### Other Notes To get Logitech F310 controller working with macOS, check this out: -https://gist.github.com/jackblk/8138827afd986f30cf9d26647e8448e1 + Notes: -- need python3 in your path in order to launch properly -- physical.py contains stubs -- onboard.py should do heavy lifting for onboard code -- TODO: need to state what packages are needed + +* need python3 in your path in order to launch properly +* physical.py contains stubs +* onboard.py should do heavy lifting for onboard code +* TODO: need to state what packages are needed ## Running the System Connecting to the physical ROV: -`ssh pi` +`ssh rov` Password: `raspberry` (yes this is the default) Note on cameras: + ```sh pi@main:~/raspivid_mjpeg_server $ v4l2-ctl -d 4 -c exposure_auto=1,exposure_absolute=300,brightness=0,gain=100 pi@main:~/raspivid_mjpeg_server $ v4l2-ctl -d 4 -v width=1024,height=768,pixelformat='MJPG' --stream-mmap --stream-to - | raspivid_mjpeg_server -p 8554 @@ -82,52 +89,60 @@ pi@main:~/raspivid_mjpeg_server $ v4l2-ctl -d 0 -v width=1024,height=768,pixelfo ``` You can run all of this with: + ```sh ./start_cameras.sh > /dev/null 2>&1 & ``` (Bookmarked on surface station Chrome) -Front cam: http://172.25.250.1:8554/ -Down cam: http://172.25.250.1:8555/ +Front cam: +Down cam: Better balance of low light performance (~20 fps): + ```sh pi@main:~/raspivid_mjpeg_server $ v4l2-ctl -d 4 -c exposure_auto=1,exposure_absolute=500,brightness=32,contrast=32,gamma=100,gain=100,saturation=128 pi@main:~/raspivid_mjpeg_server $ v4l2-ctl -d 4 -v width=1024,height=768,pixelformat='MJPG' --stream-mmap --stream-to - | raspivid_mjpeg_server ``` +Running the cameras to collect files (no adjustment for lighting): + +```sh +pi@main:~/$ v4l2-ctl -d 4 -v width=1024,height=768,pixelformat='MJPG' --stream-mmap --stream-to='stream4.mjpg' & +pi@main:~/$ v4l2-ctl -d 0 -v width=1024,height=768,pixelformat='MJPG' --stream-mmap --stream-to='stream0.mjpg' & +``` ### Physical ROV + On the ROV, use the terminal to run launch_onboard_physical.py. The command is `python3 launch_onboard_physical.py`. (Run this command from the directory of the file.) -On the surface, open the repository in VSCode and open launch_surface.py. Press the Play button to run the file. +On the surface, open the repository in VSCode and open launch_surface.py. Press the Play button to run the file. ### Simulated ROV -On the surface (or any computer), open the repository in VSCode and open launch_full_simulation.py. Press the Play button to run the file. + +On the surface (or any computer), open the repository in VSCode and open launch_full_simulation.py. Press the Play button to run the file. ### Testing Networking + If you would like to test networking without actually running the physical ROV, run launch_surface.py on one computer, and run launch_onboard_simulation.py on another computer. ## Documentation + See in-line comments for implementation-related documentation. -The main loop for the surface is `surface.py`, and the main loop for onboard is `onboard.py`. Everything is called from there. +The main loop for the surface is `surface.py`, and the main loop for onboard is `onboard.py`. Everything is called from there. ### Overview of `surface.py` -This file initializes the core, interface, and task code. It then starts the appropriate servers and links handlers for websocket communication. - -### Overview of `onboard.py` -This file initializes onboard communication. This also parses commands and forwards them to the ROV. The code here is shared for physical and simulated ROVs. - +This file initializes the core, interface, and task code. It then starts the appropriate servers and links handlers for websocket communication. +### Overview of `onboard.py` +This file initializes onboard communication. This also parses commands and forwards them to the ROV. The code here is shared for physical and simulated ROVs. Input in z-up space, output in Godot visual Control stick yaw left (+z rotation) -> model visually moves in -x rotation Control stick roll left (+y rotation) -> model visually moves in -z rotation - - Onshape space: +x rotation -> -z +z rotation -> -x result diff --git a/start_cameras_to_file.sh b/start_cameras_to_file.sh new file mode 100644 index 0000000..e4af897 --- /dev/null +++ b/start_cameras_to_file.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +v4l2-ctl -d 4 -c exposure_auto=1,exposure_absolute=300,brightness=0,gain=100 & + +v4l2-ctl -d 4 -v width=1024,height=768,pixelformat='MJPG' --stream-mmap --stream-to='stream4.mjpg' & + +v4l2-ctl -d 0 -v width=1024,height=768,pixelformat='MJPG' --stream-mmap --stream-to='stream0.mjpg' & + +wait \ No newline at end of file