forked from space-ros/demos
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change Dockerfile and add build and run scripts (fix issue space-ros#36)
- Loading branch information
1 parent
7391144
commit 5c56110
Showing
6 changed files
with
176 additions
and
48 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -48,60 +48,48 @@ This package and associated plugins and models were developped by [Robin Baran]( | |
|
||
## Running the demo <a name="running_demo"></a> | ||
### Building the docker <a name="building_docker"></a> | ||
To build the docker image, go to your ROS2 workspace. Make a spaceros workspace if you don't already have one: | ||
```bash | ||
mkdir -p ~spaceros_ws/src | ||
cd ~spaceros_ws | ||
``` | ||
To build the docker image, go to the docker folder and run: | ||
|
||
Clone the demos and simulation repos. Checkout both repos to the feature branch `feat/lunar_pole_exploration_rover`: | ||
```bash | ||
cd ~spaceros_ws | ||
git clone [email protected]:RBinsonB/demos.git | ||
git checkout feat/lunar_pole_exploration_rover | ||
cd ~spaceros_ws | ||
git clone [email protected]:RBinsonB/simulation.git | ||
git checkout feat/lunar_pole_exploration_rover | ||
cd docker | ||
./build.sh | ||
``` | ||
|
||
Build the image: | ||
```bash | ||
cd ~spaceros_ws | ||
docker build -f demos/lunar_pole_exploration_rover/docker/Dockerfile -t lunar_rover_image . | ||
``` | ||
The build process will take about 30 minutes, depending on the host computer. | ||
|
||
|
||
### Running the docker <a name="running_docker"></a> | ||
Run the following command before running the container: | ||
After building the image, you can see the newly-built image by running: | ||
|
||
```bash | ||
xhost +local:docker | ||
docker image list | ||
``` | ||
|
||
Run the container by typing: | ||
The output will look something like this: | ||
|
||
``` | ||
REPOSITORY TAG IMAGE ID CREATED SIZE | ||
openrobotics/moveit2 latest 6edb2edc9643 10 hours ago 15.5GB | ||
openrobotics/lunar_pole_exploration_rover_demo latest 629b13cf7b74 12 hours ago 7.8GB | ||
nvidia/cudagl 11.4.1-devel-ubuntu20.04 336416dfcbba 1 week ago 5.35GB | ||
``` | ||
|
||
The new image is named **openrobotics/lunar_pole_exploration_rover_demo:latest**. | ||
|
||
There is a run.sh script provided for convenience that will run the spaceros image in a container. | ||
|
||
```bash | ||
docker run --rm -it --name lunar_pole_exploration_rover \ | ||
--network host \ | ||
-e DISPLAY \ | ||
-e TERM \ | ||
-e QT_X11_NO_MITSHM=1 \ | ||
lunar_rover_image | ||
./run.sh | ||
``` | ||
|
||
If you have gpu | ||
To enable hardware acceleration, use run_gpu.sh (requires a docker install not from snap)* | ||
|
||
```bash | ||
docker run --rm -it --name lunar_pole_exploration_rover \ | ||
--network host \ | ||
--privileged \ | ||
--gpus all \ | ||
-e NVIDIA_VISIBLE_DEVICES=all \ | ||
-e NVIDIA_DRIVER_CAPABILITIES=graphics \ | ||
-e DISPLAY=$DISPLAY \ | ||
-e TERM \ | ||
-e QT_X11_NO_MITSHM=1 \ | ||
-e XAUTHORITY=$XAUTHORITY \ | ||
--mount type=bind,source=/tmp/.X11-unix,target=/tmp/.X11-unix \ | ||
lunar_rover_image | ||
./run_gpu.sh | ||
``` | ||
|
||
|
||
|
||
Once the container is running, launch the demo by typing the following command: | ||
```bash | ||
ros2 launch lunar_pole_exploration_rover lunar_pole_exploration_rover.launch.py | ||
|
This file contains 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
This file contains 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,23 @@ | ||
#!/usr/bin/env bash | ||
|
||
ORG=openrobotics | ||
IMAGE=lunar_pole_exploration_rover_demo | ||
TAG=latest | ||
|
||
VCS_REF="" | ||
VERSION=preview | ||
|
||
# Exit script with failure if build fails | ||
set -eo pipefail | ||
|
||
echo "" | ||
echo "##### Building Space ROS Demo Docker Image #####" | ||
echo "" | ||
|
||
docker build -t $IMAGE:$TAG \ | ||
--build-arg VCS_REF="$VCS_REF" \ | ||
--build-arg VERSION="$VERSION" . | ||
|
||
echo "" | ||
echo "##### Done! #####" | ||
|
This file contains 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
This file contains 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,16 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Runs a docker container with the image created by build.bash | ||
# Requires: | ||
# docker | ||
# an X server | ||
|
||
IMG_NAME=openrobotics/lunar_pole_exploration_rover_demo | ||
|
||
# Replace `/` with `_` to comply with docker container naming | ||
# And append `_runtime` | ||
CONTAINER_NAME="$(tr '/' '_' <<< "$IMG_NAME")" | ||
|
||
# Start the container | ||
docker run --rm -it --name $CONTAINER_NAME --network host \ | ||
-e DISPLAY -e TERM -e QT_X11_NO_MITSHM=1 $IMG_NAME |
This file contains 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,28 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Runs a docker container with the image created by build.bash | ||
# Requires: | ||
# docker | ||
# an X server | ||
|
||
IMG_NAME=openrobotics/lunar_pole_exploration_rover_demo | ||
|
||
xhost +local:docker | ||
|
||
# Replace `/` with `_` to comply with docker container naming | ||
# And append `_runtime` | ||
CONTAINER_NAME="$(tr '/' '_' <<< "$IMG_NAME")" | ||
|
||
# Start the container | ||
docker run --rm -it --name $CONTAINER_NAME \ | ||
--network host \ | ||
--privileged \ | ||
--gpus all \ | ||
-e NVIDIA_VISIBLE_DEVICES=all \ | ||
-e NVIDIA_DRIVER_CAPABILITIES=graphics \ | ||
-e DISPLAY=$DISPLAY \ | ||
-e TERM \ | ||
-e QT_X11_NO_MITSHM=1 \ | ||
-e XAUTHORITY=$XAUTHORITY \ | ||
--mount type=bind,source=/tmp/.X11-unix,target=/tmp/.X11-unix \ | ||
$IMG_NAME |