Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/UBC-Thunderbots/Software
Browse files Browse the repository at this point in the history
…into 1
  • Loading branch information
AmyKawa committed Nov 9, 2024
2 parents 7df478c + 10bded3 commit 99e7f6a
Show file tree
Hide file tree
Showing 257 changed files with 3,665 additions and 3,078 deletions.
79 changes: 49 additions & 30 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,16 @@ concurrency:
cancel-in-progress: true

jobs:
ubuntu22-tests:
name: Ubuntu 22.04 Build
runs-on: ubuntu-22.04
multiplatform-build:
strategy:
matrix:
platform: [ ubuntu-22.04, ubuntu-24.04 ]

name: Ubuntu Alternate Builds
runs-on: ${{ matrix.platform }}
steps:
# checks-out the repository under $GITHUB_WORKSPACE
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Environment Setup
run: |
Expand All @@ -25,24 +29,31 @@ jobs:
- name: Software Build Test
run: |
cd src
bazel build --show_timestamps \
-- //... -//software:unix_full_system \
-//software/simulated_tests/... \
-//software/ai/hl/... \
-//software/field_tests/... \
-//software/jetson_nano/... \
bazel build --show_timestamps --copt=-O3 \
-- //... -//software:unix_full_system \
-//software/simulated_tests/... \
-//software/ai/hl/... \
-//software/field_tests/... \
-//software/embedded/... \
-//cc_toolchain/...
- name: Jetson Nano Build Test
run: |
cd src
bazel build --cpu=jetson_nano //software/jetson_nano:thunderloop_main --copt=-O3
bazel build //software/embedded:thunderloop_main --copt=-O3 --//software/embedded:host_platform=NANO --platforms=//cc_toolchain:robot
- name: Raspberry Pi Build Test
run: |
cd src
bazel build //software/embedded:thunderloop_main --copt=-O3 --//software/embedded:host_platform=PI --platforms=//cc_toolchain:robot
software-tests:
name: Software Tests
runs-on: ubuntu-20.04
steps:
# checks-out the repository under $GITHUB_WORKSPACE
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Environment Setup
run: |
Expand All @@ -56,14 +67,15 @@ jobs:
-//software/simulated_tests/... \
-//software/ai/hl/... \
-//software/field_tests/... \
-//software/ai/navigator/...
-//software/ai/navigator/... \
-//cc_toolchain/...
jetson-nano-tests:
name: Jetson Nano Software Tests
robot-tests:
name: Robot Software Tests
runs-on: ubuntu-20.04
steps:
# checks-out the repository under $GITHUB_WORKSPACE
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Environment Setup
run: |
Expand All @@ -85,14 +97,21 @@ jobs:
- name: Jetson Nano Build
run: |
cd src
bazel build --cpu=jetson_nano //software/jetson_nano:thunderloop_main --copt=-O3
bazel build //software/embedded:thunderloop_main --copt=-O3 --//software/embedded:host_platform=NANO --platforms=//cc_toolchain:robot
- name: Raspberry Pi Build
run: |
cd src
bazel build //software/embedded:thunderloop_main --copt=-O3 --//software/embedded:host_platform=PI --platforms=//cc_toolchain:robot
simulated-gameplay-tests:
name: Simulated Gameplay Tests
runs-on: ubuntu-20.04
steps:
# checks-out the repository under $GITHUB_WORKSPACE
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Environment Setup
run: |
Expand All @@ -102,35 +121,35 @@ jobs:
run: |
cd src
bazel test --copt=-O3 --flaky_test_attempts=3 --show_timestamps \
//software:unix_full_system \
//software/simulated_tests/... \
//software/ai/hl/... \
//software:unix_full_system \
//software/simulated_tests/... \
//software/ai/hl/... \
//software/ai/navigator/...
- name: Upload simulated test proto logs
# Ensure that simulated test logs get uploaded
if: always()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: blue-ai-proto-logs
name: blue-sim-test-proto-logs
path: |
/tmp/tbots/blue/logs
/tmp/tbots/blue/test/*/proto_*
- name: Upload simulated test proto logs
# Ensure that simulated test logs get uploaded
if: always()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: yellow-ai-proto-logs
name: yellow-sim-test-proto-logs
path: |
/tmp/tbots/yellow/logs
/tmp/tbots/yellow/test/*/proto_*
autorefd-game:
name: AutoRef'd Game (3 Minutes)
runs-on: ubuntu-20.04
steps:
# checks-out the repository under $GITHUB_WORKSPACE
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Environment Setup
run: |
Expand All @@ -144,7 +163,7 @@ jobs:
- name: Upload AI vs AI logs
# Ensure that simulated test logs get uploaded
if: always()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: blue-ai-vs-ai-proto-logs
path: |
Expand All @@ -153,7 +172,7 @@ jobs:
- name: Upload AI vs AI logs
# Ensure that simulated test logs get uploaded
if: always()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: yellow-ai-vs-ai-proto-logs
path: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
if: github.event.pull_request.draft == false
steps:
# checks-out the repository under $GITHUB_WORKSPACE
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Environment Setup
run: |
Expand Down
30 changes: 15 additions & 15 deletions docs/fsm-diagrams.md
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,21 @@ Terminate:::terminate --> Terminate:::terminate
```

## [HaltFSM](/src/software/ai/hl/stp/tactic/halt/halt_fsm.h)

```mermaid
stateDiagram-v2
classDef terminate fill:white,color:black,font-weight:bold
direction LR
[*] --> StopState
StopState --> StopState : [!stopDone]\n<i>updateStop</i>
StopState --> Terminate:::terminate : [stopDone]\n<i>updateStop</i>
Terminate:::terminate --> StopState : [!stopDone]\n<i>updateStop</i>
Terminate:::terminate --> Terminate:::terminate : [stopDone]\n<i>updateStop</i>
```

## [KickFSM](/src/software/ai/hl/stp/tactic/kick/kick_fsm.h)

```mermaid
Expand Down Expand Up @@ -441,18 +456,3 @@ Terminate:::terminate --> Terminate:::terminate : <i>SET_STOP_PRIMITIVE_ACTION</
```

## [StopFSM](/src/software/ai/hl/stp/tactic/stop/stop_fsm.h)

```mermaid
stateDiagram-v2
classDef terminate fill:white,color:black,font-weight:bold
direction LR
[*] --> StopState
StopState --> StopState : [!stopDone]\n<i>updateStop</i>
StopState --> Terminate:::terminate : [stopDone]\n<i>updateStop</i>
Terminate:::terminate --> StopState : [!stopDone]\n<i>updateStop</i>
Terminate:::terminate --> Terminate:::terminate : [stopDone]\n<i>updateStop</i>
```

2 changes: 1 addition & 1 deletion docs/getting-started-wsl.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ If you are not using Windows 11 and would prefer not to upgrade, you can follow
3. Now, let's install Ubuntu.
- Download the WSL2 kernel from [here](https://docs.microsoft.com/en-us/windows/wsl/wsl2-kernel).
- Open a PowerShell window and run command `wsl --set-default-version 2` to use WSL2 by default.
- Install Ubuntu 20.04 LTS or Ubuntu 22.04 LTS from the Microsoft Store.
- Install Ubuntu 20.04 LTS, Ubuntu 22.04 LTS or Ubuntu 24.04 LTS from the Microsoft Store.
- 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.

### X Server Setup
Expand Down
43 changes: 27 additions & 16 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
Table of Contents
=================
<!--
NOTE: when creating or re-creating a table of contents like this, you can
save a LOT of time by using this tool:
https://github.com/ekalinin/github-markdown-toc
-->
Table of Contents
=================

* [Software Setup](#software-setup)
* [Introduction](#introduction)
Expand All @@ -30,8 +25,8 @@ Table of Contents
* [Profiling](#profiling)
* [Callgrind](#callgrind)
* [Tracy](#tracy)
* [Building for Jetson Nano](#building-for-jetson-nano)
* [Deploying to Jetson Nano](#deploying-to-jetson-nano)
* [Building for the robot](#building-for-the-robot)
* [Deploying Robot Software to the robot](#deploying-robot-software-to-the-robot)
* [Setting up Virtual Robocup 2021](#setting-up-virtual-robocup-2021)
* [Setting up the SSL Simulation Environment](#setting-up-the-ssl-simulation-environment)
* [Pushing a Dockerfile to dockerhub](#pushing-a-dockerfile-to-dockerhub)
Expand All @@ -49,6 +44,14 @@ Table of Contents
* [Example Workflow](#example-workflow)
* [Testing](#testing)

<!--
Created by https://github.com/ekalinin/github-markdown-toc
NOTE: when creating or re-creating a table of contents like this, you can
save a LOT of time by using this tool:
https://github.com/ekalinin/github-markdown-toc
-->

# Software Setup

## Introduction
Expand All @@ -63,9 +66,15 @@ These instructions assume you have a basic understanding of Linux and the comman

### Operating systems

We currently only support Linux, specifically Ubuntu 20.04 LTS and Ubuntu 22.04 LTS. 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.
We currently only support Linux, specifically Ubuntu.

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

You can use Ubuntu 20.04 LTS and Ubuntu 22.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.**
If you have a ARM64 (also known as AARCH64) machine, we support Ubuntu 24.04 LTS.

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.

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.**

### Getting the Code

Expand Down Expand Up @@ -339,17 +348,19 @@ Tracy also samples call stacks. If the profiled binary is run with root permissi

./tbots.py run thunderscope_main --tracy --sudo

## Building for Jetson Nano
## Building for the robot

To build for the Jetson Nano, build the target with the `--cpu=jetson_nano` flag and the toolchain will automatically build using the ARM toolchain for Jetson Nano. For example, `bazel build --cpu=jetson_nano //software/geom/...`.
To build for the robot computer, build the target with the `--platforms=//cc_toolchain:robot` flag and the toolchain will automatically build using the ARM toolchain. For example, `bazel build --platforms=//cc_toolchain:robot //software/geom/...`.

