Skip to content

Commit

Permalink
Merge pull request #139 from RoboTeamTwente/nova_2
Browse files Browse the repository at this point in the history
Nova 2
  • Loading branch information
flimdejong authored Jan 29, 2025
2 parents d56259f + c40c92a commit 4e82dfb
Show file tree
Hide file tree
Showing 113 changed files with 6,982 additions and 105 deletions.
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,14 @@ ENV/
env.bak/
venv.bak/
__pycache__/

# Docker
docker/runner/ssl-game-controller-config/20*
docker/runner/ssl-game-controller-config/state-store.json.stream

# RL
roboteam_ai/src/RL/src/tmp/eval_monitor.monitor.csv
roboteam_ai/src/RL/src/tmp/monitor.monitor.csv
roboteam_ai/src/RL/src/ppo_tensorboard_main
roboteam_ai/src/RL/src/best_model_PPO.zip
docker/runner/ssl-game-controller-config/state-store.json.stream
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@
[submodule "roboteam_robothub/roboteam_embedded_messages"]
path = roboteam_robothub/roboteam_embedded_messages
url = https://github.com/RoboTeamTwente/roboteam_embedded_messages.git
[submodule "tigers_sumatra"]
path = tigers_sumatra
url = https://github.com/RoboTeamTwente/tigers_sumatra.git
31 changes: 31 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
FROM roboteamtwente/roboteam:development

# Create symbolic link from /home/roboteam to /home/roboteamtwente
USER root
RUN ln -s /home/roboteamtwente /home/roboteam

# Install Java
RUN apk add --no-cache openjdk11

# Install Java 21
RUN wget https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.1%2B12/OpenJDK21U-jdk_x64_alpine-linux_hotspot_21.0.1_12.tar.gz \
&& tar -xzf OpenJDK21U-jdk_x64_alpine-linux_hotspot_21.0.1_12.tar.gz \
&& mv jdk-21* /usr/lib/jvm/java-21-openjdk

# Set up Java environment variables to point to Java 21
ENV JAVA_HOME=/usr/lib/jvm/java-21-openjdk
ENV PATH="${JAVA_HOME}/bin:${PATH}"

WORKDIR /home/roboteam

# Copy the entire current directory into the container
COPY --chown=roboteamtwente:roboteamtwente . /home/roboteam/

# Make sure build.sh is executable
RUN chmod +x build.sh

# Add the lib directory to LD_LIBRARY_PATH
ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/roboteam/build/release/lib

# Switch back to the roboteamtwente user
USER roboteamtwente
16 changes: 16 additions & 0 deletions Dockerfile.ray
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# This dockerfile uses the ray project's official ray image as a base.
# It also adds the torch and gymnasium libraries to the image.
# It also adds the roboteam RL code to the image.

FROM rayproject/ray:latest-py310

# Install dependencies in a single layer to keep it cached
RUN pip install torch==2.5.1 gymnasium numpy==1.24.3 ray[rllib]==2.38.0 pyzmq protobuf websockets

# Copy the entire roboteam root folder (including the roboteam_ai and roboteam_networking folders)
COPY roboteam_ai /roboteam/roboteam_ai
COPY roboteam_networking /roboteam/roboteam_networking

# Set working directory and Python path
WORKDIR /roboteam
ENV PYTHONPATH="/roboteam:${PYTHONPATH}"
20 changes: 20 additions & 0 deletions Dockerfile.zmq_server
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM python:3.9-slim

# Install system dependencies
RUN apt-get update && \
apt-get install -y libzmq3-dev build-essential && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

# Install Python dependencies
RUN pip install pyzmq protobuf

# Create working directory
WORKDIR /app

# Copy the Python script and proto files
COPY roboteam_ai/src/rl/src/zmq_server.py /app/
COPY /roboteam_networking/ /app/roboteam_networking/

