Skip to content

Commit

Permalink
Merge branch 'main' into update/pass-defender
Browse files Browse the repository at this point in the history
  • Loading branch information
JornJorn committed Nov 21, 2023
2 parents 0263b74 + c99728f commit 62fcaea
Show file tree
Hide file tree
Showing 18 changed files with 570 additions and 186 deletions.
13 changes: 12 additions & 1 deletion .github/workflows/docker-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ jobs:
-
name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
-
name: Set up QEMU
uses: docker/setup-qemu-action@v2
Expand All @@ -33,11 +35,20 @@ jobs:
push: true
target: development
tags: roboteamtwente/roboteam:development
-
name: Build sources
uses: addnab/docker-run-action@v3
with:
image: roboteamtwente/roboteam:development
options: -v ${{ github.workspace }}:/home/roboteamtwente/
run: |
sudo ./build.sh
-
name: Build and push release
uses: docker/build-push-action@v4
with:
context: ./docker
context: .
file: ./docker/Dockerfile
push: true
target: release
tags: roboteamtwente/roboteam:latest
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
.idea/
cmake-build-debug/
cmake-build-release/
build*/
.cmake/
**/build
.cache
/.vscode
.DS_Store

Expand Down
10 changes: 10 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[submodule "external/framework"]
path = external/framework
url = https://github.com/robotics-erlangen/framework.git
[submodule "external/autoref"]
path = external/autoref
url = https://github.com/robotics-erlangen/autoref.git
[submodule "roboteam_autoref"]
path = roboteam_autoref
url = https://github.com/RoboTeamTwente/roboteam_autoref.git
branch = main
33 changes: 2 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# RoboTeam

## Overview
This software is tested on Ubuntu 22.04 LTS, and the installation instructions are written with that distro/OS in mind. However, other distro's of Linux are also likely to be able to run this software, albeit with some modifications.

This repository contains the following projects:

- `RoboTeam World`. It is responsible from receiving and combining all sources of information into one coherent world state, which can be used by `RoboTeam AI`. These sources include data from either a simulator or SSL-Vision, and feedback from our robots (WIP). Note: The executable is called `roboteam_observer`*.
Expand All @@ -13,10 +11,8 @@ This repository contains the following projects:

\* `RoboTeam World` its executable is named `roboteam_observer`, since `RoboTeam AI` also contains a class named `World`, which caused confusion.



## Dependencies
All dependencies are listed in `install_dependencies_ubuntu22-04.sh`. Simply run this file to install all of them. Additionally, it installs other useful packages.
## How to
Refer to `docker/README.md` for usage of our software.

