Skip to content

Commit 526677f

Browse files
authored
Update dockerfile to ROS 2 (#34)
* Check dockerfile in CI * Update README for new dockerfile Signed-off-by: Ryan Friedman <ryanfriedman5410+github@gmail.com>
1 parent a43c745 commit 526677f

File tree

3 files changed

+49
-24
lines changed

3 files changed

+49
-24
lines changed

.github/workflows/docker.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
name: Build docker/Dockerfile
3+
on:
4+
push:
5+
branches:
6+
- 'ros2'
7+
pull_request:
8+
branches:
9+
- '*'
10+
11+
jobs:
12+
build:
13+
runs-on: [ubuntu-22.04]
14+
strategy:
15+
fail-fast: false
16+
steps:
17+
- uses: actions/checkout@v4
18+
- name: Build the Dockerfile
19+
run: |
20+
docker build --file docker/Dockerfile --tag terrain-navigation-ros2 .
21+
shell: bash

README.md

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,34 +15,28 @@ The implementation includes a global planner based on a RRT* in the Dubins Airpl
1515

1616
### Setting up the Build Environment using Docker
1717

18-
If your operating system doesn't support ROS 1 noetic, docker is a great alternative.
18+
If your operating system doesn't support ROS 2 humble, docker is a great alternative.
1919

2020
First, create the image, with the build context at the root of this repo
2121

2222
```Bash
23-
docker build --file docker/Dockerfile --tag terrain-navigation-ros1 .
23+
docker build --file docker/Dockerfile --tag terrain-navigation-ros2 .
2424
```
2525

2626
You can see the image exists:
2727
```Bash
2828
docker images
2929
>>> REPOSITORY TAG IMAGE ID CREATED SIZE
30-
>>> terrain-navigation-ros1 latest 5565f845ab4f 2 weeks ago 774MB
30+
>>> terrain-navigation-ros2 latest 5565f845ab4f 2 weeks ago 774MB
3131
```
3232

3333
Next, run the image, mounting in the source into a workspace. All the dependencies are now installed.
3434
```Bash
35-
docker run --network=host -it -v $(pwd):/root/catkin_ws/src/terrain-navigation -w /root/catkin_ws terrain-navigation-ros1 bash
35+
docker run --network=host -it -v $(pwd):/root/ros2_ws/src/ethz-asl/terrain-navigation -w /root/ros2_ws terrain-navigation-ros2 bash
3636
```
3737

3838
### Running the Build
3939

40-
Configure the catkin workspace
41-
```Bash
42-
catkin config --extend "/opt/ros/noetic"
43-
catkin config --merge-devel
44-
```
45-
4640
For dependencies that do not have binaries available, pull them into your ROS workspace using vcs.
4741
```Bash
4842
cd ~/ros2_ws/src
@@ -96,7 +90,7 @@ accordingly.
9690

9791
The default launch file can be run as the following command.
9892
```Bash
99-
roslaunch terrain_navigation_ros test_terrain_planner.launch
93+
ros2 launch terrain_navigation_ros test_terrain_planner.launch.py
10094
```
10195

10296
You can use [QGroundcontrol](http://qgroundcontrol.com/) to configure and fly the vehicle. Get the vehicle flying, and plan a mission to fly!

docker/Dockerfile

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
# https://github.com/osrf/docker_images/blob/df19ab7d5993d3b78a908362cdcd1479a8e78b35/ros/noetic/ubuntu/focal/ros-core/Dockerfile
2-
FROM ros:noetic-ros-core-focal as repo-deps
1+
# https://github.com/osrf/docker_images/blob/27cc0b68263bbbb10bb58dd814efc0a6b0a01ec7/ros/humble/ubuntu/jammy/ros-core/Dockerfile
2+
FROM ros:humble-ros-core-jammy as repo-deps
33
# This layer installs basic tools and the direct dependencies of terrain-navigation.
44

55
SHELL ["/bin/bash", "-c"]
66

7-
WORKDIR /root/catkin_ws/src/terrain-navigation
7+
WORKDIR /root/ros2_ws/src/ethz-asl/terrain-navigation
88

99
COPY mav_planning_rviz/package.xml mav_planning_rviz/package.xml
1010
COPY planner_msgs/package.xml planner_msgs/package.xml
@@ -13,32 +13,42 @@ COPY terrain_navigation_ros/package.xml terrain_navigation_ros/package.xml
1313
COPY terrain_planner/package.xml terrain_planner/package.xml
1414
COPY terrain_planner_benchmark/package.xml terrain_planner_benchmark/package.xml
1515

16-
WORKDIR /root/catkin_ws/
16+
WORKDIR /root/ros2_ws/
1717

1818
RUN apt-get update \
1919
# https://ros.org/reps/rep-2001.html#dev-tools
2020
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
2121
ros-dev-tools \
22-
ros-noetic-catkin \
23-
python3-catkin-tools \
2422
python3-pip \
23+
python3-colcon-mixin \
24+
&& colcon mixin add default https://raw.githubusercontent.com/colcon/colcon-mixin-repository/master/index.yaml \
25+
&& colcon mixin update default \
2526
&& rosdep init \
2627
&& rosdep update \
2728
&& DEBIAN_FRONTEND=noninteractive rosdep install --from-paths src --ignore-src -r -y \
28-
&& python3 -m pip install \
29-
wstool \
3029
&& rm -rf /var/lib/apt/lists/*
3130

3231

3332
FROM repo-deps as all-deps
3433
# This layer installs dependencies of the other source packages.
3534

36-
COPY dependencies.rosinstall src/terrain-navigation/dependencies.rosinstall
37-
RUN wstool init src src/terrain-navigation/dependencies.rosinstall
38-
RUN wstool update -t src -j4
35+
COPY terrain-navigation.repos src/ethz-asl/terrain-navigation/terrain-navigation.repos
3936

37+
WORKDIR /root/ros2_ws/src
38+
RUN vcs import --recursive --debug --skip-existing < ethz-asl/terrain-navigation/terrain-navigation.repos
39+
40+
WORKDIR /root/ros2_ws/
4041
RUN apt-get update \
4142
&& rosdep update \
42-
&& source /opt/ros/noetic/setup.bash \
43-
&& rosdep install --from-paths src --ignore-src -y \
43+
&& source /opt/ros/humble/setup.bash \
44+
&& rosdep install --from-paths src --ignore-src -r -y \
4445
&& rm -rf /var/lib/apt/lists/*
46+
47+
FROM all-deps as build
48+
49+
WORKDIR /root/ros2_ws/src/ethz-asl/terrain-navigation
50+
COPY . .
51+
WORKDIR /root/ros2_ws/
52+
53+
RUN source /opt/ros/humble/setup.bash \
54+
&& colcon build --mixin release

0 commit comments

Comments
 (0)