Skip to content

Commit

Permalink
fix: docker container support
Browse files Browse the repository at this point in the history
  • Loading branch information
BarisYazici committed Sep 11, 2024
1 parent 72b8d8e commit 11373e3
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 15 deletions.
93 changes: 84 additions & 9 deletions ingenuity_mars_helicopter/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,88 @@
FROM openrobotics/space_robots_demo
# Copyright 2021 Open Source Robotics Foundation, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

COPY ingenuity_mars_helicopter /home/spaceros-user/demos_ws/src/ingenuity_mars_helicopter
COPY helicopter_flight_control /home/spaceros-user/demos_ws/src/helicopter_flight_control
COPY helicopter_flight_simulation /home/spaceros-user/demos_ws/src/helicopter_flight_simulation
COPY ingenuity_bringup /home/spaceros-user/demos_ws/src/ingenuity_bringup
COPY ingenuity_description /home/spaceros-user/demos_ws/src/ingenuity_description
COPY ./entrypoint.sh /home/spaceros-user/entrypoint.sh
FROM osrf/space-ros:latest

# Disable prompting during package installation
ARG DEBIAN_FRONTEND=noninteractive

RUN sudo chmod +x /home/spaceros-user/entrypoint.sh
ENV INGENUITY_DIR=${HOME_DIR}/ingenuity_helicopter

ENTRYPOINT ["/home/spaceros-user/entrypoint.sh"]
RUN sudo apt-get update && \
DEBIAN_FRONTEND=noninteractive sudo apt-get install -y --no-install-recommends \
ros-humble-hardware-interface \
ros-humble-generate-parameter-library \
ros-humble-xacro \
ros-humble-controller-interface \
ros-humble-realtime-tools \
ros-humble-ros2-control-test-assets \
ros-humble-controller-manager \
ros-humble-joint-state-publisher-gui \
ros-humble-control-msgs \
ros-humble-gazebo-ros \
ros-humble-control-toolbox \
ros-humble-ackermann-msgs \
ros-humble-ament-cmake \
ros-humble-ament-cmake-clang-format \
ros-humble-moveit \
ros-humble-joint-state-broadcaster \
libignition-gazebo6-dev \
ros-humble-joint-trajectory-controller \
ros-humble-ros-ign-gazebo \
ros-humble-ros-gz-bridge \
libeigen3-dev

# Install the various build and test tools
RUN sudo apt install -y \
build-essential \
clang-format \
cmake \
git \
libbullet-dev \
python3-colcon-common-extensions \
python3-flake8 \
python3-pip \
python3-pytest-cov \
python3-rosdep \
python3-setuptools \
python3-vcstool \
wget

# Install some pip packages needed for testing
RUN python3 -m pip install -U \
argcomplete \
flake8-blind-except \
flake8-builtins \
flake8-class-newline \
flake8-comprehensions \
flake8-deprecated \
flake8-docstrings \
flake8-import-order \
flake8-quotes \
pytest-repeat \
pytest-rerunfailures \
pytest

COPY ingenuity_mars_helicopter ${INGENUITY_DIR}/src/ingenuity_mars_helicopter
COPY helicopter_flight_control ${INGENUITY_DIR}/src/helicopter_flight_control
COPY helicopter_flight_simulation ${INGENUITY_DIR}/src/helicopter_flight_simulation
COPY ingenuity_bringup ${INGENUITY_DIR}/src/ingenuity_bringup
COPY ingenuity_description ${INGENUITY_DIR}/src/ingenuity_description
COPY ./entrypoint.sh ${INGENUITY_DIR}/entrypoint.sh

RUN sudo chown -R ${USERNAME}:${USERNAME} ${INGENUITY_DIR}

RUN sudo chmod +x ${INGENUITY_DIR}/entrypoint.sh

ENTRYPOINT ["/home/spaceros-user/ingenuity_helicopter/entrypoint.sh"]
8 changes: 7 additions & 1 deletion ingenuity_mars_helicopter/build.sh
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
docker build -t ingenuity_flight_simulator .
# !/usr/bin/env bash


docker build -t ingenuity_flight_simulator .

echo ""
echo "##### Done! #####"
6 changes: 4 additions & 2 deletions ingenuity_mars_helicopter/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/bin/bash
sudo chown -R ${USERNAME}:${USERNAME} /home/spaceros-user/ingenuity_helicopter
source /home/spaceros-user/spaceros/install/setup.sh
source /opt/ros/humble/setup.sh
cd /home/spaceros-user/demos_ws
cd /home/spaceros-user/ingenuity_helicopter
colcon build --packages-select helicopter_flight_control helicopter_flight_simulation ingenuity_description ingenuity_bringup
source /home/spaceros-user/demos_ws/install/setup.sh
source /home/spaceros-user/ingenuity_helicopter/install/setup.sh
ros2 launch ingenuity_bringup ingenuity_demo.launch.py
6 changes: 3 additions & 3 deletions ingenuity_mars_helicopter/run.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

# Runs a docker container with the image created by build.bash
# Runs a docker container with the image created by build.sh
# Requires:
# docker
# an X server
Expand All @@ -19,8 +19,7 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PARENT_DIR="$(dirname "$SCRIPT_DIR")"

# Start the container
# if you don't have an nvidia card, remove the --gpus all flag
# --gpus all
# if you don't have a graphic nvidia card, remove the --gpus all flag
docker run --rm -it --gpus all \
--name "$CONTAINER_NAME" \
--network host \
Expand All @@ -29,4 +28,5 @@ docker run --rm -it --gpus all \
-e DISPLAY="$DISPLAY" \
-e TERM="$TERM" \
-e QT_X11_NO_MITSHM=1 \
-e RMW_IMPLEMENTATION=rmw_cyclonedds_cpp \
"$IMG_NAME"

0 comments on commit 11373e3

Please sign in to comment.