Skip to content
This repository has been archived by the owner on Mar 25, 2024. It is now read-only.

Commit

Permalink
* Template infrastructure for opendlv-device-gps-pos
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Berger <[email protected]>
  • Loading branch information
chrberger committed Feb 22, 2018
1 parent 38ac579 commit 9f96fd6
Show file tree
Hide file tree
Showing 15 changed files with 26,911 additions and 34 deletions.
33 changes: 1 addition & 32 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,32 +1 @@
# Prerequisites
*.d

# Compiled Object files
*.slo
*.lo
*.o
*.obj

# Precompiled Headers
*.gch
*.pch

# Compiled Dynamic libraries
*.so
*.dylib
*.dll

# Fortran module files
*.mod
*.smod

# Compiled Static libraries
*.lai
*.la
*.a
*.lib

# Executables
*.exe
*.out
*.app
build
21 changes: 21 additions & 0 deletions .multi-arch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/sh

VERSION=$1

cat <<EOF >/tmp/multi.yml
image: chalmersrevere/opendlv-device-gps-pos-multi:$VERSION
manifests:
- image: chalmersrevere/opendlv-device-gps-pos-amd64:$VERSION
platform:
architecture: amd64
os: linux
- image: chalmersrevere/opendlv-device-gps-pos-armhf:$VERSION
platform:
architecture: arm
os: linux
- image: chalmersrevere/opendlv-device-gps-pos-aarch64:$VERSION
platform:
architecture: arm64
os: linux
EOF
manifest-tool-linux-amd64 push from-spec /tmp/multi.yml
32 changes: 32 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
language: cpp

branches:
only:
- "/^master$/"
- "/^pre-release$/"

cache: ccache

compiler:
- gcc

addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-6

install:
- "[ $CC = gcc ] && export CC=gcc-6 || true"
- "[ $CXX = g++ ] && export CXX=g++-6 || true"

script:
- mkdir -p build && cd build && cmake .. && make && make test

notifications:
email:
on_success: never
on_failure: never
slack:
secure: j2R2/rMFRjvXuaJ2GLDUi5bdv4keb0a2ZC/J7l8QY1YPMQvQskevUB4B1Nv+e8QEpq+ERFhpnrB/tLL6FqzCj0/t7ydowLPHvRWneXIAaWeD6BWHezFcFUoys8eJ78T5eUwEjamVaFLLVZsqYjzzO19nkWY1QImPi6cpylo2Y7OB1DhTqPZhBJCj0XTMMpn5cgb+WmVyN5UTgfq+rGQGDdzyUtVrcdoMD8CECXQSuhyJnreTv8v9ZVFU3tD0khhxY9nUhd1dU6olDmq/hmbAlf7kfAFW0FSqu9BCXYMh3rvX3vpw/4EmOxXCCxIYnonY6YX0An7V6rIet4+Fjuk7X/VXo+ZGpoKtrBNRslXy/Wjkhvrq6qduIosiErDZxd6ofqNlYNFFUgC/UEbQSf1VE+3PaozfUqd0OnjjaLOgPqAUlM8Wjxuzs49MSjKhHmd/mxOE2xckx0a8rjoZ4wvoXz5NSXjGjGO+ye5Q6JAlzrNQwjyTNdVn9n3jqBTX3sVjS9j3rWOlXeiZ2VFEoWVibXC4V5O7jQQBeI7GYC8vaUvAeHAlydyCaeUcZm2iOahhJuYhdfNbmlfsp08FkHzMEiGYX9wAfw/5CtASBRiZSfQPMs4tS0tsmbeuZErTBgvWKpCt8KVHYwPXs+IoPmLiXpfQAVYwRfiC9MPu05CICgA=
94 changes: 94 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# Copyright (C) 2018 Christian Berger
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

cmake_minimum_required(VERSION 3.2)

project(opendlv-device-gps-pos)

################################################################################
# Defining the relevant versions of OpenDLV Standard Message Set and libcluon.
set(OPENDLV_STANDARD_MESSAGE_SET opendlv-standard-message-set-v0.9.1.odvd)
set(CLUON_COMPLETE cluon-complete-v0.0.51.hpp)

################################################################################
# This project requires C++14 or newer.
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# Strip unneeded symbols from binaries.
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -s")
# Build a static binary.
set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++")
# Add further warning levels.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
-D_XOPEN_SOURCE=700 \
-D_FORTIFY_SOURCE=2 \
-O2 \
-fstack-protector \
-fomit-frame-pointer \
-pipe \
-pedantic -pedantic-errors \
-Werror \
-Weffc++ \
-Wall -Wextra -Wshadow -Wdeprecated \
-Wdiv-by-zero -Wfloat-equal -Wfloat-conversion -Wsign-compare -Wpointer-arith \
-Wuninitialized -Wunreachable-code \
-Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-but-set-parameter -Wunused-but-set-variable \
-Wunused-value -Wunused-variable -Wunused-result \
-Wmissing-field-initializers -Wmissing-format-attribute -Wmissing-include-dirs -Wmissing-noreturn")
# Threads are necessary for linking the resulting binaries as UDPReceiver is running in parallel.
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)

