Skip to content

Commit ebf3d7a

Browse files
mkhansenbotivanperez-keera
authored andcommitted
Add nav2_demo docker files (#126).
1 parent ae03d6c commit ebf3d7a

File tree

8 files changed

+516
-0
lines changed

8 files changed

+516
-0
lines changed

nav2_demo/Dockerfile

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Copyright 2021 Open Source Robotics Foundation, Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
# A Docker configuration script to build the Navigation2/Space ROS image.
16+
#
17+
# The script provides the following build arguments:
18+
#
19+
# VCS_REF - The git revision of the Space ROS source code (no default value).
20+
# VERSION - The version of Space ROS (default: "preview")
21+
22+
FROM osrf/space_nav2:latest
23+
24+
# Define arguments used in the metadata definition
25+
ARG VCS_REF
26+
ARG VERSION="preview"
27+
28+
# Specify the docker image metadata
29+
LABEL org.label-schema.schema-version="1.0"
30+
LABEL org.label-schema.name="Navigation2 demo"
31+
LABEL org.label-schema.description="Preview version of the Navigation2/Space ROS platform"
32+
LABEL org.label-schema.vendor="Open Robotics"
33+
LABEL org.label-schema.version=${VERSION}
34+
LABEL org.label-schema.url="https://github.com/space-ros"
35+
LABEL org.label-schema.vcs-url="https://github.com/space-ros/docker"
36+
LABEL org.label-schema.vcs-ref=${VCS_REF}
37+
38+
# Disable prompting during package installation
39+
ARG DEBIAN_FRONTEND=noninteractive
40+
41+
# Define workspace locations
42+
ENV NAVIGATION2_WS=${HOME_DIR}/nav2_ws
43+
ENV NAV2_DEPS_WS=${HOME_DIR}/nav2_deps_ws
44+
45+
# Setup mars_rover demo
46+
# Install map file for localization
47+
COPY mars_map* /home/spaceros-user/nav2_ws
48+
49+
# Install nav2 config file for mars rover demo
50+
COPY nav2_params.yaml /home/spaceros-user/nav2_ws
51+
52+
# Set up the entrypoint
53+
COPY ./entrypoint.sh /
54+
ENTRYPOINT ["/entrypoint.sh"]
55+
CMD ["bash"]

nav2_demo/README.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# This folder contains the necessary files for running Nav2 on the Mars Rover demo
2+
3+
# This demo is a preliminary release, please file any issues found
4+
5+
## First build this container using the build script
6+
7+
```
8+
build.sh
9+
```
10+
11+
There will now be a docker image called "osrf/space_nav2_demo:latest".
12+
13+
# Run the Mars Rover demo with Nav2 and SLAM toolbox
14+
15+
## Terminal 1 - launch the mars_rover demo
16+
17+
Follow instructions on space-ros/docker/space-robots/README.md.
18+
19+
## Terminal 2 - launch Nav2
20+
21+
Start the space_nav2 container and launch the navigation2 nodes:
22+
23+
```
24+
./run.sh
25+
ros2 launch nav2_bringup navigation_launch.py use_sim_time:=True params_file:=nav2_params.yaml
26+
```
27+
28+
## Terminal 3 - launch localization with map
29+
30+
```
31+
docker exec -it osrf_space_nav2_demo bash
32+
source install/setup.bash
33+
ros2 launch nav2_bringup localization_launch.py use_sim_time:=True map:=mars_map.yaml
34+
```
35+
36+
## Terminal 4 - launch Rviz
37+
38+
Exec into the same space_nav2 container and launch Rviz2:
39+
40+
```
41+
docker exec -it -e DISPLAY=:0 osrf_space_nav2_demo bash
42+
source /opt/ros/humble/setup.bash
43+
source install/setup.bash
44+
ros2 launch nav2_bringup rviz_launch.py
45+
```
46+
47+
## Localize the robot and send a Nav2 goal
48+
49+
In the Rviz GUI, localize robot in Rviz using 2D Pose estimate tool, with an arrow pointing up at the center of the grid.
50+
Wait for Nav2 to initialize / costmaps to appear.
51+
When the costmap appears, send a goal using the "Nav2 goal" tool in Rviz

nav2_demo/build.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env bash
2+
3+
ORG=osrf
4+
IMAGE=space_nav2_demo
5+
TAG=latest
6+
7+
VCS_REF=""
8+
VERSION=preview
9+
10+
# Exit script with failure if build fails
11+
set -eo pipefail
12+
13+
echo ""
14+
echo "##### Building Navigation2/Space ROS Docker Image #####"
15+
echo ""
16+
17+
docker build -t $ORG/$IMAGE:$TAG \
18+
--build-arg VCS_REF="$VCS_REF" \
19+
--build-arg VERSION="$VERSION" .
20+
21+
echo ""
22+
echo "##### Done! #####"
23+

nav2_demo/entrypoint.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Setup the Navigation2 environment
5+
source "/home/spaceros-user/nav2_ws/install/setup.bash"
6+
exec "$@"

nav2_demo/mars_map.pgm

Lines changed: 4 additions & 0 deletions
Large diffs are not rendered by default.

nav2_demo/mars_map.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
image: mars_map.pgm
2+
mode: trinary
3+
resolution: 0.05
4+
origin: [-28.2, -22.1, 0]
5+
negate: 0
6+
occupied_thresh: 0.65
7+
free_thresh: 0.25

0 commit comments

Comments
 (0)