Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detectcone cleanup #3

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
build
command
tmp
32 changes: 0 additions & 32 deletions .vscode/launch.json

This file was deleted.

58 changes: 28 additions & 30 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ project(cfsd18-perception-detectcone)

################################################################################
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might want to change the header author to Cfsd instead of Christian :D @chrberger .

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, please :-)

# 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.102.hpp)

set(OPENDLV_STANDARD_MESSAGE_SET opendlv-standard-message-set-v0.9.5.odvd)
set(CLUON_COMPLETE cluon-complete-v0.0.114.hpp)
set(CLUON_PATH ${CMAKE_CURRENT_SOURCE_DIR})
################################################################################
# This project requires C++14 or newer.
set(CMAKE_CXX_STANDARD 14)
Expand Down Expand Up @@ -53,41 +53,47 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
# Threads are necessary for linking the resulting binaries as UDPReceiver is running in parallel.
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)

SET(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake.Modules")

################################################################################
# Extract cluon-msc from cluon-complete.hpp.

# Downloads a file, populates the root dir (needs to discussed if we want this...)
# execute_process(COMMAND wget -P ${CLUON_PATH} https://raw.githubusercontent.com/chrberger/libcluon/gh-pages/headeronly/${CLUON_COMPLETE})

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_CURRENT_SOURCE_DIR}/include/${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})
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/include/${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
add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/opendlv-standard-message-set.hpp
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)
COMMAND ${CMAKE_BINARY_DIR}/cluon-msc --cpp --out=${CMAKE_BINARY_DIR}/opendlv-standard-message-set.hpp ${CMAKE_CURRENT_SOURCE_DIR}/include/${OPENDLV_STANDARD_MESSAGE_SET}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/include/${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(SYSTEM ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty)

################################################################################
# Gather all object code first to avoid double compilation. This needs to be done for all added objects, can become very long? Why is this object and not static which works
add_library(${PROJECT_NAME}-core STATIC ${CMAKE_CURRENT_SOURCE_DIR}/src/detectcone.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/collector.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/cone.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/point.cpp)
add_custom_target(generate_opendlv_standard_message_set_hpp DEPENDS ${CMAKE_BINARY_DIR}/opendlv-standard-message-set.hpp)
add_dependencies(${PROJECT_NAME}-core generate_opendlv_standard_message_set_hpp)

################################################################################
# OpenCV
#set(CMAKE_PREFIX_PATH "/usr/local/opt/opencv3/share/OpenCV")
find_package(OpenCV REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})


################################################################################
# Eigen
find_package(Eigen3 REQUIRED NO_MODULE)
include_directories(${Eigen3_INCLUDE_DIRS})
find_package(Eigen3 3.3 REQUIRED NO_MODULE)
include_directories(${Eigen_INCLUDE_DIRS})

###############################################################################
# OpenMP
Expand All @@ -101,39 +107,31 @@ IF(USE_OpenMP)
ENDIF()

###############################################################################
#TinyDnn
# TinyDnn
find_package(TinyDNN REQUIRED)

###############################################################################
#TBB
# TBB
find_package(TBB REQUIRED)
include_directories(${TBB_INCLUDE_DIRS})
add_definitions(${TBB_DEFINITIONS})

SET(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}")

################################################################################
# LibRT
find_package(LibRT REQUIRED)
set(LIBRARIES ${LIBRARIES} ${LIBRT_LIBRARIES})
include_directories(SYSTEM ${LIBRT_INCLUDE_DIR})
################################################################################
# Link libs
#set(LIBRARIES Threads::Threads opencv_core opencv_imgcodecs opencv_features2d opencv_imgproc opencv_highgui opencv_calib3d rt libgio-2.0)

include_directories(SYSTEM /usr/include)
include_directories(SYSTEM /usr/local/include)
link_directories(SYSTEM /usr/lib) #Access g2o
link_directories(SYSTEM /usr/local/lib) #Access g2o
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src)

add_library(${PROJECT_NAME}-core STATIC ${CMAKE_CURRENT_SOURCE_DIR}/src/detectcone.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/collector.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/cone.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/point.cpp ${CMAKE_BINARY_DIR}/opendlv-standard-message-set.cpp)

