Skip to content

Commit

Permalink
refactor(devcontainer): source ros functions/aliases from repo
Browse files Browse the repository at this point in the history
  • Loading branch information
texhnolyze committed Mar 16, 2024
1 parent 2e620ad commit 691d71f
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 68 deletions.
70 changes: 35 additions & 35 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,43 +1,43 @@
{
"name": "Bit-Bots Iron Dev",
"name": "Bit-Bots Iron Dev",

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

"containerEnv": {
"DISPLAY": "${localEnv:DISPLAY}",
"LIBGL_ALWAYS_SOFTWARE": "1",
"QT_X11_NO_MITSHM": "1",
"DOCKER": "1"
},
"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"
]
}
},
"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",
"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",
],
"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"
],
"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 '*'"
}
"postCreateCommand": "git config --global --add safe.directory '*'"
}
42 changes: 9 additions & 33 deletions .devcontainer/zshrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# If you come from bash you might have to change your $PATH.
export PATH=$HOME/bin:/usr/local/bin:$HOME/.local/bin:$PATH

# Set the default shell to zsh when running zsh
export SHELL="$(which zsh)"

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

Expand Down Expand Up @@ -50,8 +53,7 @@ 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
# >>> bit-bots initialize >>>

# Ignore some deprecation warnings
export PYTHONWARNINGS=ignore:::setuptools.command.install,ignore:::setuptools.command.easy_install,ignore:::pkg_resources
Expand All @@ -73,38 +75,12 @@ 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'
# Load our ros plugin script containing useful functions and aliases for ROS 2 development
if [[ -f $COLCON_WS/src/bitbots_main/scripts/ros.plugin.sh ]]; then
source $COLCON_WS/src/bitbots_main/scripts/ros.plugin.sh
fi

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'
# <<< bit-bots initialize <<<

# Set default editor
export VISUAL="vim"
Expand Down

0 comments on commit 691d71f

Please sign in to comment.