################################################################################
# Extract cluon-msc from cluon-complete.hpp.
add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/cluon-msc
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_CURRENT_SOURCE_DIR}/src/${CLUON_COMPLETE} ${CMAKE_BINARY_DIR}/cluon-complete.hpp
COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_BINARY_DIR}/cluon-complete.hpp ${CMAKE_BINARY_DIR}/cluon-complete.cpp
COMMAND ${CMAKE_CXX_COMPILER} -o ${CMAKE_BINARY_DIR}/cluon-msc ${CMAKE_BINARY_DIR}/cluon-complete.cpp -std=c++14 -pthread -D HAVE_CLUON_MSC
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/src/${CLUON_COMPLETE})

################################################################################
# Generate opendlv-standard-message-set.{hpp,cpp} from ${OPENDLV_STANDARD_MESSAGE_SET} file.
add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/opendlv-standard-message-set.cpp
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMAND ${CMAKE_BINARY_DIR}/cluon-msc --cpp-sources --cpp-add-include-file=opendlv-standard-message-set.hpp --out=${CMAKE_BINARY_DIR}/opendlv-standard-message-set.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/${OPENDLV_STANDARD_MESSAGE_SET}
COMMAND ${CMAKE_BINARY_DIR}/cluon-msc --cpp-headers --out=${CMAKE_BINARY_DIR}/opendlv-standard-message-set.hpp ${CMAKE_CURRENT_SOURCE_DIR}/src/${OPENDLV_STANDARD_MESSAGE_SET}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/src/${OPENDLV_STANDARD_MESSAGE_SET} ${CMAKE_BINARY_DIR}/cluon-msc)
# Add current build directory as include directory as it contains generated files.
include_directories(SYSTEM ${CMAKE_BINARY_DIR})
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src)

################################################################################
# Gather all object code first to avoid double compilation.
add_library(${PROJECT_NAME}-core OBJECT ${CMAKE_CURRENT_SOURCE_DIR}/src/pos-decoder.cpp ${CMAKE_BINARY_DIR}/opendlv-standard-message-set.cpp)
set(LIBRARIES Threads::Threads)

