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.
Add easier entrypoint for curiosity_demo
related to space-ros/space-ros#178 - Add dockerfile for demo - Add makefile for build, run and clean automation
- Loading branch information
1 parent
4d3ed28
commit cb4f9c3
Showing
2 changed files
with
83 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
FROM osrf/space-ros:core | ||
|
||
ENV RMW_IMPLEMENTATION=rmw_cyclonedds_cpp | ||
|
||
# Install dependencies | ||
RUN sudo apt update && sudo apt install -y ros-${ROS_DISTRO}-control-msgs \ | ||
ros-${ROS_DISTRO}-rmw-cyclonedds-cpp | ||
|
||
# Prepare the workspace | ||
SHELL ["bash", "-c"] | ||
RUN mkdir -p ${HOME}/curiosity_ws/src | ||
WORKDIR ${HOME}/curiosity_ws | ||
|
||
COPY ./curiosity_rover_demo src/curiosity_rover_demo | ||
COPY .defaults.yaml .defaults.yaml | ||
|
||
# Build the workspace | ||
RUN source /opt/ros/${ROS_DISTRO}/setup.bash \ | ||
&& source /opt/spaceros/setup.bash \ | ||
&& colcon build --symlink-install | ||
|
||
# Source the workspace | ||
RUN echo "source ${HOME}/curiosity_ws/install/setup.bash" >> ${HOME}/.bashrc |
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,60 @@ | ||
# Define variables | ||
DOCKER_IMAGE = osrf/space-ros:curiosity_demo | ||
WORKSPACE = ${HOME}/curiosity_ws | ||
LOCAL_WORKSPACE = $(shell pwd) | ||
SHELL := /bin/bash | ||
XTERM_CONFIG = -bg black -fg white -fa 'Monospace' -fs 11 | ||
|
||
# Help target to describe each target | ||
.PHONY: help | ||
help: | ||
@echo "Curiosity Rover Makefile" | ||
@echo " make build - Build the Docker image and the Gazebo workspace locally" | ||
@echo " make build-docker - Build the Docker image" | ||
@echo " make build-gazebo - Build the Gazebo workspace locally" | ||
@echo " make run-gazebo - Run the Curiosity Gazebo simulation locally" | ||
@echo " make run-demo - Run the Curiosity demo within Docker" | ||
@echo " make clean - Clean the local workspace" | ||
@echo " make all - Build and run everything" | ||
|
||
# Build all | ||
.PHONY: build | ||
build: build-docker build-gazebo | ||
|
||
# Build the Docker image | ||
.PHONY: build-docker | ||
build-docker: | ||
docker build -t $(DOCKER_IMAGE) . | ||
|
||
# Run the Curiosity Gazebo simulation locally | ||
.PHONY: run-gazebo | ||
run-gazebo: | ||
xterm $(XTERM_CONFIG) -T 'Curiosity Gazebo' -e 'source /opt/ros/${ROS_DISTRO}/setup.bash \ | ||
&& source $(LOCAL_WORKSPACE)/install/setup.bash \ | ||
&& ros2 launch curiosity_gazebo curiosity_gazebo.launch.py' & | ||
|
||
# Build the Gazebo workspace locally | ||
.PHONY: build-gazebo | ||
build-gazebo: | ||
@source /opt/ros/${ROS_DISTRO}/setup.bash && \ | ||
rosdep install --from-paths curiosity_gazebo --ignore-src -r -y && \ | ||
rosdep install --from-paths curiosity_description --ignore-src -r -y && \ | ||
colcon build --symlink-install --base-paths $(LOCAL_WORKSPACE) --install-base $(LOCAL_WORKSPACE)/install \ | ||
--cmake-args -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ | ||
--packages-select curiosity_description curiosity_gazebo | ||
|
||
# Run the Curiosity demo within Docker | ||
.PHONY: run-docker | ||
run-docker: | ||
xterm $(XTERM_CONFIG) -T 'Curiosity Demo' -e "docker run -it --rm \ | ||
-e RMW_IMPLEMENTATION=rmw_cyclonedds_cpp \ | ||
$(DOCKER_IMAGE) \ | ||
bash -c 'source ~/.bashrc && ros2 launch curiosity_rover_demo mars_rover.launch.py'" & | ||
|
||
.PHONY: clean | ||
clean: | ||
rm -rf $(LOCAL_WORKSPACE)/install $(LOCAL_WORKSPACE)/log $(LOCAL_WORKSPACE)/build | ||
|
||
# Build and run everything | ||
.PHONY: run | ||
run: build run-gazebo run-docker |