## IDEs
### VSCode
Expand All @@ -27,29 +23,6 @@ To install [CLion](https://www.jetbrains.com/clion/), you need a [student licens

Make sure you have the dependencies installed. Within CLion, go to the CMakeLists.txt and click on it. CLion will generate a pop-up saying "project files not loaded" in blue in the top right corner. Clicking it will have CMake load the project. This means it generates instructions on how the files should be compiled in order to produce the executables specified in the CMakeLists.txt file. You can now compile the targets!

## Running a game
![alt text](readme_images/rtt_software_stack.png)

To run a game, you will need to boot up `RoboTeam AI`, `RoboTeam World`, and `RoboTeam Robothub`. The executables are named `roboteam_ai`, `roboteam_observer`, and `roboteam_robothub` respectively. Next to that, either boot up a simulator or SSL-Vision. Want to run an entire match with autorefs and everything? Please have a look at this official (docker-compose)[https://github.com/RoboCup-SSL/ssl-game-controller/blob/master/docker-compose.yaml] file. It contains everything you need outside of our own software.

## SSL Software / Simulators
* [`SSL Vision`](https://github.com/RoboCup-SSL/ssl-vision)
* [`SSL Game Controller`](https://github.com/RoboCup-SSL/ssl-game-controller)
* [`GrSim simulator`](https://github.com/RoboCup-SSL/grSim)
* [`ER-Force simulator`](https://github.com/robotics-erlangen/framework#simulator-cli)
* [`Other SSL software`](https://github.com/RoboCup-SSL)

It is recommended to use the game controller to control the gamestates. You can do so by downloading the latest binary release of the [SSL-Game-Controller](https://github.com/RoboCup-SSL/ssl-game-controller) repo, and executing it. For example, when downloaded to the Downloads folder:

```bash
~/Downloads/ssl-game-controller_v1.2.0_linux_amd64
```

You might need to [chmod](https://www.howtoforge.com/tutorial/linux-chmod-command/) the file to make it executable. The AI client should now listen to the commands sent by the GameController.

## Installation Ubuntu
All dependencies are listed in `install_dependencies_ubuntu22-04.sh`. Simply run the script to install all of these, and some useful other packages.

### Code Style Formatting
To be consistent in the code style, we use clang-format. You can use clang-format to automatically format your code during every commit and you can use clang-format in CLion to format all code files in a given folder. Format the code by running `format.sh`
## See also
Expand All @@ -63,5 +36,3 @@ To enable Tracy
- Compile Tracy Server and run
- Information is in the tracy [docs](https://github.com/wolfpld/tracy)
- Run AI


70 changes: 70 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#! /bin/bash

# Exit on errors
# Note: do not concat commands with && otheriwise won't be catched
set -eo pipefail

GREEN='\033[0;32m'
RED='\033[0;31m'
ORANGE='\033[0;33m'
RESET='\033[0m'

error() {
echo -e "${RED}Fatal error on line $1${RESET}" >&2
}

trap 'error $LINENO' ERR

if [ "$1" == "-y" ];
then
OK=1
fi

# Check if the script is being executed from inside container or explicitly
# asked to run it on host environment
if [ -f /.dockerenv ] || [ "$OK" = "1" ];
then
if [ "$0" == "./build.sh" ];
then
echo -e "${GREEN}Checking submodules${RESET}"
git submodule update --init --recursive
echo "Done"
#rm -rf build
mkdir -p build
pushd build
echo -e "${GREEN}Building RoboTeamTwente software${RESET}"
cmake .. -DCMAKE_BUILD_TYPE=Release
make -j$(nproc) roboteam_observer roboteam_ai roboteam_robothub
popd
echo -e "${GREEN}Installing interface${RESET}"
pushd roboteam_interface
yarn install
popd
pushd external
echo -e "${GREEN}Building external${RESET}"
pushd framework
echo -e "${GREEN}Building external/framework${RESET}"
mkdir -p build
pushd build
cmake ..
make simulator-cli -j$(nproc)
popd
popd
pushd autoref
echo -e "${GREEN}Building external/autoref${RESET}"
mkdir -p build
pushd build
cmake ..
make autoref-cli -j$(nproc)
popd
popd
popd
echo -e "${GREEN}Done, exiting builder..${RESET}"
else
echo -e "${RED}E: The script must be called from the root folder${RESET}"
exit 1
fi
else
echo -e "${ORANGE}W: If you really want to build outside the container call the script with -y argument.${RESET}"
exit 1
fi
31 changes: 0 additions & 31 deletions checkout_branch.py

This file was deleted.

121 changes: 69 additions & 52 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,68 +1,85 @@
# ========================== #
# INSTRUCTIONS #
# ========================== #
# RTT Build Environment
# The purpose of this container is to have a stable, quick and reliable environment
# to build RTT software.
#
# ==== QUICKLY BOOT
# $ docker run --init --rm --net=host roboteamtwente/roboteam:latest ./roboteam_robothub
# $ docker run --init --rm --net=host roboteamtwente/roboteam:latest ./roboteam_observer
# $ xhost local:
# $ docker run --init --rm --net=host -v /tmp/.X11-unix/ -e DISPLAY=$DISPLAY rtt-release /roboteam_ai
# =========================================================================== #
#
# Manually build the container:
# docker build -t rtt-build-env .
#
# Spin-up the container:
# docker run -itd --name rtt-build-env -h rtt-build-env -v <abs_path_to_the_repo_root>/:/home/roboteamtwente/roboteam rtt-build-env
#
# ==== DO IT YOURSELF
# Step 1.1: Build
# $ docker build . --target development -t rtt-development
# $ docker build . --target release -t rtt-release
# Start/Stop container:
# docker <start/stop> rtt-build-env
#
# Step 2: Allow X11 access
# $ xhost local:
# This will give local VMs acces to the X11-server, which is needed to do GUI stuff
# https://stackoverflow.com/questions/25281992/alternatives-to-ssh-x11-forwarding-for-docker-containers
# Attach to the container:
# docker exec -it -w /home/roboteamtwente rtt-build-env /bin/bash
#
# Step 3.1: Create a development container, to which you can e.g. hook into with VSCode
# $ docker run -it -v /tmp/.X11-unix/ -e DISPLAY=$DISPLAY --net=host --name rtt rtt-development
# OR
# Step 3.2: Start any executable
# $ docker run --init --rm --net=host rtt-release /roboteam_observer
# $ docker run --init --rm --net=host -v /tmp/.X11-unix/ -e DISPLAY=$DISPLAY rtt-release /roboteam_ai
# $ docker run --init --rm --net=host rtt-release /roboteam_robothub
# =========================================================================== #
#
# ========================== #

# Development target
FROM alpine:3.18 AS development

ENV TZ="Europe/Rome"
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

# ========================== #
# DEVELOPMENT CONTAINER #
# ========================== #
FROM ubuntu:22.04 AS development
RUN apt-get update -y && apt-get upgrade -y
RUN apt-get install -y vim git cmake pkg-config python3 python3-pip ccache
ARG USERNAME=roboteamtwente

RUN git clone https://github.com/RoboTeamTwente/roboteam.git --recursive
WORKDIR /roboteam
RUN ./install_UBUNTU_22_04.sh
RUN mkdir build
WORKDIR /roboteam/build
RUN cmake .. -DCMAKE_BUILD_TYPE=Release && make -j$(nproc) roboteam_observer roboteam_ai roboteam_robothub
WORKDIR /roboteam
RUN apk add --no-cache bash build-base cmake make musl-dev libtool \
clang ninja-build autoconf automake pkgconfig \
python3 py3-pip git ccache sudo \
libzmq zeromq-dev libzmq-static eigen-dev gtest-dev \
libtbb-dev boost-dev curl unzip wget zlib-dev zip nodejs npm \
openssl-dev sdl2-dev libudev-zero libudev-zero-dev libusb libusb-dev \
qt5-qtbase-dev qt5-qtcharts-dev qt5-qtdeclarative-dev qt5-qtsvg-dev
RUN npm install -g yarn

WORKDIR /root/protobuf
RUN wget https://github.com/protocolbuffers/protobuf/releases/download/v3.20.3/protobuf-cpp-3.20.3.zip -O protobuf.zip && unzip protobuf.zip && rm protobuf.zip
WORKDIR /root/protobuf/protobuf-3.20.3
RUN ./configure && make -j$(nproc) && make check -j$(nproc) && make install && ldconfig . && cd .. && rm -rf /root/protobuf/protobuf-3.20.3

ENV HOME=/home/$USERNAME
ENV USER=$USERNAME

# ========================== #
# RELEASE CONTAINER #
# ========================== #
FROM ubuntu:22.04 AS release
COPY --from=development /roboteam/build/release/bin/roboteam_observer /roboteam_observer
COPY --from=development /roboteam/build/release/bin/roboteam_ai /roboteam_ai
COPY --from=development /roboteam/build/release/bin/roboteam_robothub /roboteam_robothub
RUN adduser -D $USER && \
echo "$USER ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/$USER && \
chmod 0440 /etc/sudoers.d/$USER

COPY --from=development /usr/lib/x86_64-linux-gnu /usr/lib/x86_64-linux-gnu
COPY --from=development /usr/share/fonts /usr/share/fonts
COPY --from=development /roboteam/build/release/lib/libzmqpp.so /usr/lib/libzmqpp.so
COPY --from=development /roboteam/build/release/lib/libNFParam.so /usr/lib/libNFParam.so
COPY --from=development /usr/local/lib/libprotobuf.so.30.0.6 /usr/lib/libprotobuf.so.30
USER $USER
WORKDIR $HOME

# The entire /usr/lib/x86_64-linux-gnu folder is cloned since it's too much of a hassle to figure out what is and isn't needed
# TODO figure out how to exlude large files such as /usr/lib/x86_64-linux-gnu/libLLVM* (200+MB)
# Can't use .dockerignore for this https://github.com/moby/moby/issues/33923
# Release target
FROM alpine:3.18 AS release

ENV TZ="Europe/Rome"
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

ARG USERNAME=roboteamtwente
ENV HOME=/home/$USERNAME
ENV USER=$USERNAME

RUN apk add --no-cache \
libtool libzmq libzmq-static libudev-zero libusb \
zeromq-dev eigen-dev gtest-dev \
libtbb-dev boost-dev zlib-dev \
openssl-dev sdl2-dev \
qt5-qtbase-dev qt5-qtcharts-dev qt5-qtdeclarative-dev qt5-qtsvg-dev \
sudo nodejs npm
RUN npm install -g yarn

COPY --from=development --chown=root:root /usr/local/lib/libprotobuf.so.31 /usr/local/lib/libprotobuf.so.31
COPY --from=development --chown=root:root /usr/local/bin/protoc /usr/local/bin/protoc

RUN adduser -D $USER && \
echo "$USER ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/$USER && \
chmod 0440 /etc/sudoers.d/$USER

USER $USER
WORKDIR $HOME

ENV LD_LIBRARY_PATH=$HOME/lib/
# Note: cannot COPY from outside context, build from parent folder
COPY --chown=$USER:$USER ../build/release/ $HOME/
Loading

0 comments on commit 62fcaea

Please sign in to comment.