# Run the script
CMD ["python", "zmq_server.py"]
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,15 @@ To enable Tracy
- Compile Tracy Server and run
- Information is in the tracy [docs](https://github.com/wolfpld/tracy)
- Run AI

### Use of Ray

The dockerimage Dockerfile.ray is used to build a docker image with the ray project's official ray image as a base. It also adds the necessary libraries to the image and the roboteam RL code to the image. Only build it if you want to deploy it to a cluster.

Build the docker image using the following command from the root folder:

- docker build -t roboteamtwente/ray:development -f Dockerfile.ray .

Push it using the following command:

- docker push roboteamtwente/ray:development
4 changes: 4 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ docker run -itd --name rtt-release-env -h rtt-release-env roboteamtwente/robotea
#### TODO
https://lemariva.com/blog/2020/10/vscode-c-development-and-debugging-containers


### Profile explanation
If you want to run certain docker containers with a single command, you create a profile. This will run every docker container that has this command.

### Docker geeks
We highly discourage executing command under this section unless you know what you are doing and for some reason you need to edit dockerfiles or composes structure.

Expand Down
39 changes: 39 additions & 0 deletions docker/runner/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@

In a ray or distributed computing cluster, the terms "head node" and "worker nodes" refer to different roles that containers play in the cluster. The head node is the master node in a Ray cluster. You typically have one head node. Worker nodes are the containers that execute the jobs, in parallel. You can have as many worker nodes as you want.

-----------------------------------------------------------

## Installing Kuberay

curl <https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3> | bash
helm repo add kuberay <https://ray-project.github.io/kuberay-helm/>
helm repo update
helm install kuberay-operator kuberay/kuberay-operator --namespace ray-system --create-namespace

<https://docs.ray.io/en/latest/cluster/kubernetes/user-guides/config.html>
The above source was used for creating the ray-cluster.yaml

Installing kubernetes and minikubernetes, you can follow this guide to check out how to install and run them: <https://medium.com/@areesmoon/installing-minikube-on-ubuntu-20-04-lts-focal-fossa-b10fad9d0511>

Use 'pip install ray' and then 'pip show ray' to get your version of ray.

-----------------------------------------------------------

After you have both kubernetes and ray, use the following command to create a cluster: kubectl apply -f ray-cluster.yaml
This cluster launches a ray head node and one worker node. Launch the external simulator using kubectl apply -f simulator.yaml

'kubectl get pods'-> this is will give you the cluster name

Use to forward the needed port to the ray service: kubectl port-forward svc/<cluster name> 8265:8265
This is the port that will be used inside ray_jobs.py, where we submit the jobs to ray.

-----------------------------------------------------------

## Useful commands

kubectl apply -f ray-cluster.yaml
kubectl delete -f ray-cluster.yaml
helm install kuberay-operator ray/kuberay-operator
helm uninstall kuberay-operator
kubectl port-forward svc/roboteam-ray-cluster-head-nodeport 8265:8265 6379:6379 10001:10001 8000:8000 &
minikube start -p ray --nodes 2 --memory 4000 --cpus 3
28 changes: 15 additions & 13 deletions docker/runner/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: '3'

services:

roboteam_primary_ai:
Expand All @@ -18,7 +16,7 @@ services:
- LD_LIBRARY_PATH=/home/roboteamtwente/lib/
volumes:
- ../../build/release/:/home/roboteamtwente/
profiles: ["simulator","diff","game", "robocup"]
profiles: ["simulator","diff","game", "robocup", "RL"]

roboteam_secondary_ai:
image: roboteamtwente/roboteam:development
Expand Down Expand Up @@ -61,7 +59,7 @@ services:
container_name: RTT_roboteam_observer_sim
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 --log"
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
Expand All @@ -72,7 +70,7 @@ services:
- LD_LIBRARY_PATH=/home/roboteamtwente/lib/
volumes:
- ../../build/release/:/home/roboteamtwente/
profiles: ["simulator","diff"]
profiles: ["simulator","diff", "RL"]

roboteam_observer_game:
image: roboteamtwente/roboteam:development
Expand Down Expand Up @@ -111,7 +109,7 @@ services:
- LD_LIBRARY_PATH=/home/roboteamtwente/lib/
volumes:
- ../../build/release/:/home/roboteamtwente/
profiles: ["simulator","diff"]
profiles: ["simulator","diff", "RL"]

roboteam_robothub_game:
image: roboteamtwente/roboteam:development
Expand Down Expand Up @@ -147,7 +145,7 @@ services:
- 8080:8080
volumes:
- ../../roboteam_interface/:/home/roboteamtwente/
profiles: ["simulator","diff","game", "robocup"]
profiles: ["simulator","diff","game", "robocup", "RL"]

roboteam_autoref:
image: gradle:8.4.0-jdk17
Expand All @@ -164,7 +162,7 @@ services:
- GRADLE_USER_HOME=/home/roboteamtwente/.cache # Cache gradle dependencies
volumes:
- ../../roboteam_autoref/:/home/roboteamtwente/
profiles: ["simulator","diff","game","autoref"]
profiles: ["simulator","diff","game","autoref", "RL"]

erforce_autoref_sim:
image: roboteamtwente/roboteam:development
Expand All @@ -179,7 +177,7 @@ services:
- 10010:10010 # Tracker port
volumes:
- ../../:/home/roboteamtwente/
profiles: ["simulator","diff"]
profiles: ["simulator","diff", "RL"]

erforce_autoref_game:
image: roboteamtwente/roboteam:development
Expand Down Expand Up @@ -212,13 +210,17 @@ services:
- 30013:30013 #Simulation Feedback Port
volumes:
- ../../:/home/roboteamtwente/
profiles: ["simulator","diff"]
profiles: ["simulator","diff", "RL"]

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
network_mode: "host"
ports:
- "8081:8081/tcp" # UI port
profiles: ["simulator","diff","game"]
- "8081:8081/tcp"
volumes:
- ./ssl-game-controller-config:/config
- ./ssl-game-controller-data:/data
command: -address :8081
profiles: ["simulator","diff","game", "RL"]
Loading

0 comments on commit 4e82dfb

Please sign in to comment.