################################################################################
# Create executable.
add_executable(${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/src/${PROJECT_NAME}.cpp $<TARGET_OBJECTS:${PROJECT_NAME}-core>)
target_link_libraries(${PROJECT_NAME} ${LIBRARIES})

################################################################################
# Enable unit testing.
enable_testing()
add_executable(${PROJECT_NAME}-runner ${CMAKE_CURRENT_SOURCE_DIR}/test/tests-pos-decoder.cpp $<TARGET_OBJECTS:${PROJECT_NAME}-core>)
target_link_libraries(${PROJECT_NAME}-runner ${LIBRARIES})
add_test(NAME ${PROJECT_NAME}-runner COMMAND ${PROJECT_NAME}-runner)

################################################################################
# Install executable.
install(TARGETS ${PROJECT_NAME} DESTINATION bin COMPONENT ${PROJECT_NAME})
48 changes: 48 additions & 0 deletions Dockerfile.aarch64
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Copyright (C) 2018 Christian Berger
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

# Part to build opendlv-device-gps-pos.
FROM docker.io/project31/aarch64-alpine-qemu:3.5-7 as builder
MAINTAINER Christian Berger "[email protected]"

RUN [ "cross-build-start" ]

RUN cat /etc/apk/repositories && \
echo http://dl-4.alpinelinux.org/alpine/v3.7/main > /etc/apk/repositories && \
echo http://dl-4.alpinelinux.org/alpine/v3.7/community >> /etc/apk/repositories

RUN apk update && \
apk --no-cache add \
cmake \
g++ \
make
ADD . /opt/sources
WORKDIR /opt/sources
RUN mkdir build && \
cd build && \
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/tmp/opendlv-device-gps-pos-dest .. && \
make && make test && make install

RUN [ "cross-build-end" ]


# Part to deploy opendlv-device-gps-pos.
FROM docker.io/project31/aarch64-alpine-qemu:3.5-7
MAINTAINER Christian Berger "[email protected]"

WORKDIR /usr/bin
COPY --from=builder /tmp/opendlv-device-gps-pos-dest/bin/opendlv-device-gps-pos .
CMD ["/usr/bin/opendlv-device-gps-pos"]

40 changes: 40 additions & 0 deletions Dockerfile.amd64
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Copyright (C) 2018 Christian Berger
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

# Part to build opendlv-device-gps-pos.
FROM alpine:3.7 as builder
MAINTAINER Christian Berger "[email protected]"
RUN apk update && \
apk --no-cache add \
cmake \
g++ \
make \
upx
ADD . /opt/sources
WORKDIR /opt/sources
RUN mkdir build && \
cd build && \
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/tmp/opendlv-device-gps-pos-dest .. && \
make && make test && make install && upx -9 /tmp/opendlv-device-gps-pos-dest/bin/opendlv-device-gps-pos


# Part to deploy opendlv-device-gps-pos.
FROM alpine:3.7
MAINTAINER Christian Berger "[email protected]"

WORKDIR /usr/bin
COPY --from=builder /tmp/opendlv-device-gps-pos-dest/bin/opendlv-device-gps-pos .
CMD ["/usr/bin/opendlv-device-gps-pos"]

48 changes: 48 additions & 0 deletions Dockerfile.armhf
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Copyright (C) 2018 Christian Berger
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

# Part to build opendlv-device-gps-pos.
FROM pipill/armhf-alpine:edge as builder
MAINTAINER Christian Berger "[email protected]"

RUN [ "cross-build-start" ]

RUN cat /etc/apk/repositories && \
echo http://dl-4.alpinelinux.org/alpine/v3.7/main > /etc/apk/repositories && \
echo http://dl-4.alpinelinux.org/alpine/v3.7/community >> /etc/apk/repositories

RUN apk update && \
apk --no-cache add \
cmake \
g++ \
make
ADD . /opt/sources
WORKDIR /opt/sources
RUN mkdir build && \
cd build && \
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/tmp/opendlv-device-gps-pos-dest .. && \
make && make test && make install

RUN [ "cross-build-end" ]


# Part to deploy opendlv-device-gps-pos.
FROM pipill/armhf-alpine:edge
MAINTAINER Christian Berger "[email protected]"

WORKDIR /usr/bin
COPY --from=builder /tmp/opendlv-device-gps-pos-dest/bin/opendlv-device-gps-pos .
CMD ["/usr/bin/opendlv-device-gps-pos"]

57 changes: 55 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,55 @@
# opendlv-device-gps-pos
OpenDLV Microservice to interface with Applanix POS GPS/INSS units
## OpenDLV Microservice to interface with Applanix POS GPS/INSS units

This repository provides source code to interface with an Applanix POS GPS/INSS unit
providing data in POS data format for the OpenDLV software ecosystem.

[![Build Status](https://travis-ci.org/chalmers-revere/opendlv-device-gps-pos.svg?branch=master)](https://travis-ci.org/chalmers-revere/opendlv-device-gps-pos) [![License: GPLv3](https://img.shields.io/badge/license-GPL--3-blue.svg
)](https://www.gnu.org/licenses/gpl-3.0.txt)


## Table of Contents
* [Dependencies](#dependencies)
* [Usage](#usage)
* [Build from sources on the example of Ubuntu 16.04 LTS](#build-from-sources-on-the-example-of-ubuntu-1604-lts)
* [License](#license)


## Dependencies
No dependencies! You just need a C++14-compliant compiler to compile this
project as it ships the following dependencies as part of the source distribution:

* [libcluon](https://github.com/chrberger/libcluon) - [![License: GPLv3](https://img.shields.io/badge/license-GPL--3-blue.svg
)](https://www.gnu.org/licenses/gpl-3.0.txt)
* [Unit Test Framework Catch2](https://github.com/catchorg/Catch2/releases/tag/v2.1.2) - [![License: Boost Software License v1.0](https://img.shields.io/badge/License-Boost%20v1-blue.svg)](http://www.boost.org/LICENSE_1_0.txt)


## Usage
This microservice is created automatically on changes to this repository via Docker's public registry for:
* [x86_64](https://hub.docker.com/r/chalmersrevere/opendlv-device-gps-pos-amd64/tags/)
* [armhf](https://hub.docker.com/r/chalmersrevere/opendlv-device-gps-pos-armhf/tags/)
* [aarch64](https://hub.docker.com/r/chalmersrevere/opendlv-device-gps-pos-aarch64/tags/)

To run this microservice using our pre-built Docker multi-arch images to connect
to an Applanix POS GPS/INSS unit broadcasting data to `192.168.1.77:5602` and to publish
the messages according to OpenDLV Standard Message Set into session 111 in
Google Protobuf format, simply start it as follows:

```
docker run --init --rm --net=host chalmersrevere/opendlv-device-gps-pos-multi:v0.0.1 opendlv-device-gps-pos --pos_ip=192.168.1.77 --pos_port=5602 --cid=111 --verbose
```

## Build from sources on the example of Ubuntu 16.04 LTS
To build this software, you need cmake, C++14 or newer, and make. Having these
preconditions, just run `cmake` and `make` as follows:

```
mkdir build && cd build
cmake -D CMAKE_BUILD_TYPE=Release ..
make && make test && make install
```


## License

* This project is released under the terms of the GNU GPLv3 License

Loading

0 comments on commit 9f96fd6

Please sign in to comment.