Skip to content

Commit a24a2d1

Browse files
committed
Merge branch 'master' of https://github.com/UBC-Thunderbots/Software into annie/keep_away
2 parents eedf1bf + 8c508a4 commit a24a2d1

File tree

127 files changed

+3935
-937
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

127 files changed

+3935
-937
lines changed

.github/workflows/main.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
multiplatform-build:
1515
strategy:
1616
matrix:
17-
platform: [ ubuntu-22.04, ubuntu-24.04 ]
17+
platform: [ ubuntu-24.04 ]
1818

1919
name: Ubuntu Alternate Builds
2020
runs-on: ${{ matrix.platform }}
@@ -50,7 +50,7 @@ jobs:
5050
5151
software-tests:
5252
name: Software Tests
53-
runs-on: ubuntu-20.04
53+
runs-on: ubuntu-22.04
5454
steps:
5555
# checks-out the repository under $GITHUB_WORKSPACE
5656
- uses: actions/checkout@v4
@@ -72,7 +72,7 @@ jobs:
7272
7373
robot-tests:
7474
name: Robot Software Tests
75-
runs-on: ubuntu-20.04
75+
runs-on: ubuntu-22.04
7676
steps:
7777
# checks-out the repository under $GITHUB_WORKSPACE
7878
- uses: actions/checkout@v4
@@ -108,7 +108,7 @@ jobs:
108108
109109
simulated-gameplay-tests:
110110
name: Simulated Gameplay Tests
111-
runs-on: ubuntu-20.04
111+
runs-on: ubuntu-22.04
112112
steps:
113113
# checks-out the repository under $GITHUB_WORKSPACE
114114
- uses: actions/checkout@v4
@@ -146,7 +146,7 @@ jobs:
146146
147147
autorefd-game:
148148
name: AutoRef'd Game (3 Minutes)
149-
runs-on: ubuntu-20.04
149+
runs-on: ubuntu-22.04
150150
steps:
151151
# checks-out the repository under $GITHUB_WORKSPACE
152152
- uses: actions/checkout@v4

.github/workflows/pre-commit.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ concurrency:
1414
jobs:
1515
formatting-check:
1616
name: Formatting and FSM diagram generation with pre-commit-ci-lite
17-
runs-on: ubuntu-20.04
17+
runs-on: ubuntu-22.04
1818
if: github.event.pull_request.draft == false
1919
steps:
2020
# checks-out the repository under $GITHUB_WORKSPACE
@@ -27,9 +27,9 @@ jobs:
2727
- name: Install pip
2828
run: curl -sS https://bootstrap.pypa.io/get-pip.py | python
2929

30-
- uses: pre-commit/[email protected].0
30+
- uses: pre-commit/[email protected].1
3131

32-
- uses: pre-commit-ci/lite-action@v1.0.1
32+
- uses: pre-commit-ci/lite-action@v1.1.0
3333
name: Run pre-commit-ci-lite
3434
if: always()
3535

