Skip to content

Commit 5ae4641

Browse files
authored
add tutorials (#10)
* tutorial upload * Update Streaming.md * add static link * updated tutorial and README
1 parent 45a8975 commit 5ae4641

20 files changed

+683
-4
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,5 @@ build
2424
*.pytest_cache
2525

2626
photos
27-
venv
27+
venv
28+
myenv/

README.md

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,34 @@
11
# NEW EVA 2025
2+
EVA is PoliTOcean main ROV ready for MATE Competition.
3+
4+
<p align="center">
5+
<img src="docs/eva.png" width="60%" height="60%">
6+
</p>
7+
<p align="center">
8+
<img src="docs/cad.png" width="60%" height="60%">
9+
</p>
10+
11+
## Overview
12+
The ROV’s software stack is built around three integrated components: NEXUS, Oceanix, and STM Nucleo firmware. NEXUS, running on the control station, delivers real-time video, telemetry, and control to the pilot. Oceanix, hosted on a Raspberry Pi 5, handles mission logic, sensor fusion, and dynamic thrust allocation. The STM Nucleo executes low-level motor and actuator control via lightweight firmware, offering additional GPIOs with PWM support at very low cost. These components communicate via MQTT, I²C and a custom serial protocol, ensuring modularity, low latency, and robustness.
13+
The decision to adopt the Raspberry Pi 5 over alternatives like the NVIDIA Jetson Nano was driven by its efficiency, lower power consumption, and cost-effectiveness. While the Jetson’s GPU acceleration benefits AI workloads, our architecture prioritizes real-time control, sensor polling and network communication (tasks where the Pi 5's CPU is more than sufficient). Similarly, the STM Nucleo adds PWM-capable GPIOs and supports a modular architecture at minimal cost. This design allows us to upgrade sensors or control logic with minimal effort, supporting rapid development and scalability.
214
<p align="center">
3-
<img src="docs/eva.jpg" width="60%" height="60%">
15+
<img src="docs/Software_SID.png" width="60%" height="60%">
416
</p>
517

6-
## Components
7-
The firmware for a specific component can be find in [this](firmware/) directory...
18+
19+
## NEXUS
20+
NEXUS is implemented as a Flask‑based Python application that delivers a desktop‑style web interface to the ROV pilot. Within the browser window, operators see five live feeds from the Raspberry Pi 5. This year, we upgraded the streaming system to WebRTC, enabling GPU-accelerated rendering of the video directly in the browser. This allowed us to reduce latency by up to 200 ms and add real-time lens distortion correction for improved camera visualization, while fully leveraging the onboard H.264 encoding of the two front cameras. Alongside the video panels, dynamic charts visualize the ROV’s attitude (roll, pitch, yaw) and depth readings from the Bar02 sensor. Float functions are accessed through a dedicated section. Commands, from joystick movements to arm actuation, are serialized as JSON and sent over MQTT to Oceanix.
21+
22+
## Oceanix
23+
Oceanix is our C++ application running on the Raspberry Pi 5, structured in an object‑oriented paradigm to isolate sensors, controllers and communication services. The Pi hosts a Mosquitto MQTT broker that relays messages between NEXUS, the debug tool and Oceanix itself. Joystick inputs arrive on the command topic, the resulting force and moment vectors feed a thrust allocation algorithm that computes individual PWM setpoints for eight thrusters.
24+
These setpoints are forwarded over a high‑speed UART link to the STM Nucleo board. Simultaneously, Oceanix polls the onboard IMU and Bar02 sensor at 200 Hz via I²C, combining accelerometer, gyroscope and pressure data in a complementary filter to estimate depth and attitude.
25+
26+
## STM Nucleo
27+
On the NUCLEO‑L432KC board, a bare‑metal C application built on ST’s HAL libraries listens on UART for a continuous stream of PWM duty‑cycle values and servo positions sent by Oceanix at 100 Hz. Each packet includes a CRC to verify integrity; in the event of a CRC failure, the firmware retains the previous command until valid data resumes. Hardware timers generate PWM signals with 1 µs resolution, which drive optocouplers feeding our motor driver MOSFETs. For arm control, a specially designed packet is received to regulate the actuator and driver, including their speed and direction. The firmware’s emphasis on deterministic timing and minimal interrupt jitter guarantees that high‑frequency control loops run reliably, enabling both precise thrust control and smooth manipulator operation.
28+
29+
## Helper
30+
For deeper analysis and tuning, we maintain a companion Python/Tk debug tool that connects via MQTT to display raw sensor dumps, per‑motor thrust values, live logs and adjustable control‑loop parameters such as controller gains. This app is divided into windows, is very good for lab testing since all essentials commands can be send to Oceanix, also statuses are printed along with real time plot for controller tuning, camera streamning can be tested and snapshot can be taken, also the configuration page edits the config.json on the Raspberry Pi.
31+
32+
# Usage
33+
in rasp_setup all tutorial for setting up a new raspberry are contained, focusing on the handling of the camera also in general .
34+
usage.md contains instructions for EVA.
File renamed without changes.

docs/Software_SID.png

343 KB
Loading

docs/cad.png

977 KB
Loading

docs/eva.jpg

-164 KB
Binary file not shown.

docs/eva.png

1.61 MB
Loading

rasp_setup/Camera static link.md

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
## 🎯 **Goal**
2+
3+
Instead of dealing with changing `/dev/video4`, `/dev/video6`, etc., we want:
4+
5+
```bash
6+
/dev/camera-bottom
7+
/dev/camera-top
8+
/dev/camera-main
9+
/dev/camera-right
10+
/dev/camera-arm
11+
```
12+
13+
that always point to the correct camera, based on which USB port it’s plugged into.
14+
15+
---
16+
17+
## 🧰 Prerequisites
18+
19+
Make sure you have:
20+
21+
* `v4l-utils` installed (for `v4l2-ctl`)
22+
* root access (`sudo`)
23+
24+
If not already installed:
25+
26+
```bash
27+
sudo apt update
28+
sudo apt install v4l-utils
29+
```
30+
31+
---
32+
33+
## 📝 Step 1: List Video Devices
34+
35+
List your connected cameras and the video devices they expose:
36+
37+
```bash
38+
v4l2-ctl --list-devices
39+
```
40+
41+
You'll see output like:
42+
43+
```
44+
HD USB CAMERA: HD USB CAMERA (usb-xhci-hcd.0-2.2):
45+
/dev/video4
46+
/dev/video5
47+
48+
exploreHD USB Camera: exploreHD (usb-xhci-hcd.0-2.4):
49+
/dev/video8
50+
/dev/video9
51+
```
52+
53+
exploreHD USB Cameras are managed by DWE OS that already uses static path, so ignore these cameras in this tutorial
54+
55+
---
56+
57+
## 🔍 Step 2: Find the `ID_PATH` for the Correct Device
58+
59+
Pick the device that corresponds to the **stream you want to use** (e.g. `/dev/video4`), then run:
60+
61+
```bash
62+
udevadm info /dev/video4 | grep ID_PATH
63+
```
64+
65+
You'll get something like:
66+
67+
```
68+
E: ID_PATH=platform-xhci-hcd.0-usb-0:2.2:1.0
69+
```
70+
71+
Write that down — that's the stable ID of that USB port.
72+
73+
Repeat this for all cameras you want to assign.
74+
75+
---
76+
77+
## 🧩 Step 3: Create a udev Rule File
78+
79+
Create a new udev rules file:
80+
81+
```bash
82+
sudo nano /etc/udev/rules.d/99-usb-cameras.rules
83+
```
84+
85+
Add one line per camera, like this:
86+
87+
```udev
88+
# Bottom camera
89+
SUBSYSTEM=="video4linux", ENV{ID_PATH}=="platform-xhci-hcd.0-usb-0:2.2:1.0", ATTR{index}=="0", SYMLINK+="camera-bottom"
90+
91+
# Top camera
92+
SUBSYSTEM=="video4linux", ENV{ID_PATH}=="platform-xhci-hcd.0-usb-0:2.3:1.0", ATTR{index}=="0", SYMLINK+="camera-top"
93+
```
94+
95+
📌 **Make sure you adjust the `ID_PATH` values** to the correct ones from your own system.
96+
the ATTR{index}=="0" is to make sure we are selecting the right interface of the camera, for the DWE camera the index is 2 to use H.264
97+
98+
---
99+
100+
## 🔄 Step 4: Reload udev and Trigger
101+
102+
```bash
103+
sudo udevadm control --reload-rules
104+
sudo udevadm trigger
105+
```
106+
107+
Then check:
108+
109+
```bash
110+
ls -l /dev/camera-*
111+
```
112+
113+
You should see:
114+
115+
```
116+
/dev/camera-bottom -> video4
117+
/dev/camera-top -> video6
118+
...
119+
```
120+
121+
🎉 Done!

rasp_setup/Camera tutorial.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Linux Camera Systems
2+
3+
Cameras in Linux are seen as `/dev/video*`. They have different output formats and resolutions. To check the available formats, use the following command:
4+
5+
```bash
6+
v4l2-ctl -d /dev/video0 --list-formats-ext
7+
```
8+
9+
after the camera static link setup is best to use:
10+
11+
```bash
12+
v4l2-ctl -d /dev/camera-main --list-formats-ext
13+
```
14+
also to check that the ATTR{index} is set up correctly.
15+
16+
## Camera Formats Explained
17+
18+
The formats can be MJPG or H264:
19+
20+
- **MJPG (Motion JPEG)**: A series of JPEG images sent in sequence.
21+
- Pros: Higher quality, widely supported
22+
- Cons: Higher bandwidth usage, must be transcoded for efficient streaming
23+
- Must be encoded to H264 for efficient network streaming
24+
- May introduce lag on the client side due to decoding overhead
25+
- To stream in MJPG use ustreamer, easy to set up and easy to work with, also with the snapshots
26+
27+
- **H264**: A compressed video format
28+
- Pros: Already compressed, lower bandwidth, ready for Real-Time Communication (RTC)
29+
- Cons: May have slightly lower quality than MJPG at the same bitrate
30+
- DWE cameras can output compressed H264 natively and are streamed directly with DWE OS 2
31+
32+
## Camera Identification
33+
34+
To understand which camera is associated with a specific `/dev/video*`, use the following command:
35+
36+
```bash
37+
v4l2-ctl --list-devices
38+
```
39+
40+
This script will list all video devices and their corresponding camera models/types.
41+
42+
43+
## Port Configuration and Janus Integration
44+
45+
Both DWE_OS_2 and GStreamer streams should target `127.0.0.1` (localhost), which is where Janus is running. The port selected for each camera stream must match the corresponding port defined in the Janus streaming configuration file (`janus.plugin.streaming.cfg`). In NEXUS, the different camera streams are then identified and displayed using their respective IDs configured in Janus.

rasp_setup/Install Oceanix.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
To install Oceanix:
2+
3+
1. Clone the Oceanix repository:
4+
```bash
5+
git clone https://github.com/PoliTOcean/Oceanix.git
6+
cd Oceanix
7+
```
8+
9+
2. Source the install script:
10+
```bash
11+
source install.sh
12+
```
13+
14+
3. To use I2C, enable it:
15+
16+
* Open the Raspberry Pi configuration:
17+
```bash
18+
sudo raspi-config
19+
```
20+
* Navigate to `Interface Options` -> `I2C` -> `<Yes>` to enable it.
21+
* Reboot the Raspberry Pi for the changes to take effect:
22+
```bash
23+
sudo reboot
24+
```
25+
26+
4. Automatic Execution with Systemd
27+
28+
To automatically start Oceanix as a service on boot, you can use systemd.
29+
30+
* Create the `oceanix.service` file in `/etc/systemd/system/`:
31+
32+
```bash
33+
sudo nano /etc/systemd/system/oceanix.service
34+
```
35+
36+
* Add the following content to the `oceanix.service` file:
37+
38+
```
39+
[Unit]
40+
Description=Oceanix Service
41+
After=network.target
42+
43+
[Service]
44+
ExecStart=/usr/bin/chrt -f 99 /home/politocean/firmware/Oceanix/build/Oceanix
45+
WorkingDirectory=/home/politocean/firmware/Oceanix/build
46+
Restart=always
47+
User=root
48+
Environment=DISPLAY=:0
49+
CPUSchedulingPolicy=fifo
50+
CPUSchedulingPriority=99
51+
52+
[Install]
53+
WantedBy=multi-user.target
54+
```
55+
56+
* **Important:** Verify that the `ExecStart` and `WorkingDirectory` paths are correct for your Oceanix installation. The `User` should be the user that owns the Oceanix installation.
57+
58+
* Enable the Oceanix service:
59+
60+
```bash
61+
sudo systemctl enable oceanix.service
62+
```
63+
64+
* restart the Oceanix service:
65+
66+
```bash
67+
sudo systemctl restart oceanix.service
68+
```
69+
70+
* Start the Oceanix service:
71+
72+
```bash
73+
sudo systemctl start oceanix.service
74+
```
75+
76+
* Check the status of the Oceanix service:
77+
78+
```bash
79+
sudo systemctl status oceanix.service
80+
```
81+
82+
* To stop the Oceanix service:
83+
84+
```bash
85+
sudo systemctl stop oceanix.service
86+
```
87+
88+
* To disable the Oceanix service:
89+
90+
```bash
91+
sudo systemctl disable oceanix.service
92+
```

0 commit comments

Comments
 (0)