From ba8169ccc02726b3b4b2e023d5072b60e58459f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Kowalski?= <82044322+pkowalsk1@users.noreply.github.com> Date: Fri, 9 Dec 2022 10:08:21 +0100 Subject: [PATCH] Add docker (#1) * add Dockerfile * Update README.md * fix rutx cred * Update .github/workflows/build-docker-image.yaml Co-authored-by: Dawid Kmak <73443304+KmakD@users.noreply.github.com> Co-authored-by: Dawid Kmak <73443304+KmakD@users.noreply.github.com> --- .github/workflows/build-docker-image.yaml | 51 +++++++++++++++++++++++ Dockerfile | 24 +++++++++++ README.md | 18 ++++++++ compose.yaml | 13 ++++++ ros_entrypoint.sh | 7 ++++ 5 files changed, 113 insertions(+) create mode 100644 .github/workflows/build-docker-image.yaml create mode 100755 Dockerfile create mode 100644 compose.yaml create mode 100755 ros_entrypoint.sh diff --git a/.github/workflows/build-docker-image.yaml b/.github/workflows/build-docker-image.yaml new file mode 100644 index 0000000..4a51b95 --- /dev/null +++ b/.github/workflows/build-docker-image.yaml @@ -0,0 +1,51 @@ +name: Build/Publish Docker Image + +on: + push: + branches: + - 'main' + workflow_dispatch: + inputs: + tag: + description: 'tag that the image will be built with' + required: true + default: 'noetic' + branch: + description: 'branch that will be used to build image' + required: true + default: 'main' + +jobs: + build_nmea_gps_ros: + runs-on: ubuntu-20.04 + + steps: + + - name: Checkout + uses: actions/checkout@v1 + with: + ref: ${{ github.event.inputs.branch }} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + with: + version: latest + + - name: Login to Docker Registry + uses: docker/login-action@v1 + with: + registry: docker.io + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v2 + with: + context: . + file: ./Dockerfile + platforms: linux/arm64, linux/amd64 + push: true + tags: husarion/nmea-gps:noetic \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100755 index 0000000..2c36809 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,24 @@ +FROM ros:noetic-ros-core + +SHELL ["/bin/bash", "-c"] + +WORKDIR /ros_ws + +RUN apt-get update && \ + apt-get install -y \ + git \ + python3-pip && \ + pip3 install \ + rosdep && \ + git clone -b decode-udp-line https://github.com/ros-drivers/nmea_navsat_driver.git src/nmea_navsat_driver && \ + rosdep init && \ + rosdep update --rosdistro $ROS_DISTRO && \ + rosdep install --from-paths src -y -i && \ + source /opt/ros/$ROS_DISTRO/setup.bash && \ + catkin_make -DCATKIN_ENABLE_TESTING=0 -DCMAKE_BUILD_TYPE=Release && \ + apt-get autoremove -y && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +COPY ./ros_entrypoint.sh / +ENTRYPOINT [ "/ros_entrypoint.sh" ] \ No newline at end of file diff --git a/README.md b/README.md index efca900..068218e 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,20 @@ # nmea-gps-docker Building a Docker image for a GPS module + +### GPS API + +GPS data in [NMEA](https://en.wikipedia.org/wiki/NMEA_0183) format is forwarded to RPi IP address at port 5000, typically it is `10.15.20.2:5000`. +You can make sure the address is correct by typing [http://10.15.20.1](http://10.15.20.1) into your browser (Username: `admin`, Password: `Husarion1`). Navigate to `Services -> GPS -> NMEA -> NMEA forwarding -> Hostname and Port`. Remember that you must be connected to the robot's WIFi network. If changes were needed, finish the connfiguration by pressing `save & apply` at the bottom of the screen. + +Data frequency is 1Hz and can be interacted ether with GPSD daemon (`gpsd -N udp://10.15.20.2:5000`) or directly with [ROS package](https://github.com/ros-drivers/nmea_navsat_driver/tree/decode-udp-line) redirecting signal to ROS topic. + +It is recommended to use docker image. To start the container type: + +```bash +git clone https://github.com/husarion/nmea-gps-docker.git +cd nmea-gps-docker + +docker compose up +``` + +You should be able to see data on `/panther/fix` topic (`rostopic echo /panther/fix`). diff --git a/compose.yaml b/compose.yaml new file mode 100644 index 0000000..fed7536 --- /dev/null +++ b/compose.yaml @@ -0,0 +1,13 @@ +services: + + nmea-gps: + image: husarion/nmea-gps:noetic + container_name: nmea-gps + network_mode: host + environment: + - ROS_MASTER_URI=http://10.15.20.2:11311 + command: > + rosrun nmea_navsat_driver nmea_socket_driver + __ns:=panther + _port:=5000 + _local_ip:=10.15.20.2 \ No newline at end of file diff --git a/ros_entrypoint.sh b/ros_entrypoint.sh new file mode 100755 index 0000000..49464cb --- /dev/null +++ b/ros_entrypoint.sh @@ -0,0 +1,7 @@ +#!/bin/bash +set -e + +source "/opt/ros/$ROS_DISTRO/setup.bash" +source "/ros_ws/devel/setup.bash" + +exec "$@" \ No newline at end of file