Skip to content

Commit

Permalink
Merge branch 'main' into goalie_behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
JanNiklasFeld committed Mar 17, 2024
2 parents f5b0d86 + dd081db commit 5e13cfa
Show file tree
Hide file tree
Showing 189 changed files with 1,126 additions and 741 deletions.
97 changes: 97 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
FROM ros:iron

# Basic Utilities
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update -y \
&& apt-get install -y apt-utils auto-apt-proxy \
&& apt-get install -y \
build-essential \
curl \
ffmpeg \
gdb \
gnupg2 \
htop \
iproute2 \
iputils-ping \
ipython3 \
jq \
less \
libncurses5-dev \
locales \
python3-pip \
radeontop \
ranger \
rsync \
screen \
ssh \
sudo \
synaptic \
tig \
tmux \
tree \
uvcdynctrl \
vim \
vlc \
wget \
x11-apps \
zsh

# Setup locale
RUN echo 'en_US.UTF-8 UTF-8' > /etc/locale.gen \
&& locale-gen \
&& update-locale LANG=en_US.UTF-8 \
&& ln -s /usr/bin/python3 /usr/bin/python

ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8

# Setup and prioritize packages.bit-bots.de repository
RUN apt update -y \
&& apt upgrade -y --allow-downgrades

# Additional robotics related packages
RUN apt-get install -y \
python3-rosdep \
python3-vcstool \
ros-iron-camera-calibration \
ros-iron-desktop \
ros-iron-joint-state-publisher-gui \
# ros-iron-plotjuggler-ros containing plotjuggler ros plugins
# build currently fails and is not available as a package so we
# have to manually install plotjuggler and plotjuggler-msgs
# https://github.com/PlotJuggler/plotjuggler-ros-plugins/issues/59
ros-iron-plotjuggler \
ros-iron-plotjuggler-msgs \
ros-iron-rmw-cyclonedds-cpp \
ros-iron-rqt-robot-monitor \
ros-iron-soccer-vision-3d-rviz-markers

# Update pip and install colcon-clean
RUN pip3 install pip -U

# Install colcon extensions / patches
RUN python3 -m pip install \
git+https://github.com/ruffsl/colcon-clean \
git+https://github.com/timonegk/colcon-core.git@colors \
git+https://github.com/timonegk/colcon-notification.git@colors \
git+https://github.com/timonegk/colcon-output.git@colors

# Set zsh as default shell
SHELL ["/bin/zsh", "-c"]

# Create home directory and colcon workspace
RUN mkdir -p "/root/colcon_ws"

# Install oh-my-zsh for pretty terminal
RUN sh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" && \
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

# Add zshrc
COPY zshrc "/root/.zshrc"

# This is required for sharing Xauthority
ENV QT_X11_NO_MITSHM=1

# Switch to the workspace directory
WORKDIR "/root/colcon_ws"
43 changes: 43 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"name": "Bit-Bots Iron Dev",

"build": { "dockerfile": "Dockerfile" },

"containerEnv": {
"DISPLAY": "${localEnv:DISPLAY}",
"LIBGL_ALWAYS_SOFTWARE": "1",
"QT_X11_NO_MITSHM": "1",
"DOCKER": "1"
},

"customizations": {
"vscode": {
"settings": {
"terminal.integrated.defaultProfile.linux": "zsh",
"terminal.integrated.profiles.linux": { "zsh": { "path": "/bin/zsh" } }
},
"extensions": [
"ms-iot.vscode-ros"
]
}
},

"workspaceMount": "type=bind,source=${localWorkspaceFolder},target=/root/colcon_ws/src/bitbots_main",
"workspaceFolder": "/root/colcon_ws/src/bitbots_main",

"mounts": [
"type=bind,source=${localEnv:HOME},target=/srv/host_home,consistency=cached",
],

"runArgs": [
"--tmpfs", "/tmp:exec,mode=01777",
"--privileged",
"--net=host",
"--device=/dev/dri:/dev/dri",
"--volume=/tmp/.X11-unix:/tmp/.X11-unix",
"--cap-add=SYS_PTRACE",
"--security-opt", "seccomp=unconfined"
],

"postCreateCommand": "git config --global --add safe.directory '*'"
}
120 changes: 120 additions & 0 deletions .devcontainer/zshrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
# If you come from bash you might have to change your $PATH.
export PATH=$HOME/bin:/usr/local/bin:$HOME/.local/bin:$PATH

