Skip to content

Commit

Permalink
Merge pull request #2 from ETHZ-RobotX/release/v1.2.0
Browse files Browse the repository at this point in the history
Release/v1.2.0
  • Loading branch information
Huoleit authored Jun 28, 2024
2 parents 06897eb + 1c3e2fb commit 3a11436
Show file tree
Hide file tree
Showing 8 changed files with 88 additions and 46 deletions.
19 changes: 19 additions & 0 deletions .devcontainer/devcontainer-lock.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"features": {
"ghcr.io/devcontainers/features/common-utils:2": {
"version": "2.4.3",
"resolved": "ghcr.io/devcontainers/features/common-utils@sha256:e9e1d402031416ed5fc500f242c27ffa1043a27b5ba612e6596ea62503c8ae70",
"integrity": "sha256:e9e1d402031416ed5fc500f242c27ffa1043a27b5ba612e6596ea62503c8ae70"
},
"ghcr.io/devcontainers/features/desktop-lite:1": {
"version": "1.2.0",
"resolved": "ghcr.io/devcontainers/features/desktop-lite@sha256:3ae291711d296da3829948600f49c9acf26f58c14ff636f34240fbf240deaf43",
"integrity": "sha256:3ae291711d296da3829948600f49c9acf26f58c14ff636f34240fbf240deaf43"
},
"ghcr.io/devcontainers/features/git:1": {
"version": "1.3.0",
"resolved": "ghcr.io/devcontainers/features/git@sha256:aa0f267b6f10c7a1ba2545d6beb5d3d8576b584d5017dce4ba2d61d409f342f9",
"integrity": "sha256:aa0f267b6f10c7a1ba2545d6beb5d3d8576b584d5017dce4ba2d61d409f342f9"
}
}
}
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"onAutoForward": "ignore"
},
"containerUser": "robotx",
"initializeCommand": "docker pull ghcr.io/ethz-robotx/rss_workspace:main",
// "initializeCommand": "docker pull ghcr.io/ethz-robotx/rss_workspace:main",
"postCreateCommand": "bash ./.devcontainer/post-create.sh",
"customizations": {
"vscode": {
Expand Down
3 changes: 2 additions & 1 deletion .devcontainer/generate_catkin_buildlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ def main():
args = parser.parse_args()
top_level_packages = args.packages

all_build_packages = set()
all_build_packages = set(top_level_packages)
for pkg in top_level_packages:
all_build_packages |= generate_dependencies(pkg)

all_build_packages = sorted(all_build_packages)
print(" ".join(all_build_packages).lstrip())

Expand Down
79 changes: 42 additions & 37 deletions .devcontainer/post-create.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,48 +10,53 @@ echo "export HISTFILE=${ROOT}/.zsh_history" >> ~/.zshrc
echo "source /opt/ros/noetic/setup.bash" >> ~/.bashrc
echo "source /opt/ros/noetic/setup.zsh" >> ~/.zshrc

# Setup fzf
# Setup fzf completions
echo "eval \"\$(fzf --bash)\"" >> ~/.bashrc
echo "source <(fzf --zsh)" >> ~/.zshrc

# Setup vcs completions
echo "source /usr/share/vcstool-completion/vcs.bash" >> ~/.bashrc
echo "source /usr/share/vcstool-completion/vcs.zsh" >> ~/.zshrc

# Setup aliases
source "${ROOT}/.devcontainer/setup_alias.sh" ${ROOT}

# Make folder `src` if not exists
# Clone repositories and configure the workspace if `src` folder does not exist
if [ ! -d "${ROOT}/src" ]; then
# Create the `src` folder
mkdir -p "${ROOT}/src"
fi

# Clone the repository
vcs import --input "${SMB_RAW_REPO_FILE_URL}" --recursive --skip-existing "${ROOT}/src"

# Setup catkin workspace
catkin init --workspace "${ROOT}" &>/dev/null

# Generate buildlist for catkin config
# NOTE: catkin build will only build the packages themselve listed in the buildlist but not their dependencies
# so we need to generate a buildlist of packages that are recursively dependent on the packages we want to build
# NOTE: The input to the script is a list of top-level packages to build and the output is the complete list of packages to build
# NOTE: You can use the `scripts/list_top_level_packages.sh` script to list the top level packages in the workspace
# CAUTION: This script should be run after the workspace is created and the repositories are cloned as it uses the workspace to generate the buildlist
BUILD_PKG_LIST=$(python3 "${ROOT}/.devcontainer/generate_catkin_buildlist.py" --workspace "${ROOT}" \
catkin_simple \
smb_exploration \
smb_gazebo \
smb_mission_planner \
smb_mpc \
smb_msf \
smb_msf_graph \
smb_path_planner \
object_detection \
)

# Split the string into an array of package names to pass to catkin config as positional arguments
IFS=' ' read -r -a BUILD_PKGS_ARRAY <<< "${BUILD_PKG_LIST}"

# Configure the workspace
catkin config --workspace "${ROOT}" \
--extend /opt/ros/noetic \
--cmake-args -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -- \
--buildlist "${BUILD_PKGS_ARRAY[@]}"

# Clone the repository
vcs import --input "${SMB_RAW_REPO_FILE_URL}" --recursive --skip-existing "${ROOT}/src"

# Setup catkin workspace
catkin init --workspace "${ROOT}" &>/dev/null

# Generate buildlist for catkin config
# NOTE: catkin build will only build the packages themselve listed in the buildlist but not their dependencies
# so we need to generate a buildlist of packages that are recursively dependent on the packages we want to build
# NOTE: The input to the script is a list of top-level packages to build and the output is the complete list of packages to build
# NOTE: You can use the `scripts/list_top_level_packages.sh` script to list the top level packages in the workspace
# CAUTION: This script should be run after the workspace is created and the repositories are cloned as it uses the workspace to generate the buildlist
BUILD_PKG_LIST=$(python3 "${ROOT}/.devcontainer/generate_catkin_buildlist.py" --workspace "${ROOT}" \
catkin_simple \
smb_exploration \
smb_gazebo \
smb_mission_planner \
smb_msf_graph \
smb_path_planner \
object_detection \
)

# Split the string into an array of package names to pass to catkin config as positional arguments
IFS=' ' read -r -a BUILD_PKGS_ARRAY <<< "${BUILD_PKG_LIST}"

# Configure the workspace
catkin config --workspace "${ROOT}" \
--extend /opt/ros/noetic \
--cmake-args -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -- \
--buildlist "${BUILD_PKGS_ARRAY[@]}"
else
echo "Workspace already exists. Skipping cloning and configuring the workspace."
echo "If you want to re-clone the repository, please remove the 'src' folder and rebuild the workspace."
fi
8 changes: 5 additions & 3 deletions .devcontainer/setup_alias.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ setup_alias_in_zsh "wssetup" "source ${ROOT}/devel/setup.zsh"
setup_alias_in_bash "wssetup" "source ${ROOT}/devel/setup.bash"

## Setup alias for other commands
## Example: define ROS_MASTER_URI and ROS_IP for connecting to SMB 263
## The ip address of every SMB is 10.0.x.5 where x is the last digit of SMB Robot Number. Example: For SMB 263 the on-board computer IP address is 10.0.3.5
setup_alias_in_shell "connect-smb263" "export ROS_MASTER_URI=http://10.0.3.5:11311 && export ROS_IP=$(hostname -I | awk '{print $1}')"
## Example: define ROS_MASTER_URI and ROS_IP for connecting to SMB
## It will automatically set ROS_MASTER_URI to the IP address of the SMB NUC and ROS_IP to the IP address of the host machine
## based on the default gateway IP address (the IP address of the router on the SMB)
## Note: The ip address of every SMB is 10.0.x.5 where x is the last digit of SMB Robot Number. Example: For SMB 261 the on-board computer IP address is 10.0.1.5
setup_alias_in_shell "connect-smb" "export ROS_MASTER_URI=http://\$(ip route show default | grep -oP 'via \K\d+\.\d+\.\d+').5:11311 ; export ROS_IP=\$(ip route get 8.8.8.8 | grep -oP '(?<=src )\S+') ; echo 'ROS_MASTER_URI and ROS_IP set to ' ; printenv ROS_MASTER_URI ; printenv ROS_IP"

# Catkin build memory & job limit
setup_alias_in_shell "build-limit" "catkin build --jobs 8 --mem-limit 70%"
6 changes: 3 additions & 3 deletions .tmux.conf
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ set -g default-terminal "screen-256color"
setw -g allow-rename off
setw -g automatic-rename off

## Change prefix key to C-a, easier to type, same to "screen"
# unbind C-b
# set -g prefix C-a
# Enable pane title
set -g pane-border-format "#{pane_index} #{pane_title}"
set -g pane-border-status bottom

# Enable mouse support
set -g mouse on
Expand Down
12 changes: 11 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,14 @@ Changelog

1.1.0 (2024-06-26)
--------------
* Change `matplotlib` backend to `Qt5Agg` to avoid `tkinter` dependency
* Change `matplotlib` backend to `Qt5Agg` to avoid `tkinter` dependency

1.2.0 (2024-06-28)
--------------
* Comment out `initializeCommand` in `.devcontainer/devcontainer.json` to avoid always pulling the image
* Add `.devcontainer/devcontainer-lock.json` to lock the feature version
* Add `connect-smb` alias in `.devcontainer/setup_alias.sh`
* Add shell completion for `vcs`
* Do not clone repositories and configure workspace if `src` exists
* Add pane title for `tmux`
* fix: add top-level packages to `.devcontainer/generate_catkin_buildlist.py`
5 changes: 5 additions & 0 deletions scripts/start_smb_tmux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ else
tmux split-window -h
tmux split-window -v

# Set the title of each pane
tmux select-pane -t $SESSION_NAME:0.0 -T "Gazebo"
tmux select-pane -t $SESSION_NAME:0.1 -T "Object Detection"
tmux select-pane -t $SESSION_NAME:0.2 -T "Custom Command"

# Send the command to panes
tmux send-keys -t $SESSION_NAME:0.0 'wssetup && roslaunch smb_gazebo sim.launch launch_gazebo_gui:=true keyboard_teleop:=true'
tmux send-keys -t $SESSION_NAME:0.1 'wssetup && roslaunch object_detection object_detection.launch gpu:=off'
Expand Down

0 comments on commit 3a11436

Please sign in to comment.