# Add custom libs h
set(LIBRARIES ${LIBRARIES} Threads::Threads ${OpenCV_LIBS} ${Eigen3_LIBS} ${TinyDNN_LIBS} ${TBB_LIBRARIES} rt)
################################################################################
# Link libs
set(LIBRARIES ${LIBRARIES} Threads::Threads ${OpenCV_LIBS} ${Eigen3_LIBS} ${TinyDNN_LIBS} ${TBB_LIBRARIES} )

MESSAGE(STATUS "heej")
MESSAGE(STATUS ${LIBRARIES})
#${TBB_LIBRARIES}

################################################################################
# Create executable.
Expand Down
138 changes: 109 additions & 29 deletions Dockerfile.amd64
Original file line number Diff line number Diff line change
Expand Up @@ -13,47 +13,46 @@
# 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-perception-vision-orbslam2.
FROM alpine:edge as builder
MAINTAINER Christian Berger "[email protected]"
# Part to build opendlv-perception-vision-orbslam2.
FROM alpine:3.8 as builder
# Deprecated, use label (see docker docs)
# MAINTAINER Christian Berger "[email protected]"
#Get OS stuff
RUN echo "@testing http://nl.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories
RUN apk update && \
RUN apk update && apk upgrade && \
apk --no-cache add \
cmake \
#bash \
g++ \
make \
upx \
git \
mercurial \
# mercurial \
libmount \
libtbb@testing \
libtbb-dev@testing \
opencv-dev@testing
opencv@testing \
opencv-dev@testing \
libgomp \
libtbb@testing \
libtbb-dev@testing \
openblas \
openblas-dev

WORKDIR /tmp
ADD ./config.h /opt/sources/config.h

RUN git clone https://github.com/justusc/FindTBB.git && \
cp FindTBB/FindTBB.cmake /usr/share/cmake/Modules/

RUN git clone https://github.com/tiny-dnn/tiny-dnn.git && \
mkdir -p tiny-dnn/build && \
cp /opt/sources/config.h tiny-dnn/tiny_dnn/config.h && \
cd tiny-dnn/build && \
cmake .. && \
make install

RUN git clone https://github.com/eigenteam/eigen-git-mirror.git && \
RUN git clone --depth 1 https://github.com/eigenteam/eigen-git-mirror.git && \
mkdir -p eigen-git-mirror/build && \
cd eigen-git-mirror/build && \
cmake .. && \
make install
RUN echo "@testing http://nl.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories
RUN apk update && \
apk --no-cache add \
opencv@testing

RUN git clone --depth 10 https://github.com/tiny-dnn/tiny-dnn.git && \
mkdir -p tiny-dnn/build && \
cd tiny-dnn/build && \
# Temp fix for the recent compilation error
git checkout 1aec6a1ece0ba7a5e018a070bd52e045d49d1411 && \
cmake -DUSE_TBB=ON -DUSE_OMP=ON .. && \
make install

ADD . /opt/sources/

Expand All @@ -62,17 +61,98 @@ WORKDIR /opt/sources
RUN mkdir -p build && \
cd build && \
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/tmp/cfsd18-perception-detectcone-dest .. && \
make -j3 && make test && make install && upx -9 /tmp/cfsd18-perception-detectcone-dest/bin/cfsd18-perception-detectcone
make -j3 && make test && make install
# mkdir -p /usr/lib/dependency && \
# cp $(ldd cfsd18-perception-detectcone | awk '/\/usr\/bin/ {print $3}') /usr/lib/dependency/
# && upx -9 /tmp/cfsd18-perception-detectcone-dest/bin/cfsd18-perception-detectcone

# Part to deploy opendlv-perception-vision-orbslam2
FROM alpine:edge
MAINTAINER Christian Berger "[email protected]"
# Deprecated, use label (see docker docs)
# MAINTAINER Christian Berger "[email protected]"
RUN apk update && \
apk --no-cache add \
glib

#Start microservice
WORKDIR /usr/bin
COPY --from=builder /usr/local/include/ /usr/include/
COPY --from=builder /usr/local/lib/ /usr/lib/
COPY --from=builder /usr/lib/ /usr/lib/
# This will make the image heavy... Do we need all of them?
# This could be slimmed down
# Nothing in the builder's /usr/local/lib
# COPY --from=builder /usr/local/lib/ /usr/lib/
# COPY --from=builder /usr/lib/ /usr/lib/

