-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Support Dockerfile #1124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
GyuH13
wants to merge
25
commits into
main
Choose a base branch
from
feature-docker-update
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Support Dockerfile #1124
Changes from 24 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
04adcbc
add sbc docker
GyuH13 41aa268
Merge branch 'main' of https://github.com/ROBOTIS-GIT/turtlebot3 into…
GyuH13 70feb3d
docker: add Dockerfile.sbc and update docker-compose.yml for turtlebot3
GyuH13 1f225cc
docker: remove old Dockerfile and docker-compose.yml, update Dockerfi…
GyuH13 ef4bd76
docker: additional packages
GyuH13 b397010
docker: add nano package to Dockerfile.sbc
GyuH13 e0efe4f
docker: reorganize package installation in Dockerfile.pc for clarity
GyuH13 d6375b2
add docker file
GyuH13 b5eec21
Add dockerfile and compose.yml
GyuH13 585ab3f
docker: remove outdated Dockerfiles and update image reference in doc…
GyuH13 d150e90
docker: comment out build section in multiple docker-compose files fo…
GyuH13 5131d08
fix volumn mapping error
GyuH13 9dd5b5a
Add container management scripts for Turtlebot3
GyuH13 62c205c
docker: remove redundant comment from udev rule setup in container sc…
GyuH13 cc66146
docker: comment out udev rule setup in container scripts to avoid con…
GyuH13 49c96c4
docker: comment out environment variable exports in Dockerfiles for c…
GyuH13 35576be
Bump
GyuH13 6f718a8
docker: Update Dockerfiles to include additional dependencies for ROS…
Woojin-Crive 314b6a4
gitignore: Update .gitignore to include .DS_Store file exclusion
Woojin-Crive f0c3465
fix EOF
GyuH13 e0d05e1
add udev rule in container.sh pc version
GyuH13 5fd48d2
support docker-compose environment
GyuH13 c1cae49
unified pc and sbc
GyuH13 a37b7e3
change volumn mount path
GyuH13 e8d5765
add nav2-route install command
GyuH13 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -59,3 +59,4 @@ build-*/ | |
| *.txt.user | ||
| *.gch | ||
| /.project | ||
| .DS_Store | ||
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| # Use the base ROS2 humble image | ||
| FROM ros:humble-ros-base | ||
|
|
||
| # Set environment variables | ||
| ENV DEBIAN_FRONTEND=noninteractive | ||
| ENV COLCON_WS=/root/turtlebot3_ws | ||
|
|
||
| # Install the required packages in a single layer and clean up afterwards | ||
| RUN apt-get update && \ | ||
| apt-get install -y --no-install-recommends \ | ||
| ros-${ROS_DISTRO}-desktop \ | ||
| python3-argcomplete \ | ||
| python3-colcon-common-extensions \ | ||
| libboost-system-dev \ | ||
| build-essential \ | ||
| libudev-dev \ | ||
| udev \ | ||
| git \ | ||
| nano \ | ||
| ros-${ROS_DISTRO}-cartographer \ | ||
| ros-${ROS_DISTRO}-cartographer-ros \ | ||
| ros-${ROS_DISTRO}-navigation2 \ | ||
| ros-${ROS_DISTRO}-nav2-bringup \ | ||
| ros-${ROS_DISTRO}-turtlebot3-msgs \ | ||
| ros-${ROS_DISTRO}-dynamixel-sdk \ | ||
| ros-${ROS_DISTRO}-xacro \ | ||
| ros-${ROS_DISTRO}-hls-lfcd-lds-driver \ | ||
| ros-${ROS_DISTRO}-ld08-driver \ | ||
| ros-${ROS_DISTRO}-coin-d4-driver \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| WORKDIR ${COLCON_WS} | ||
|
|
||
| RUN mkdir -p ${COLCON_WS}/src && \ | ||
| cd ${COLCON_WS}/src && \ | ||
| git clone -b humble https://github.com/ROBOTIS-GIT/turtlebot3.git | ||
|
|
||
| RUN bash -c "source /opt/ros/${ROS_DISTRO}/setup.bash && \ | ||
| cd ${COLCON_WS} && \ | ||
| colcon build --symlink-install --cmake-args -DCMAKE_BUILD_TYPE=Release" | ||
|
|
||
| RUN echo "source /opt/ros/${ROS_DISTRO}/setup.bash" >> ~/.bashrc && \ | ||
| echo "source ${COLCON_WS}/install/setup.bash" >> ~/.bashrc && \ | ||
| echo "alias cb='colcon build --symlink-install --cmake-args -DCMAKE_BUILD_TYPE=Release'" >> ~/.bashrc && \ | ||
| echo "export ROS_DOMAIN_ID=30 # TURTLEBOT3" >> ~/.bashrc && \ | ||
| echo "# export TURTLEBOT3_MODEL= # burger, waffle, waffle_pi" >> ~/.bashrc && \ | ||
| echo "# export LDS_MODEL= # LDS-01, LDS-02, LDS-03" >> ~/.bashrc | ||
|
|
||
| CMD ["bash"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,116 @@ | ||
| #!/bin/bash | ||
|
|
||
| # Get the directory where the script is located | ||
| SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
| CONTAINER_NAME="turtlebot3" | ||
|
|
||
| # Determine whether to use docker-compose or docker compose | ||
| if docker compose version &> /dev/null; then | ||
| COMPOSE_CMD="docker compose" | ||
| else | ||
| COMPOSE_CMD="docker-compose" | ||
| fi | ||
|
|
||
| # Function to display help | ||
| show_help() { | ||
| echo "Usage: $0 [command]" | ||
| echo "" | ||
| echo "Commands:" | ||
| echo " help Show this help message" | ||
| echo " start Start the container" | ||
| echo " enter Enter the running container" | ||
| echo " stop Stop the container" | ||
| echo "" | ||
| echo "Examples:" | ||
| echo " $0 start Start container" | ||
| echo " $0 enter Enter the running container" | ||
| echo " $0 stop Stop the container" | ||
| } | ||
|
|
||
| # Function to start the container | ||
| start_container() { | ||
| # Set up X11 forwarding only if DISPLAY is set | ||
| if [ -n "$DISPLAY" ]; then | ||
| echo "Setting up X11 forwarding..." | ||
| xhost +local:docker || true | ||
| else | ||
| echo "Warning: DISPLAY environment variable is not set. X11 forwarding will not be available." | ||
| fi | ||
|
|
||
| echo "Starting Turtlebot3 container..." | ||
|
|
||
| # Copy udev rule for TurtleBot3 | ||
| sudo tee /etc/udev/rules.d/99-tb3.rules > /dev/null <<EOF | ||
| ATTRS{idVendor}=="0483", ATTRS{idProduct}=="5740", ENV{ID_MM_DEVICE_IGNORE}="1", MODE:="0666" | ||
| ATTRS{idVendor}=="0483", ATTRS{idProduct}=="df11", MODE:="0666" | ||
| ATTRS{idVendor}=="fff1", ATTRS{idProduct}=="ff48", ENV{ID_MM_DEVICE_IGNORE}="1", MODE:="0666" | ||
| ATTRS{idVendor}=="10c4", ATTRS{idProduct}=="ea60", ENV{ID_MM_DEVICE_IGNORE}="1", MODE:="0666", SYMLINK+="tb3_lidar" | ||
| EOF | ||
|
|
||
| # Reload udev rules | ||
| echo "Reloading udev rules..." | ||
| sudo udevadm control --reload-rules | ||
| sudo udevadm trigger | ||
|
|
||
| # Pull the latest images | ||
| $COMPOSE_CMD -f "${SCRIPT_DIR}/docker-compose.yml" pull | ||
|
|
||
| # Run docker-compose | ||
| $COMPOSE_CMD -f "${SCRIPT_DIR}/docker-compose.yml" up -d | ||
| } | ||
|
|
||
| # Function to enter the container | ||
| enter_container() { | ||
| # Set up X11 forwarding only if DISPLAY is set | ||
| if [ -n "$DISPLAY" ]; then | ||
| echo "Setting up X11 forwarding..." | ||
| xhost +local:docker || true | ||
| else | ||
| echo "Warning: DISPLAY environment variable is not set. X11 forwarding will not be available." | ||
| fi | ||
|
|
||
| if ! docker ps | grep -q "$CONTAINER_NAME"; then | ||
| echo "Error: Container is not running" | ||
| exit 1 | ||
| fi | ||
| docker exec -it "$CONTAINER_NAME" bash | ||
| } | ||
|
|
||
| # Function to stop the container | ||
| stop_container() { | ||
| if ! docker ps | grep -q "$CONTAINER_NAME"; then | ||
| echo "Error: Container is not running" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "Warning: This will stop and remove the container. All unsaved data in the container will be lost." | ||
| read -p "Are you sure you want to continue? [y/N] " -n 1 -r | ||
| echo | ||
| if [[ $REPLY =~ ^[Yy]$ ]]; then | ||
| $COMPOSE_CMD -f "${SCRIPT_DIR}/docker-compose.yml" down | ||
| else | ||
| echo "Operation cancelled." | ||
| exit 0 | ||
| fi | ||
| } | ||
|
|
||
| # Main command handling | ||
| case "$1" in | ||
| "help") | ||
| show_help | ||
| ;; | ||
| "start") | ||
| start_container | ||
| ;; | ||
| "enter") | ||
| enter_container | ||
| ;; | ||
| "stop") | ||
| stop_container | ||
| ;; | ||
| *) | ||
| echo "Error: Unknown command" | ||
| show_help | ||
| exit 1 | ||
| ;; | ||
| esac |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| services: | ||
| turtlebot3: | ||
| container_name: turtlebot3 | ||
| image: robotis/turtlebot3:humble-latest | ||
| # build: | ||
| # context: . | ||
| # dockerfile: Dockerfile.pc | ||
| tty: true | ||
| restart: unless-stopped | ||
| cap_add: | ||
| - SYS_NICE | ||
| ulimits: | ||
| rtprio: 99 | ||
| rttime: -1 | ||
| memlock: 8428281856 | ||
| network_mode: host | ||
| ipc: host | ||
| pid: host | ||
| environment: | ||
| - DISPLAY=${DISPLAY} | ||
| - QT_X11_NO_MITSHM=1 | ||
| volumes: | ||
| - /dev:/dev | ||
| - /dev/shm:/dev/shm | ||
| - /tmp/.X11-unix:/tmp/.X11-unix:rw | ||
| - /tmp/.docker.xauth:/tmp/.docker.xauth:rw | ||
| - ./workspace:/workspace | ||
| - ../../:/root/turtlebot3_ws/src/turtlebot3 | ||
| privileged: true | ||
| command: bash | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| # Use the base ROS2 jazzy image | ||
| FROM ros:jazzy-ros-base | ||
|
|
||
| # Set environment variables | ||
| ENV DEBIAN_FRONTEND=noninteractive | ||
| ENV COLCON_WS=/root/turtlebot3_ws | ||
|
|
||
| # Install the required packages in a single layer and clean up afterwards | ||
| RUN apt-get update && \ | ||
| apt-get install -y --no-install-recommends \ | ||
| ros-${ROS_DISTRO}-desktop \ | ||
| python3-argcomplete \ | ||
| python3-colcon-common-extensions \ | ||
| libboost-system-dev \ | ||
| build-essential \ | ||
| libudev-dev \ | ||
| udev \ | ||
| git \ | ||
| nano \ | ||
| ros-${ROS_DISTRO}-cartographer \ | ||
| ros-${ROS_DISTRO}-cartographer-ros \ | ||
| ros-${ROS_DISTRO}-navigation2 \ | ||
| ros-${ROS_DISTRO}-nav2-bringup \ | ||
| ros-${ROS_DISTRO}-turtlebot3-msgs \ | ||
| ros-${ROS_DISTRO}-dynamixel-sdk \ | ||
| ros-${ROS_DISTRO}-xacro \ | ||
| ros-${ROS_DISTRO}-hls-lfcd-lds-driver \ | ||
| ros-${ROS_DISTRO}-ld08-driver \ | ||
| ros-${ROS_DISTRO}-coin-d4-driver \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| WORKDIR ${COLCON_WS} | ||
|
|
||
| RUN mkdir -p ${COLCON_WS}/src && \ | ||
| cd ${COLCON_WS}/src && \ | ||
| git clone -b jazzy https://github.com/ROBOTIS-GIT/turtlebot3.git | ||
|
|
||
| RUN bash -c "source /opt/ros/${ROS_DISTRO}/setup.bash && \ | ||
| cd ${COLCON_WS} && \ | ||
| colcon build --symlink-install --cmake-args -DCMAKE_BUILD_TYPE=Release" | ||
|
|
||
| RUN echo "source /opt/ros/${ROS_DISTRO}/setup.bash" >> ~/.bashrc && \ | ||
| echo "source ${COLCON_WS}/install/setup.bash" >> ~/.bashrc && \ | ||
| echo "alias cb='colcon build --symlink-install --cmake-args -DCMAKE_BUILD_TYPE=Release'" >> ~/.bashrc && \ | ||
| echo "export ROS_DOMAIN_ID=30 # TURTLEBOT3" >> ~/.bashrc && \ | ||
| echo "# export TURTLEBOT3_MODEL= # burger, waffle, waffle_pi" >> ~/.bashrc && \ | ||
| echo "# export LDS_MODEL= # LDS-01, LDS-02, LDS-03" >> ~/.bashrc | ||
|
|
||
| CMD ["bash"] |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using
privileged: truegives the container full root access to the host machine, which poses a significant security risk. It's highly recommended to avoid this. Instead, consider granting only the necessary capabilities viacap_addand mapping specific devices (e.g.,/dev/ttyUSB0) using thedeviceskey. This follows the principle of least privilege.