docs/getting-started-wsl.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ If you are not using Windows 11 and would prefer not to upgrade, you can follow
3939
3. Now, let's install Ubuntu.
4040
- Download the WSL2 kernel from [here](https://docs.microsoft.com/en-us/windows/wsl/wsl2-kernel).
4141
- Open a PowerShell window and run command `wsl --set-default-version 2` to use WSL2 by default.
42-
- Install Ubuntu 20.04 LTS, Ubuntu 22.04 LTS or Ubuntu 24.04 LTS from the Microsoft Store.
42+
- Install Ubuntu 22.04 LTS or Ubuntu 24.04 LTS from the Microsoft Store.
4343
- Open the Ubuntu app in the Start menu. It will open a command prompt and ask you to create a new UNIX username and password for your WSL2 Ubuntu installation.
4444
4545
### X Server Setup

docs/getting-started.md

+15-9
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,13 @@ These instructions assume you have a basic understanding of Linux and the comman
6868

6969
We currently only support Linux, specifically Ubuntu.
7070

71-
If you have a X86_64 machine, we support Ubuntu 20.04 LTS, Ubuntu 22.04 LTS and Ubuntu 24.04 LTS.
71+
If you have a X86_64 machine, we support Ubuntu 22.04 LTS and Ubuntu 24.04 LTS.
7272

7373
If you have a ARM64 (also known as AARCH64) machine, we support Ubuntu 24.04 LTS.
7474

7575
You are welcome to use a different version or distribution of Linux, but may need to make some tweaks in order for things to work.
7676

77-
You can use Ubuntu 20.04 LTS, Ubuntu 22.04 LTS or Ubuntu 24.04 LTS inside Windows through Windows Subsystem for Linux, by following [this guide](./getting-started-wsl.md). **Running and developing Thunderbots on Windows is experimental and not officially supported.**
77+
You can use Ubuntu 22.04 LTS or Ubuntu 24.04 LTS inside Windows through Windows Subsystem for Linux, by following [this guide](./getting-started-wsl.md). **Running and developing Thunderbots on Windows is experimental and not officially supported.**
7878

7979
### Getting the Code
8080

@@ -230,13 +230,11 @@ Now that you're setup, if you can run it on the command line, you can run it in
230230

231231
- If we want to run it with real robots:
232232
- Open your terminal, `cd` into `Software/src` and run `ifconfig`.
233-
- Pick the network interface you would like to use:
234-
1. If you are running things locally, you can pick any interface that is not `lo`
235-
2. If you would like to communicate with robots on the network, make sure to select the interface that is connected to the same network as the robots.
233+
- Pick the network interface you would like to use. If you would like to communicate with robots on the network, make sure to select the interface that is connected to the same network as the robots.
236234
- For example, on a sample machine, the output may look like this:
237235

238236
```
239-
enp0s5: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
237+
wlp3s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
240238
...
241239
[omitted]
242240
...
@@ -247,22 +245,30 @@ Now that you're setup, if you can run it on the command line, you can run it in
247245
...
248246
```
249247

250-
- An appropriate interface we could choose is `enp0s5`
248+
- An appropriate interface we could choose is `wlp3s0`
249+
- Hint: If you are using a wired connection, the interface will likely start with `e-`. If you are using a WiFi connection, the interface will likely start with `w-`.
251250
- If we are running the AI as "blue": `./tbots.py run thunderscope_main --interface=[interface_here] --run_blue`
252251
- If we are running the AI as "yellow": `./tbots.py run thunderscope_main --interface=[interface_here] --run_yellow`
253252
- `[interface_here]` corresponds to the `ifconfig` interfaces seen in the previous step
254-
- For instance, a call to run the AI as blue on wifi could be: `./tbots.py run thunderscope_main --interface=enp0s5 --run_blue`
253+
- For instance, a call to run the AI as blue on WiFi could be: `./tbots.py run thunderscope_main --interface=wlp3s0 --run_blue`. This will start Thunderscope and set up communication with robots over the wifi interface. It will also listen for referee and vision messages on the same interface.
254+
- **Note: You do not need to include the `--interface=[interface_here]` argument!** You can run Thunderscope without it and use the dynamic configuration widget to set the interfaces for communication to send and receive robot, vision and referee messages.
255+
- If you choose to include `--interface=[interface_here]` argument, Thunderscope will listen for and send robot messages on this port as well as receive vision and referee messages.
256+
- Using the dynamic configuration widget is recommended at Robocup. To reduce latencies, it is recommended to connect the robot router to the AI computer via ethernet and use a separate ethernet connection to receive vision and referee messages. In this configuration, Thunderscope will need to bind to two different interfaces, each likely starting with a "e-".
257+
- If you have specified `--run_blue` or `--run_yellow`, navigate to the "Parameters" widget. In "ai_config" > "ai_control_config" > "network_config", you can set the appropriate interface using the dropdowns for robot, vision and referee message communication.
255258
- This command will set up robot communication and the Unix full system binary context manager. The Unix full system context manager hooks up our AI, Backend and SensorFusion
256259
2. Run AI along with Robot Diagnostics:
257260
- The Mechanical and Electrical sub-teams use Robot Diagnostics to test specific parts of the Robot.
258261
- If we want to run with one AI and Diagnostics
259-
- `./tbots.py run thunderscope_main [--run_blue | --run_yellow] --run_diagnostics` will start Thunderscope
262+
- `./tbots.py run thunderscope_main [--run_blue | --run_yellow] --run_diagnostics --interface=[interface_here]` will start Thunderscope
260263
- `[--run_blue | --run_yellow]` indicate which FullSystem to run
261264
- `--run_diagnostics` indicates if diagnostics should be loaded as well
262265
- Initially, the robots are all connected to the AI and only receive input from it
263266
- To change the input source for the robot, use the drop-down menu of that robot to change it between None, AI, and Manual
264267
- None means the robots are receiving no commands
265268
- More info about Manual control below
269+
- `--interface=[interface_here]` corresponds to the `ifconfig` interfaces seen in the previous step
270+
- For instance, a call to run the AI as blue on WiFi could be: `./tbots.py run thunderscope_main --interface=wlp3s0 --run_blue --run_diagnostics`
271+
- The `--interface` flag is optional. If you do not include it, you can set the interface in the dynamic configuration widget. See above for how to set the interface in the dynamic configuration widget.
266272
3. Run only Diagnostics
267273
- To run just Diagnostics
268274
- `./tbots.py run thunderscope --run_diagnostics --interface <network_interface>`

docs/wifi-communication-readme.md

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# WiFi Communication README
2+
3+
## Lessons Learned So Far
4+
1. For optimal performance, make sure that any packets sent over the network are below MTU size (1500 bytes). Packets larger than MTU size require multiple transmissions for a single send event and multiple retransmissions in the case of packet loss. Overall, these packets contribute to greater utilization of the network and increased latency.
5+
2. Connect the host computer to the network via ethernet cable when possible. By minimizing the utilization of the WiFi network, this change significantly improves the round-trip time.
6+
3. Use unicast communication over WiFi for frequent, low-latency communication over multicast. [RFC 9119](https://www.rfc-editor.org/rfc/rfc9119.html#section-3.1.2) provides a good overview of the limitations of multicast communication over WiFi. In short, routers are forced to transmit at the lowest common data rate of all devices on the network to ensure that all devices receive the packet, meaning that the network is slowed down by the slowest device. In addition, router features such as Multiple Input Multiple Output (MIMO) may not be available when using multicast communication. We have found a 24% improvement in round-trip time when switching from multicast to unicast communication with some benchmarking tests.
7+
4. On embedded Linux devices, WiFi power management seems to cause significant latency spikes. To disable power management, run the following command: `sudo iw dev {wifi_interface} set power_save off` where `{wifi_interface}` is the name of the WiFi interface (e.g. `wlan0`).
8+
9+
10+
## Debugging
11+
12+
We have built some tools to help diagnose network latency problems without the confounding effects of running Thunderloop and Thunderscope and their associated overheads.
13+
14+
The latency tester tests the round trip time between two nodes. The primary node sends a message to the secondary node, which sends back the same message as soon as it receives it. The primary node then measures the round trip time.
15+
16+
Typically, the primary node is the host computer and the secondary node is the robot.
17+
18+
## Running the latency tester with the robot
19+
### Prerequisites
20+
You must know:
21+
- The IP address of the robot. We will refer to this address as `{robot_ip}`.
22+
- The WiFi interface of the robot. We will refer to this interface as `{robot_wifi_interface}`. This interface is typically found by running `ifconfig` or `ip a` on the robot.
23+
- The network interface of the host computer. We will refer to this interface as `{host_interface}`. This interface is typically found by running `ifconfig` or `ip a` on the host computer.
24+
25+
1. Build the latency tester secondary node: `./tbots.py build latency_tester_secondary_node --platforms=//cc_toolchain:robot`
26+
2. Copy the binary to the robot: `scp bazel-bin/software/networking/benchmarking_utils/latency_tester_secondary_node robot@{robot_ip}:/home/robot/latency_tester_secondary_node`
27+
3. SSH into the robot: `ssh robot@{robot_ip}`
28+
4. There are two test modes: multicast or unicast
29+
1. For multicast:
30+
1. Run the latency tester secondary node: `./latency_tester_secondary_node --interface {robot_wifi_interface}`
31+
- You may optionally also provide the following arguments:
32+
- `--runtime_dir` to specify the directory where log files are stored
33+
- `--listen_port` to specify the port on which the secondary node listens for messages.
34+
- `--send_port` to specify the port on which the secondary node sends messages
35+
- `--listen_channel` to specify the channel on which the secondary node listens for messages
36+
- `--send_channel` to specify the channel on which the secondary node sends back replies
37+
2. On a different terminal on the host computer, run the latency tester primary node: `./tbots.py run latency_tester_primary_node -- --interface {host_interface}`
38+
- You may optionally also provide the following arguments:
39+
- `--runtime_dir` to specify the directory where log files are stored
40+
- `--listen_port` to specify the port on which the primary node listens for replies to messages. This port must match the `--send_port` argument provided to the secondary node.
41+
- `--send_port` to specify the port on which the primary node sends messages. This port must match the `--listen_port` argument provided to the secondary node.
42+
- `--listen_channel` to specify the channel on which the primary node listens for replies to messages. This channel must match the `--send_channel` argument provided to the secondary node.
43+
- `--send_channel` to specify the channel on which the primary node sends messages. This channel must match the `--listen_channel` argument provided to the secondary node.
44+
- `--num_messages` to specify the number of messages to send
45+
- `--message_size_bytes` to specify the size of the message payload in bytes
46+
- `--timeout_duration_ms` to specify the duration in milliseconds to wait for a reply before retransmitting the message
47+
- `--initial_delay_s` to specify the delay in seconds before sending the first message
48+
2. For unicast:
49+
1. Run the latency_tester_secondary_node: `./latency_tester_secondary_node --interface {robot_wifi_interface} --unicast`
50+
- You may optionally also provide the following arguments:
51+
- `--runtime_dir` to specify the directory where log files are stored
52+
- `--listen_port` to specify the port on which the secondary node listens for messages.
53+
- `--send_port` to specify the port on which the secondary node sends messages
54+
- `--send_ip` to specify the IP address of the primary node to send replies to
55+
2. On a different terminal on the host computer, run the latency_tester_primary_node: `./tbots.py run latency_tester_primary_node -- --interface {host_interface} --unicast`
56+
- You may optionally also provide the following arguments:
57+
- `--runtime_dir` to specify the directory where log files are stored
58+
- `--listen_port` to specify the port on which the primary node listens for replies to messages. This port must match the `--send_port` argument provided to the secondary node.
59+
- `--send_port` to specify the port on which the primary node sends messages. This port must match the `--listen_port` argument provided to the secondary node.
60+
- `--send_ip` to specify the IP address of the secondary node to send messages to (`{robot_ip}`)
61+
- `--num_messages` to specify the number of messages to send
62+
- `--message_size_bytes` to specify the size of the message payload in bytes
63+
- `--timeout_duration_ms` to specify the duration in milliseconds to wait for a reply before retransmitting the message
64+
- `--initial_delay_s` to specify the delay in seconds before sending the first message
65+
3. This tool can also be run with Tracy, a profiling tool, which provides some nice performance visualizations and histograms. To do so:
66+
1. Make sure Tracy has been installed. Run `./environment_setup/install_tracy.sh` to install Tracy.
67+
2. On a new terminal in the host computer run Tracy: `./tbots.py run tracy`
68+
3. When running the latency tester primary node, add the `--tracy` flag to the command before the `--`. For example: `./tbots.py run latency_tester_primary_node --tracy -- --interface {host_interface}`
69+
4. Tracy will allow you to select the binary to profile and provide detailed performance information after the tester has run.

environment_setup/install_tracy.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ CURR_DIR=$(dirname -- "$(readlink -f -- "$BASH_SOURCE")")
66
cd "$CURR_DIR" || exit
77

88
# Install dependences
9-
sudo apt install libglfw3-dev libfreetype-dev libdbus-1-dev
9+
sudo apt install -y libglfw3-dev libfreetype-dev libdbus-1-dev
1010

1111
# Install capstone-next
1212
wget -nc https://github.com/capstone-engine/capstone/archive/refs/tags/5.0.1.zip -O /tmp/capstone.zip

environment_setup/setup_software.sh

+9
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,11 @@ if [[ $(lsb_release -rs) == "22.04" ]] || [[ $(lsb_release -rs) == "24.04" ]]; t
104104
sudo mv /tmp/tbots_download_cache/85-brltty.rules /usr/lib/udev/rules.d/85-brltty.rules
105105
fi
106106

107+
if [[ $(lsb_release -rs) == "22.04" ]]; then
108+
# This is required for clang-format
109+
host_software_packages+=(libtinfo5)
110+
fi
111+
107112
virtualenv_opt_args=""
108113
if [[ $(lsb_release -rs) == "24.04" ]]; then
109114
host_software_packages+=(python3-pyqt6)
@@ -211,4 +216,8 @@ sudo ln -s ~/.platformio/penv/bin/platformio /usr/local/bin/platformio
211216

212217
print_status_msg "Done PlatformIO Setup"
213218

219+
print_status_msg "Set up ansible-lint"
220+
/opt/tbotspython/bin/ansible-galaxy collection install ansible.posix
221+
print_status_msg "Finished setting up ansible-lint"
222+
214223
print_status_msg "Done Software Setup, please reboot for changes to take place"

environment_setup/ubuntu20_requirements.txt

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
ansible-lint==24.12.2
12
pyqtgraph==0.13.7
23
pyqt6==6.6.1
34
PyQt6-Qt6==6.6.1
@@ -7,3 +8,4 @@ python-Levenshtein==0.25.1
78
psutil==5.9.0
89
PyOpenGL==3.1.6
910
ruff==0.5.5
11+
pyqt-toast-notification==1.3.2

environment_setup/ubuntu22_requirements.txt

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
ansible-lint==24.12.2
12
pyqtgraph==0.13.7
23
pyqt6==6.6.1
34
PyQt6-Qt6==6.6.1
@@ -8,3 +9,4 @@ psutil==5.9.0
89
PyOpenGL==3.1.6
910
numpy==1.26.4
1011
ruff==0.5.5
12+
pyqt-toast-notification==1.3.2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
ansible-lint==24.12.2
12
pyqtgraph==0.13.7
23
thefuzz==0.19.0
34
iterfzf==0.5.0.20.0
45
python-Levenshtein==0.25.1
56
psutil==5.9.0
67
PyOpenGL==3.1.6
78
ruff==0.5.5
9+
pyqt-toast-notification==1.3.2

scripts/lint_and_format.sh

+13
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,25 @@ function run_eof_new_line(){
119119
fi
120120
}
121121

122+
function run_ansible_lint(){
123+
printf "Running ansible-lint...\n\n"
124+
125+
/opt/tbotspython/bin/ansible-lint $CURR_DIR/../src/software/embedded/ansible/**/*.yml --fix
126+
127+
if [[ "$?" != 0 ]]; then
128+
printf "\n***Failed to lint and format Ansible files!***\n\n"
129+
exit 1
130+
fi
131+
}
132+
133+
122134
# Run formatting
123135
run_code_spell
124136
run_clang_format
125137
run_bazel_formatting
126138
run_ruff
127139
run_eof_new_line
128140
run_git_diff_check
141+
run_ansible_lint
129142

130143
exit 0

src/proto/BUILD

+4
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@ proto_library(
1111
"game_state.proto",
1212
"geneva_slot.proto",
1313
"geometry.proto",
14+
"ip_notification.proto",
1415
"parameters.proto",
1516
"play.proto",
1617
"power_frame_msg.proto",
1718
"primitive.proto",
19+
"replay_bookmark.proto",
1820
"robot_crash_msg.proto",
1921
"robot_log_msg.proto",
2022
"robot_statistic.proto",
@@ -50,9 +52,11 @@ py_proto_library(
5052
"game_state.proto",
5153
"geneva_slot.proto",
5254
"geometry.proto",
55+
"ip_notification.proto",
5356
"parameters.proto",
5457
"play.proto",
5558
"primitive.proto",
59+
"replay_bookmark.proto",
5660
"robot_statistic.proto",
5761
"robot_status_msg.proto",
5862
"tactic.proto",

src/proto/ip_notification.proto

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
syntax = "proto3";
2+
3+
import "proto/tbots_timestamp_msg.proto";
4+
5+
package TbotsProto;
6+
7+
message IpNotification
8+
{
9+
int32 robot_id = 1;
10+
string ip_address = 2;
11+
}

0 commit comments

Comments
 (0)