# COPY --from=builder /usr/lib/dependency/ /usr/lib/
# Tried to copy from /usr/lib/dependency/
# but " ldd cfsd18-perception-detectcone | awk '{print $3}' " output nothing (i.e. line 66 failed)
# instead, use the manual and tedious way
# image size: 393MB -> 79.1MB
COPY --from=builder /usr/lib/libopencv_calib3d.so.3.2 \
/usr/lib/libopencv_features2d.so.3.2 \
/usr/lib/libopencv_flann.so.3.2 \
/usr/lib/libopencv_highgui.so.3.2 \
/usr/lib/libopencv_imgcodecs.so.3.2 \
/usr/lib/libopencv_imgproc.so.3.2 \
/usr/lib/libopencv_core.so.3.2 \
/usr/lib/libstdc++.so.6 \
/usr/lib/libgcc_s.so.1 \
/usr/lib/libgtk-3.so.0 \
/usr/lib/libgdk-3.so.0 \
/usr/lib/libcairo.so.2 \
/usr/lib/libgdk_pixbuf-2.0.so.0 \
/usr/lib/libgobject-2.0.so.0 \
/usr/lib/libglib-2.0.so.0 \
/usr/lib/libjpeg.so.8 \
/usr/lib/libwebp.so.7 \
/usr/lib/libpng16.so.16 \
/usr/lib/libtiff.so.5 \
/usr/lib/libjasper.so.4 \
/usr/lib/libIlmImf-2_2.so.23 \
/usr/lib/libHalf.so.12 \
/usr/lib/libgomp.so.1 \
/usr/lib/libgmodule-2.0.so.0 \
/usr/lib/libpangocairo-1.0.so.0 \
/usr/lib/libX11.so.6 \
/usr/lib/libXi.so.6 \
/usr/lib/libXfixes.so.3 \
/usr/lib/libcairo-gobject.so.2 \
/usr/lib/libatk-1.0.so.0 \
/usr/lib/libatk-bridge-2.0.so.0 \
/usr/lib/libepoxy.so.0 \
/usr/lib/libpangoft2-1.0.so.0 \
/usr/lib/libpango-1.0.so.0 \
/usr/lib/libfontconfig.so.1 \
/usr/lib/libgio-2.0.so.0 \
/usr/lib/libintl.so.8 \
/usr/lib/libXinerama.so.1 \
/usr/lib/libXrandr.so.2 \
/usr/lib/libXcursor.so.1 \
/usr/lib/libXcomposite.so.1 \
/usr/lib/libXdamage.so.1 \
/usr/lib/libxkbcommon.so.0 \
/usr/lib/libwayland-cursor.so.0 \
/usr/lib/libwayland-egl.so.1 \
/usr/lib/libwayland-client.so.0 \
/usr/lib/libXext.so.6 \
/usr/lib/libpixman-1.so.0 \
/usr/lib/libfreetype.so.6 \
/usr/lib/libxcb-shm.so.0 \
/usr/lib/libxcb.so.1 \
/usr/lib/libxcb-render.so.0 \
/usr/lib/libXrender.so.1 \
/usr/lib/libffi.so.6 \
/usr/lib/libpcre.so.1 \
/usr/lib/libIex-2_2.so.12 \
/usr/lib/libIlmThread-2_2.so.12 \
/usr/lib/libatspi.so.0 \
/usr/lib/libdbus-1.so.3 \
/usr/lib/libharfbuzz.so.0 \
/usr/lib/libexpat.so.1 \
/usr/lib/libbz2.so.1 \
/usr/lib/libXau.so.6 \
/usr/lib/libXdmcp.so.6 \
/usr/lib/libgraphite2.so.3 \
/usr/lib/libbsd.so.0 \
/usr/lib/
COPY --from=builder /tmp/cfsd18-perception-detectcone-dest/bin/cfsd18-perception-detectcone .
RUN apk update && apk add glib
CMD ["/usr/bin/cfsd18-perception-detectcone"]
Loading