# Path to your oh-my-zsh installation.
export ZSH=$HOME/.oh-my-zsh

# Set name of the theme to load.
ZSH_THEME="agnoster"

# Set list of
plugins=(
git
zsh-autosuggestions
)

# Setups for oh-my-zsh
source $ZSH/oh-my-zsh.sh

# User configuration

# You may need to manually set your language environment
export LANG=en_US.UTF-8
export LANGUAGE=en_US:en

# Set personal aliases, overriding those provided by oh-my-zsh libs,
# plugins, and themes. Aliases can be placed here, though oh-my-zsh
# users are encouraged to define aliases within the ZSH_CUSTOM folder.
# For a full list of active aliases, run `alias`.
#
# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"
function mkcd(){
mkdir -p $1
cd $1
}

function mksh(){
vim $1.sh
chmod 744 $1.sh
}


# Settings for the terminal
bindkey "^H" backward-kill-word
bindkey "^[[1;5C" forward-word
bindkey "^[[1;5D" backward-word


# Settings for the prompt to show that we are in a docker container
export PROMPT="%K{black} 🐋 %K{blue}%F{black}%/ %f%k%F{blue}%f " # Prefix the prompt with DOCKER

# Do ros2 specific things
source /opt/ros/iron/setup.zsh &> /dev/null

# Ignore some deprecation warnings
export PYTHONWARNINGS=ignore:::setuptools.command.install,ignore:::setuptools.command.easy_install,ignore:::pkg_resources

# Limit ROS 2 communication to localhost (can be overridden when needed)
export ROS_DOMAIN_ID=24
export ROS_AUTOMATIC_DISCOVERY_RANGE=LOCALHOST

# Set the default colcon workspace
export COLCON_WS="$HOME/colcon_ws"

# Set the default log level for colcon
export COLCON_LOG_LEVEL=30

# Define a log layout
export RCUTILS_COLORIZED_OUTPUT=1
export RCUTILS_CONSOLE_OUTPUT_FORMAT="[{severity}] [{name}]: {message}"

# Set the default Middleware
export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp

# Create a function to update the argcomplete so tab completion works
# This needs to be called every time we source something ROS 2 related
function update_ros2_argcomplete() {
eval "$(register-python-argcomplete3 colcon)"
eval "$(register-python-argcomplete3 ros2)"
}

# Update the tab completion
update_ros2_argcomplete

alias rr='ros2 run'
alias rl='ros2 launch'

alias rte='ros2 topic echo'
alias rtl='ros2 topic list'
alias rth='ros2 topic hz'
alias rtp='ros2 topic pub'

alias rpl='ros2 param list'
alias rpg='ros2 param get'

alias cdc='cd $COLCON_WS'

alias cba='cdc && colcon build --symlink-install --continue-on-error'
alias cb='cdc && colcon build --symlink-install --continue-on-error --packages-up-to'
alias cbs='cdc && colcon build --symlink-install --packages-select'
alias cc='cdc && colcon clean packages --packages-select'
alias cca='cdc && colcon clean packages'

alias sr='source /opt/ros/iron/setup.zsh && update_ros2_argcomplete'
alias sc='source $COLCON_WS/install/setup.zsh && update_ros2_argcomplete'
alias sa='sr && sc'

# Set default editor
export VISUAL="vim"

# Some user instructions
echo "Hello there! Welcome to the Bit-Bots ROS 2 development environment!"
echo "If you just (re)build this container a few manual steps are nessessary:"
echo "Create a ssh key with 'ssh-keygen -q -f $HOME/.ssh/id_rsa -N \"\" && cat $HOME/.ssh/id_rsa.pub'."
echo "Copy the commands output and add it to your GitHub account ('https://github.com/settings/keys') (ctrl+click to open in browser)."
echo "Now you can install the rest of the workspace and compile everything with 'make install && cba'."
echo "To update an existing workspace you can use 'make update && cba'."
echo "To compile all packages in the workspace use 'cba'. If you want to compile only a specific package use 'cbs <package_name>'."
echo "Run 'xhost local:root' in a terminal on the host machine to enable GUI applications (e.g. rviz2) in the container. This needs to be done after every restart of the host machine."
4 changes: 2 additions & 2 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

