diff --git a/.github/workflows/docker-action.yml b/.github/workflows/docker-action.yml index 9941b7022..ee670a033 100644 --- a/.github/workflows/docker-action.yml +++ b/.github/workflows/docker-action.yml @@ -13,6 +13,8 @@ jobs: - name: Checkout uses: actions/checkout@v3 + with: + submodules: recursive - name: Set up QEMU uses: docker/setup-qemu-action@v2 @@ -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 \ No newline at end of file diff --git a/.gitignore b/.gitignore index 91934be2e..74ca9d675 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,9 @@ .idea/ cmake-build-debug/ cmake-build-release/ -build*/ +.cmake/ +**/build +.cache /.vscode .DS_Store diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 000000000..83a62b8fb --- /dev/null +++ b/.gitmodules @@ -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 diff --git a/README.md b/README.md index 8dfc9fd12..4a4af676b 100644 --- a/README.md +++ b/README.md @@ -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`*. @@ -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 @@ -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 @@ -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 - - diff --git a/build.sh b/build.sh new file mode 100755 index 000000000..3adca3ecf --- /dev/null +++ b/build.sh @@ -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 diff --git a/checkout_branch.py b/checkout_branch.py deleted file mode 100755 index 2bfa4cd23..000000000 --- a/checkout_branch.py +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/python3 - -import os -import argparse -from typing import List - -def checkout_repo_branch(repo: str, branch: str): - if not os.system(f"cd {repo} && git pull origin {branch} && cd .."): - return - - raise Exception(f"Failed to checkout repo {repo} to branch {branch}") - -def checkout_main_repos_branch(branch: str): - main_repos: List[str] = [ - "roboteam_ai", - "roboteam_proto", - "roboteam_robothub", - "roboteam_utils", - "roboteam_world", - "roboteam_central_server" - ] - for each in main_repos: - checkout_repo_branch(each, branch) - - -if __name__ == "__main__": - parser = argparse.ArgumentParser(description="Checkout the main roboteam branches") - parser.add_argument("branch_name", type=str, help='The branch to checkout the repos on') - - args = parser.parse_args() - checkout_main_repos_branch(args.branch_name) \ No newline at end of file diff --git a/docker/Dockerfile b/docker/Dockerfile index 498847840..17507aedb 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -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 /:/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 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/ \ No newline at end of file diff --git a/docker/README.md b/docker/README.md index afba1595c..0d785c34e 100644 --- a/docker/README.md +++ b/docker/README.md @@ -1,24 +1,109 @@ # Docker setup for RTT - ## Why docker? -Docker can create a virtual environment with pre installed depencendies. This makes sure everyone with this virtual environment can run our code. +Docker can create a virtual environment with pre installed depencendies. This makes sure everyone with this virtual environment can build or run our code. For a simulation tournament (2022/04), every team had to put their program in a docker image, so that their image could run on the server of the people that hosted the tournament (So less delay between our program and the simulator). -## How to make? -The `Dockerfile` file contains the steps to create the image. It contains all the commands that need to be run to install the required dependencies. It also copies the `clone.sh` script to the image so you dont have to type git clone for our repo. -- To create the image: (note the dot at the end) - - docker build -t roboteamtwente/practice_tournament . -- To run the image in a container: - docker run -e VNC_PW=12345 -p 5901:5901 -p 2222:2222 -it roboteamtwente/practice_tournament +## Structure +The description of the environment is located in the Dockerfile inside the `docker` folder. The file is divided in two targets: "development" and "release". + +Release target is only intended as a GitHub Action target, its purpose is to create the Docker image containing runnable binaries that can be pushed into a Registry. If you really want to build it locally you can do it by first building the development target, then compile sources with it and then build the release target. Note that release target contains only RoboTeamTwente binaries and not external ones like erforce simulator or erforce autoref. +Development target is instead intended as a normal usage target. -This image that will be created is also publicly available at [the docker hub](https://hub.docker.com/r/roboteamtwente/practice_tournament). This allows others to run our image. Be sure to update that docker once in a while. +Inside `docker` folder there are three subdirectories: `builder` `game` and `simulator`. +Every folder contains a convenient docker compose file: + - builder is used by lazy people like me to build sources without building and then directly executing command on a container + - simulator is used to start every service needed to start a simulation (apart from some external software, see [Normal Usage](#normal-usage) + - game is used to start roboteam software in real game mode +Docker composes use volumes because this way it's possible to compile sources and start up just built services without rebuilding any container. ## How to use? -On startup, the container will open a VNC session. With this you can remote desktop into the container, where you will be able to run our code. Download a VNC viewer for the remote desktopping(I suggest [this one](https://www.realvnc.com/en/connect/download/viewer/linux/), and log in with the VNC password you set in the `docker run` command (12345). +First things first: for convenience create an ENV VAR containing the path to this repo (change rc file accordingly to your shell). Make sure to be in the repo root folder (should be one level up from the folder in which this README is) and then: +``` +echo ROBOTEAM_REPO=$(pwd)/ >> ~/.bashrc +source ~/.bashrc +``` + +Init submodules: +``` +cd $ROBOTEAM_REPO +git submodule update --init --recursive +``` + +Then, install prerequisite: install Docker https://docs.docker.com/engine/install/, if you want you can add yourself to docker group in order to run Docker command without invoking root user https://docs.docker.com/engine/install/linux-postinstall/#manage-docker-as-a-non-root-user and finally install docker compose. + +Every subproject is meant to be executed as a service using its own container from a docker compose. +Every RTT subproject (service) runs in its own 'rtt-build-env' container, this way that all dependencies and requirements are satisfied. +Subproject containers start their own software from `build/release/bin` folder mounted as a volume. + +### Normal usage +1) Make your edits on RTT sources +2) Spin-up "builder" compose +3) Spin-up "simulator"/"game" compose +4) (Game-only) Download, install and run ssl-vision +5) You can now reach game controller UI on localhost:8081 and roboteam interface on localhost:8080, connect to primary_ai (port 12676) or secondary_ai (port 12677). + +As simple as that. + +1. Whenever you want to build all RTT services (normal operation) you simply need to run: +``` +cd $ROBOTEAM_REPO/docker/builder +docker compose up +``` +2. Start services: +``` +cd $ROBOTEAM_REPO/docker/ +docker compose up <-d> +``` +When you want to stop services: +``` +docker compose down +``` + +Note: you may want to use `docker logs -t ` to see command output of a specific container (service). +Example: `docker logs -t RTT_roboteam_primary_ai` + +#### TODO +https://lemariva.com/blog/2020/10/vscode-c-development-and-debugging-containers + +### Docker geeks +#### Build environment +You can manually build the 'build environment' container doing: +``` +docker build -t rtt-build-env . +``` + +Spin-up the just built container: +``` +docker run -itd --name rtt-build-env -h rtt-build-env -v $ROBOTEAM_REPO:/home/roboteamtwente/roboteam rtt-build-env +``` + +Then, you can compile sources using `build.sh` script located in the repo root folder from inside the container. +First, attach to a contanier shell: +``` +docker exec -it -u roboteamtwente -w /home/roboteamtwente/roboteam rtt-build-env /bin/bash +``` +then you can execute build script (or manually compiler whatever you want): +``` +./build.sh +``` + +Remember that you can stop/start 'rtt-build-env' container simply using: +``` +docker rtt-build-env +``` + +Note: avoid tagging the "run" stage container with the same name "rtt-build-env", otherwise when you will start the "build" compose you won't be able to compile sources (because the compose will be re-using the container with that name). +#### Manually starting a service +You can start a service by simply executing the binary from the rtt-build-env container. +Example: +Log into a container shell: +``` +docker exec -it -u roboteamtwente -w /home/roboteamtwente/ -v /:/home/roboteamtwente/ rtt-build-env /bin/bash +``` +execute roboteam_ai: +``` +./release/bin/roboteam_ai --primary_ai +``` -## Nice to know -- The image already has the text editor sublime text. To start it, open a terminal, and enter `subl ` to open that specific folder. -- Use the sript `clone.sh` to clone the roboteam repo located at `/`. \ No newline at end of file diff --git a/docker/builder/docker-compose.yml b/docker/builder/docker-compose.yml new file mode 100644 index 000000000..005f2ea12 --- /dev/null +++ b/docker/builder/docker-compose.yml @@ -0,0 +1,15 @@ +version: '3' + +services: + + roboteam_builder: + build: + context: ../ + target: development + image: rtt-build-env:latest + container_name: RTT_roboteam_builder + restart: "no" + working_dir: "/home/roboteamtwente/" + command: sh -c "./build.sh" + volumes: + - ../../:/home/roboteamtwente/ \ No newline at end of file diff --git a/docker/game/docker-compose.yml b/docker/game/docker-compose.yml new file mode 100644 index 000000000..7b1494950 --- /dev/null +++ b/docker/game/docker-compose.yml @@ -0,0 +1,122 @@ +version: '3' + +services: + + roboteam_primary_ai: + build: + context: ../ + target: development + image: rtt-build-env:latest + container_name: RTT_roboteam_primary_ai + restart: always + working_dir: "/home/roboteamtwente/" + command: sh -c "./bin/roboteam_ai --primary-ai --basestation" + network_mode: "host" # Workaround to connect from interface on host to AI websocket, please fix + expose: + - 1-65535:1-65535 # For zeromq ports + - 12676:12676 # Primary AI Port + ports: + - 12676:12676 # Primary AI Port + environment: + - LD_LIBRARY_PATH=/home/roboteamtwente/lib/ + volumes: + - ../../build/release/:/home/roboteamtwente/ + + roboteam_observer: + image: rtt-build-env:latest + container_name: RTT_roboteam_observer + restart: always + working_dir: "/home/roboteamtwente/" + command: sh -c "./bin/roboteam_observer --vision-ip 224.5.23.2 --referee-ip 224.5.23.1 --vision-port 10006 --referee-port 10003" + network_mode: "host" # Workaround to connect from interface on host to AI websocket, please fix + expose: + - 1-65535:1-65535 # For zeromq ports + - 10006:10006 # Vision port vision + - 10020:10020 # Vision port simulator + - 10003:10003 # Referee port + environment: + - LD_LIBRARY_PATH=/home/roboteamtwente/lib/ + volumes: + - ../../build/release/:/home/roboteamtwente/ + + roboteam_robothub: + image: rtt-build-env:latest + container_name: RTT_roboteam_robothub + restart: always + working_dir: "/home/roboteamtwente/" + command: sh -c "./bin/roboteam_robothub" + network_mode: "host" # Workaround to connect from interface on host to AI websocket, please fix + expose: + - 1-65535:1-65535 # For zeromq ports + - 10301:10301 #Blue Control Port + - 30011:30011 #Blue Feedback Port + - 10302:10302 #Yellow Control Port + - 30012:30012 #Yellow Feedback Port + - 10300:10300 #Simulation Control Port + - 30013:30013 #Simulation Feedback Port + environment: + - LD_LIBRARY_PATH=/home/roboteamtwente/lib/ + volumes: + - ../../build/release/:/home/roboteamtwente/ + + roboteam_interface: + image: rtt-build-env:latest + container_name: RTT_roboteam_interface + restart: always + working_dir: "/home/roboteamtwente/" + command: sh -c "yarn serve --host 0.0.0.0" + ports: + - 8080:8080 + volumes: + - ../../roboteam_interface/:/home/roboteamtwente/ + + roboteam_autoref: + image: gradle:8.4.0-jdk17 + container_name: RTT_roboteam_autoref + user: gradle # Do not build as root + restart: always + working_dir: "/home/roboteamtwente/" + command: sh -c "./gradlew run --args=\"-cli -active --world-ip=127.0.0.1 --world-port=5558 --gc-ip=127.0.0.1 --gc-port=10007\"" + network_mode: "host" # Workaround to connect from interface on host to AI websocket, please fix + expose: + - 10007:10007 # GC port + - 5558:5558 # World port + environment: + - GRADLE_USER_HOME=/home/roboteamtwente/.cache # Cache gradle dependencies + volumes: + - ../../roboteam_autoref/:/home/roboteamtwente/ + + erforce_autoref: + image: rtt-build-env:latest + container_name: RTT_erforce_autoref + restart: always + working_dir: "/home/roboteamtwente/external/autoref/build/bin/" + command: sh -c "./autoref-cli --vision-port 10006 --tracker-port 10010 --gc-port 10003" + network_mode: "host" # Workaround to connect from interface on host to AI websocket, please fix + expose: + - 10006:10006 #Vision port + - 10003:10003 #Ref port + - 10010:10010 #Tracker port + volumes: + - ../../:/home/roboteamtwente/ + + ssl-game-controller: + image: robocupssl/ssl-game-controller:latest + container_name: RTT_ssl-game-controller + restart: always + network_mode: "host" # Workaround to connect from interface on host to AI websocket, please fix + ports: + - "8081:8081/tcp" # UI port + +# ssl_vision: +# image: rtt-build-env:latest +# container_name: RTT_ssl_vision +# restart: always +# working_dir: "/home/roboteamtwente/" +# command: sh -c "./bin/vision" +# expose: +# - 10006:10006 # Vision port +# environment: +# - LC_NUMERIC=en_US.UTF-8 +# volumes: +# - ../../external/ssl-vision/:/home/roboteamtwente/ \ No newline at end of file diff --git a/docker/simulator/docker-compose.yml b/docker/simulator/docker-compose.yml new file mode 100644 index 000000000..88297671b --- /dev/null +++ b/docker/simulator/docker-compose.yml @@ -0,0 +1,143 @@ +version: '3' + +services: + + roboteam_primary_ai: + build: + context: ../ + target: run + image: rtt-build-env:latest + container_name: RTT_roboteam_primary_ai + restart: always + working_dir: "/home/roboteamtwente/" + command: sh -c "./bin/roboteam_ai --primary-ai" + network_mode: "host" # Workaround to connect from interface on host to AI websocket, please fix + expose: + - 1-65535:1-65535 # For zeromq ports + - 12676:12676 # Primary AI Port + ports: + - 12676:12676 # Primary AI Port + environment: + - LD_LIBRARY_PATH=/home/roboteamtwente/lib/ + volumes: + - ../../build/release/:/home/roboteamtwente/ + + roboteam_secondary_ai: + image: rtt-build-env:latest + container_name: RTT_roboteam_secondary_ai + restart: always + working_dir: "/home/roboteamtwente/" + command: sh -c "./bin/roboteam_ai --secondary-ai" + network_mode: "host" # Workaround to connect from interface on host to AI websocket, please fix + expose: + - 1-65535:1-65535 # For zeromq ports + - 12677:12677 # Secondary AI Port + ports: + - 12677:12677 # Secondary AI Port + environment: + - LD_LIBRARY_PATH=/home/roboteamtwente/lib/ + volumes: + - ../../build/release/:/home/roboteamtwente/ + + roboteam_observer: + image: rtt-build-env:latest + container_name: RTT_roboteam_observer + restart: always + working_dir: "/home/roboteamtwente/" + command: sh -c "./bin/roboteam_observer --vision-ip 224.5.23.2 --referee-ip 224.5.23.1 --vision-port 10020 --referee-port 10003" + network_mode: "host" # Workaround to connect from interface on host to AI websocket, please fix + expose: + - 1-65535:1-65535 # For zeromq ports + - 10006:10006 # Vision port vision + - 10020:10020 # Vision port simulator + - 10003:10003 # Referee port + environment: + - LD_LIBRARY_PATH=/home/roboteamtwente/lib/ + volumes: + - ../../build/release/:/home/roboteamtwente/ + + roboteam_robothub: + image: rtt-build-env:latest + container_name: RTT_roboteam_robothub + restart: always + working_dir: "/home/roboteamtwente/" + command: sh -c "./bin/roboteam_robothub" + network_mode: "host" # Workaround to connect from interface on host to AI websocket, please fix + expose: + - 1-65535:1-65535 # For zeromq ports + - 10301:10301 #Blue Control Port + - 30011:30011 #Blue Feedback Port + - 10302:10302 #Yellow Control Port + - 30012:30012 #Yellow Feedback Port + - 10300:10300 #Simulation Control Port + - 30013:30013 #Simulation Feedback Port + environment: + - LD_LIBRARY_PATH=/home/roboteamtwente/lib/ + volumes: + - ../../build/release/:/home/roboteamtwente/ + + roboteam_interface: + image: rtt-build-env:latest + container_name: RTT_roboteam_interface + restart: always + working_dir: "/home/roboteamtwente/" + command: sh -c "yarn serve --host 0.0.0.0" + ports: + - 8080:8080 + volumes: + - ../../roboteam_interface/:/home/roboteamtwente/ + + roboteam_autoref: + image: gradle:8.4.0-jdk17 + container_name: RTT_roboteam_autoref + user: gradle # Do not build as root + restart: always + working_dir: "/home/roboteamtwente/" + command: sh -c "./gradlew run --args=\"-cli -active --world-ip=127.0.0.1 --world-port=5558 --gc-ip=127.0.0.1 --gc-port=10007\"" + network_mode: "host" # Workaround to connect from interface on host to AI websocket, please fix + expose: + - 10007:10007 # GC port + - 5558:5558 # World port + environment: + - GRADLE_USER_HOME=/home/roboteamtwente/.cache # Cache gradle dependencies + volumes: + - ../../roboteam_autoref/:/home/roboteamtwente/ + + erforce_autoref: + image: rtt-build-env:latest + container_name: RTT_erforce_autoref + restart: always + working_dir: "/home/roboteamtwente/external/autoref/build/bin/" + command: sh -c "./autoref-cli --vision-port 10020 --tracker-port 10010 --gc-port 10003" + network_mode: "host" # Workaround to connect from interface on host to AI websocket, please fix + expose: + - 10020:10020 # Vision port simulator + - 10003:10003 # GC port + - 10010:10010 # Tracker port + volumes: + - ../../:/home/roboteamtwente/ + + erforce_simulator: + image: rtt-build-env:latest + container_name: RTT_erforce_simulator + restart: always + working_dir: "/home/roboteamtwente/external/framework/build/bin/" + command: sh -c "./simulator-cli" + network_mode: "host" # Workaround to connect from interface on host to AI websocket, please fix + expose: + - 10301:10301 #Blue Control Port + - 30011:30011 #Blue Feedback Port + - 10302:10302 #Yellow Control Port + - 30012:30012 #Yellow Feedback Port + - 10300:10300 #Simulation Control Port + - 30013:30013 #Simulation Feedback Port + volumes: + - ../../:/home/roboteamtwente/ + + ssl-game-controller: + image: robocupssl/ssl-game-controller:latest + container_name: RTT_ssl-game-controller + restart: always + network_mode: "host" # Workaround to connect from interface on host to AI websocket, please fix + ports: + - "8081:8081/tcp" # UI port \ No newline at end of file diff --git a/external/autoref b/external/autoref new file mode 160000 index 000000000..6f15f574e --- /dev/null +++ b/external/autoref @@ -0,0 +1 @@ +Subproject commit 6f15f574ea803984ba7169a40c618fad43143596 diff --git a/external/framework b/external/framework new file mode 160000 index 000000000..0f5ffffa4 --- /dev/null +++ b/external/framework @@ -0,0 +1 @@ +Subproject commit 0f5ffffa4417be583357c923ee4217183ed5c260 diff --git a/install_UBUNTU_22_04.sh b/install_UBUNTU_22_04.sh deleted file mode 100755 index 59c814dd8..000000000 --- a/install_UBUNTU_22_04.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/bash - -echo Updating repositories -apt-get -y update -apt-get -y upgrade - -echo Installing required packaged dependencies -apt-get install -y cmake -apt-get install -y g++ -apt-get install -y qt5-default -apt-get install -y libqt5charts5-dev -apt-get install -y libzmq3-dev -apt-get install -y libeigen3-dev -apt-get install -y libgtest-dev -apt-get install -y libudev-dev - -echo Installing other useful packages -apt-get install -y clang -apt-get install -y clang-format -apt-get install -y ninja-build -apt-get install -y autoconf -apt-get install -y automake -apt-get install -y libtool -apt-get install -y libtbb-dev -apt-get install -y apt-utils -apt-get install -y libboost-all-dev -apt-get install -y curl -apt-get install -y make -apt-get install -y unzip -apt-get install -y qtdeclarative5-dev - -# The default protobuf package is too low of a version for us -echo Installing protobuf -git clone https://github.com/protocolbuffers/protobuf.git /opt/protobuf -cd /opt/protobuf -git checkout 3.19.x -git submodule update --init --recursive -./autogen.sh -./configure -make -j $(nproc) -make install -ldconfig diff --git a/roboteam_ai/src/utilities/IOManager.cpp b/roboteam_ai/src/utilities/IOManager.cpp index 451fd04d4..4e384cbf1 100644 --- a/roboteam_ai/src/utilities/IOManager.cpp +++ b/roboteam_ai/src/utilities/IOManager.cpp @@ -64,7 +64,9 @@ void IOManager::handleState(const proto::State& stateMsg) { } else if (state.referee().blue().name() == ROBOTEAM_TWENTE) { GameSettings::setYellow(false); } - GameSettings::setLeft(!(state.referee().blue_team_on_positive_half() ^ GameSettings::isYellow())); + if (GameSettings::isPrimaryAI()) { + GameSettings::setLeft(!(state.referee().blue_team_on_positive_half() ^ GameSettings::isYellow())); + } if (!GameSettings::isLeft()) roboteam_utils::rotate(state.mutable_referee()); auto const& [_, data] = World::instance(); diff --git a/roboteam_autoref b/roboteam_autoref new file mode 160000 index 000000000..3b336322e --- /dev/null +++ b/roboteam_autoref @@ -0,0 +1 @@ +Subproject commit 3b336322e42dd3087835bccea04a7f16fdf4c522 diff --git a/roboteam_robothub/src/RobotHubStatistics.cpp b/roboteam_robothub/src/RobotHubStatistics.cpp index 340f41763..252c86ffb 100644 --- a/roboteam_robothub/src/RobotHubStatistics.cpp +++ b/roboteam_robothub/src/RobotHubStatistics.cpp @@ -49,6 +49,9 @@ void RobotHubStatistics::print() const { std::stringstream ss; + // Clear and flush + ss << "\x1B[2J\x1B[H" << std::flush; + ss << " ┏━━━━━━━━━━━━━━━━━━━┓ " << std::endl << "┏━━━━━━━━━━━━━━━━━━━━━━━━━┫ Roboteam RobotHub ┣━━━┳━━━━━━━━━━━━━━━━━━━━━━┓" << std::endl << "┃ ┗━━━━━━━━━━━━━━━━━━━┛ ┃ ┃" << std::endl diff --git a/roboteam_world/src/main.cpp b/roboteam_world/src/main.cpp index c9822e61a..df59e2af6 100644 --- a/roboteam_world/src/main.cpp +++ b/roboteam_world/src/main.cpp @@ -2,27 +2,30 @@ #include "roboteam_utils/ArgParser.h" int main(int argc, char** argv) { - std::cout << "Usage: ./roboteam_observer --log --vision-ip --referee-ip --vision-port --referee-port " << std::endl; - std::cout << " log: log data to file" << std::endl; - std::cout << " vision-ip : ip to listen for vision. Defaults to 224.5.23.2" << std::endl; - std::cout << " referee-ip : ip to listen for referee. Defaults to 224.5.23.1" << std::endl; - std::cout << " vision-port : port to listen for vision. Defaults to 10006 (use 10020 for ER-Force simulator)" << std::endl; - std::cout << " referee-port : port to listen for referee. Defaults to 10003" << std::endl; + const std::vector args(argv, argv + argc); - std::cout << std::endl; + // Search for log flag --log + auto itLog = std::find(args.begin(), args.end(), std::string("--log")); + bool shouldLog = itLog != args.end(); + + std::optional val; std::string visionip = "224.5.23.2"; std::string refereeip = "224.5.23.1"; std::string visionport_str = "10006"; std::string refereeport_str = "10003"; - const std::vector args(argv, argv + argc); + if (rtt::findFlagValue(args, "--help", true) || rtt::findFlagValue(args, "-h", true)) { + std::cout << "Usage: ./roboteam_observer --log --vision-ip --referee-ip --vision-port --referee-port " << std::endl; + std::cout << " log: log data to file" << std::endl; + std::cout << " vision-ip : ip to listen for vision. Defaults to 224.5.23.2" << std::endl; + std::cout << " referee-ip : ip to listen for referee. Defaults to 224.5.23.1" << std::endl; + std::cout << " vision-port : port to listen for vision. Defaults to 10006 (use 10020 for ER-Force simulator)" << std::endl; + std::cout << " referee-port : port to listen for referee. Defaults to 10003" << std::endl; + std::cout << "Use -h or --help to print this help message" << std::endl; - // Search for log flag --log - auto itLog = std::find(args.begin(), args.end(), std::string("--log")); - bool shouldLog = itLog != args.end(); - - std::optional val; + std::cout << std::endl; + } val = rtt::findFlagValue(args, "--vision-ip"); if (val) {