diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml new file mode 100644 index 0000000..b402833 --- /dev/null +++ b/.github/workflows/docker-build.yml @@ -0,0 +1,54 @@ +name: Build and Push Docker Image to Docker Hub + +on: + push: + branches: [ "master", "dev_container"] + pull_request: + branches: [ "master"] + +env: + # Use docker.io for Docker Hub if empty + REGISTRY: docker.io + REGISTRY_USER: matthiasmayr + # github.repository as + IMAGE_NAME: ${{ github.event.repository.name }} + +jobs: + + build: + runs-on: ubuntu-20.04 + + steps: + - uses: actions/checkout@v3 + - name: Build the Docker image + run: docker build . + + push_to_registry: + name: Push Docker image to Docker Hub + runs-on: ubuntu-20.04 + steps: + - name: Check out the repo + uses: actions/checkout@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Log in to Docker Hub + uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 + with: + images: ${{ env.REGISTRY }}/${{ env.REGISTRY_USER }}/${{ env.IMAGE_NAME }} + + - name: Build and push Docker image + uses: docker/build-push-action@v2 + with: + context: "{{defaultContext}}" + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a5349e9 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,29 @@ +# Use ROS Noetic base image +FROM ros:noetic-ros-base +RUN apt-get update && apt-get install -y git tmux python3-pip python3-catkin-tools ros-noetic-rosmon + +# Set the working directory in the container +RUN mkdir -p /catkin_ws/src +WORKDIR /catkin_ws +RUN /bin/bash -c "source /opt/ros/${ROS_DISTRO}/setup.bash; catkin init" +RUN /bin/bash -c "source /opt/ros/${ROS_DISTRO}/setup.bash; catkin build" +WORKDIR /catkin_ws/src +RUN git clone https://github.com/RVMI/skiros2 +RUN git clone https://github.com/RVMI/skiros2_std_lib +RUN git clone https://github.com/RVMI/skiros2_examples +RUN git clone https://github.com/RVMI/skiros2_template_lib + +COPY ./skiros2/scripts/install_fd_task_planner.sh /root/install_fd_task_planner.sh +RUN /root/install_fd_task_planner.sh ~/.skiros/planner + +# Install dependencies & python dependencies +RUN /bin/bash -c "source /opt/ros/${ROS_DISTRO}/setup.bash; rosdep install --from-paths . --ignore-src --rosdistro=$ROS_DISTRO -y" +RUN /bin/bash -c "source /opt/ros/${ROS_DISTRO}/setup.bash; cd skiros2; pip install -r requirements.txt --user; cd .." + +# Build the catkin workspace +RUN /bin/bash -c "source /opt/ros/${ROS_DISTRO}/setup.bash; cd /catkin_ws && catkin build" +# Add source command to bashrc +RUN echo "source /catkin_ws/devel/setup.bash" >> /root/.bashrc + +# tmux session +ENTRYPOINT ["/bin/bash"] \ No newline at end of file diff --git a/README.md b/README.md index de93d03..70d555c 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,33 @@ SkiROS offers the following features: SkiROS is compatible with Ubuntu 18.04/ROS Melodic and Ubuntu 20.04/ROS Noetic, Python 2 and 3. +### Docker Container + +The easiest way to get started is to use the provided Docker container. After installing [Docker](https://docs.docker.com/get-docker/), you can pull the container from Docker Hub and run it with the following commands: + +```shell +docker pull matthiasmayr/skiros2:master +``` +Then it can be started with: +```shell +docker run --rm -it \ + --device=/dev/dri:/dev/dri \ + --ipc=host \ + --net=host \ + --privileged \ + --env DISPLAY=$DISPLAY \ + --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" \ + --volume ~/.Xauthority:/root/.Xauthority \ + matthiasmayr/skiros2:master +``` +The container will start a bash shell. Often it makes sense to start a terminal multiplexer like *tmux*. The code is in the folder `/catkin_ws`. +Then to start the SkiROS2 system, run: +```shell +roslaunch skiros2 skiros.launch +# Or try one of the examples like +roslaunch skiros2_examples turtlesim_example.launch +``` + ### Installation Instructions To use SkiROS you must have [ROS](https://wiki.ros.org/ROS/Installation) installed on your machine. diff --git a/skiros2/scripts/install_fd_task_planner.sh b/skiros2/scripts/install_fd_task_planner.sh index 9544a9b..c17bba8 100755 --- a/skiros2/scripts/install_fd_task_planner.sh +++ b/skiros2/scripts/install_fd_task_planner.sh @@ -1,11 +1,22 @@ #!/bin/bash - echo "Installing planner..." -#Navigate to install folder +# Check if git is installed +if ! [ -x "$(command -v git)" ]; then + echo "Error: git is not installed." >&2 + exit 1 +fi + default="~/.skiros/planner" -echo "Select install folder or leave blank for default [default: $default]:" -read folder +# Check if an argument is provided +if [ $# -eq 0 ]; then + echo "Select install folder or leave blank for default [default: $default]:" + read folder +else + folder=$1 +fi + +# Navigate to install folder if [[ $folder == "" ]]; then folder=${default/"~"/$HOME} else