- [ ] Run `colcon build`
- [ ] Write documentation
- [ ] Create issues for future work
- [ ] Test on your machine
- [ ] Test on the robot
- [ ] This PR is on our `Software` project board
- [ ] Create issues for future work
- [ ] Triage this PR and label it
11 changes: 8 additions & 3 deletions .github/workflows/build.yml → .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Test if all packages build
name: Build & Test
on:
schedule:
- cron: '0 0 * * *'
Expand All @@ -20,8 +20,13 @@ jobs:
- name: Configure git to trust repository
run: git config --global --add safe.directory /__w/bitbots_main/bitbots_main

- name: Add '$HOME/.local/bin' to PATH
run: |
mkdir -p $HOME/.local/bin
echo "PATH=$PATH:/github/home/.local/bin" >> "$GITHUB_ENV"
- name: Pull source code for libraries and install dependencies
run: make install HTTPS=true ARGS="-ci"
run: make install HTTPS=true ARGS="--ci"

- name: Set up colcon workspace
run: |
Expand All @@ -33,7 +38,7 @@ jobs:
. /opt/ros/iron/setup.sh
colcon build --symlink-install
working-directory: /colcon_ws

- name: Test packages
run: |
# Source workspace
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -221,5 +221,7 @@ doku/*
/lib/

# Path to the protocol buffer definitions, which are a diffrerent repository and managed by vcstool
/humanoid_league_misc/humanoid_league_team_communication/humanoid_league_team_communication/RobocupProtocol
/bitbots_team_communication/bitbots_team_communication/RobocupProtocol
# Protobuf generated file
/bitbots_team_communication/bitbots_team_communication/robocup_extension_pb2.py

13 changes: 9 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ repos:
args:
- "--fix"
- "--exit-non-zero-on-fix"
- repo: https://github.com/psf/black
rev: 23.10.0 # keep this version for Ubuntu support
hooks:
- id: black
- id: ruff-format
- repo: https://github.com/pocc/pre-commit-hooks
rev: v1.3.5
hooks:
Expand All @@ -28,3 +25,11 @@ repos:
hooks:
- id: cmake-format
- id: cmake-lint
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-merge-conflict
- id: check-toml
- id: check-xml
- id: check-yaml
- id: detect-private-key
3 changes: 3 additions & 0 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
"${env:COLCON_WS}/install/*/include/**",
"${env:COLCON_WS}/build/**/include/**",
"${env:COLCON_WS}/build/**/rosidl_generator_cpp/**",
"/root/colcon_ws/install/*/include/**",
"/root/colcon_ws/build/**/include/**",
"/root/colcon_ws/build/**/rosidl_generator_cpp/**",
"${workspaceFolder}/**/include/**",
"/opt/ros/${env:ROS_DISTRO}/include/**",
"/usr/include/**"
Expand Down
8 changes: 4 additions & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"autoDocstring.docstringFormat": "sphinx",
"autoDocstring.docstringFormat": "sphinx-notypes",
"autoDocstring.startOnNewLine": true,
"cSpell.language": "en,de-de,lorem",
"cSpell.words": [
"ansible",
Expand Down Expand Up @@ -72,6 +73,7 @@
"rclpy",
"rhoban",
"robocup",
"rory",
"rosbag",
"rosbags",
"rosdep",
Expand Down Expand Up @@ -199,7 +201,5 @@
"python.analysis.extraPaths": [
"/opt/ros/iron/lib/python3.10/site-packages"
],



"cmake.configureOnOpen": false,
}
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ install-no-root: pull-init update-no-root

pip:
# Install and upgrade pip dependencies
pip install --upgrade -r requirements/dev.txt
pip install --upgrade -r requirements/dev.txt --user

pre-commit:
# Install pre-commit hooks for all submodules that have a .pre-commit-config.yaml file
Expand All @@ -24,7 +24,7 @@ install-git-filters:
# The vscode settings file gets updated by the ros extension and contains the full path to the current user's home directory.
# We don't want to commit this path, so we use a git filter to remove it when git adds the file to the staging area.
# This does not affect the file on disk, so vscode will still work as expected.
git config filter.removeFullHomePath.clean "sed '/\/home.*\(install\|build\)/d'"
git config filter.removeFullHomePath.clean "sed '/\/\(home\|root\).*\(install\|build\)/d'"

format:
# Format all files in the repository
Expand Down
Loading

0 comments on commit 5e13cfa

Please sign in to comment.