## Deploying to Jetson Nano
## Deploying Robot Software to the robot

We use ansible to automatically update software running on the Jetson Nano. [More info here.](useful-robot-commands.md#flashing-the-nano)
We use Ansible to automatically update software running on the robot. [More info here.](useful-robot-commands.md#flashing-the-robots-compute-module)

To update binaries on a working robot, you can run:

`bazel run //software/jetson_nano/ansible:run_ansible --cpu=jetson_nano -- --playbook deploy_nano.yml --hosts <robot_ip> --ssh_pass <jetson_nano_password>`
`bazel run //software/embedded/ansible:run_ansible --platforms=//cc_toolchain:robot --//software/embedded:host_platform=<platform> -- --playbook deploy_robot_software.yml --hosts <robot_ip> --ssh_pass <robot_password>`

Where `<platform>` is the robot platform you are deploying to (`PI` or `NANO`), and `<robot_ip>` is the IP address of the robot you are deploying to. The `robot_password` is the password used to login to the `robot` user on the robot.

## Setting up Virtual Robocup 2021

Expand Down
19 changes: 7 additions & 12 deletions docs/robot-software-architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@

## Ansible

[Ansible](https://www.ansible.com/overview/how-ansible-works) allows us to run actions on multiple robots at once. Actions are communicated through YAML files called playbooks. Playbooks contain a series of tasks (ex move a file, run this script, output this command) and logic dictating dependencies between tasks. When playbooks are run, Ansible establishes an SSH connection between the user's computer and target Jetson Nanos, allowing it to run the tasks in the playbook. Output from each task, and any other requested output, is displayed on the console
[Ansible](https://www.ansible.com/overview/how-ansible-works) allows us to run actions on multiple robots at once. Actions are communicated through YAML files called playbooks. Playbooks contain a series of tasks (eg. move a file, run this script, output this command) and logic dictating dependencies between tasks. When playbooks are run, Ansible establishes an SSH connection between the user's computer and robot, allowing it to run the tasks in the playbook. Output from each task, and any other requested output, is displayed on the console

For a more detailed look at how Ansible works, [see the RFC](https://docs.google.com/document/d/1hN3Us2Vjr8z6ihqUVp_3L7rrjKc-EZ-l2hZJc31gNOc/edit)

Example command: `bazel run //software/jetson_nano/ansible:run_ansible --cpu=jetson_nano -- --playbook deploy_nano.yml --hosts <robot_ip> --ssh_pass <jetson_nano_password>`
Example command: `bazel run //software/embedded/ansible:run_ansible --platforms=//cc_toolchain:robot --//software/embedded:host_platform=<platform> -- --playbook deploy_robot_software.yml --hosts <robot_ip> --ssh_pass <robot_password>`
* <platform>: `PI` or `NANO` depending on the computer on the robot
* <robot_ip>: IP address of the robot
* <robot_password>: Password of the robot

More commands available [here](useful-robot-commands.md#off-robot-commands)

Expand All @@ -36,14 +39,6 @@ To learn more about how it works, [see the RFC](https://docs.google.com/document

# Thunderloop

Thunderloop is software that runs in a loop. It continuously polls services (unrelated from Systemd) sending relevant control proto (`PowerControl`, `MotorControl`) and receiving back status proto. Currently we have a [Network](https://github.com/UBC-Thunderbots/Software/blob/master/src/software/jetson_nano/services/network/network.cpp), [Power](https://github.com/UBC-Thunderbots/Software/blob/master/src/software/jetson_nano/services/power.cpp) and [Motor service](https://github.com/UBC-Thunderbots/Software/blob/master/src/software/jetson_nano/services/motor.cpp). Thunderloop also receives `World` and `PrimitiveSet` Proto from AI and sends back Robot Status.
Thunderloop is software that runs in a loop. It continuously polls services (unrelated from Systemd), sending relevant control protos (`PowerControl`, `MotorControl`) and receiving back status protos from the power and motor boards. Currently we have a [Network](https://github.com/UBC-Thunderbots/Software/blob/master/src/software/embedded/services/network/network.cpp), [Power](https://github.com/UBC-Thunderbots/Software/blob/master/src/software/embedded/services/power.cpp) and [Motor](https://github.com/UBC-Thunderbots/Software/blob/master/src/software/embedded/services/motor.cpp) services. Thunderloop also receives `World` and `PrimitiveSet` protos from AI and sends back `Robot Status` protos.

Motor and Power service both interface with their respective electrical boards over different communication interfaces, namely SPI and UART respectively.

# Announcements

Broadcasts packets for what robot IDs are connected to wifi and what IPs they have. Combined with `robot_broadcast_receiver.py` allows us to see all robots on the network.

# Display

Displays information about the robot for us. Uses redis to receive info from other processes. Can also change values with physical buttons.
Motor and Power services both interface with their respective electrical boards over different communication interfaces, namely SPI and UART respectively.
Loading

0 comments on commit 99e7f6a

Please sign in to comment.