Skip to content

Commit

Permalink
Merge pull request #38 from tritonuas/chore/arena-sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
atar13 authored Oct 22, 2023
2 parents 4e2dee4 + f607de5 commit 0895aad
Show file tree
Hide file tree
Showing 6 changed files with 122 additions and 13 deletions.
25 changes: 15 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ FATAL: In-source builds are not allowed.
endif()


cmake_minimum_required(VERSION 3.10)
cmake_minimum_required(VERSION 3.13)


set(CMAKE_CXX_COMPILER g++)
Expand All @@ -31,22 +31,25 @@ add_executable(${PROJECT_NAME} ${SOURCES})

# =============================
# Libraries
# NOTE: add each library's include directory to clang-tidy in the Linting section
add_subdirectory(deps/json)
target_link_libraries(${PROJECT_NAME}
PRIVATE
nlohmann_json::nlohmann_json
)
set(DEPS_DIRECTORY ${PROJECT_SOURCE_DIR}/deps)

add_subdirectory(${DEPS_DIRECTORY}/arena-sdk)
add_subdirectory(${DEPS_DIRECTORY}/json)
# =============================

# =============================
# Unit tests
add_subdirectory(tests)
add_subdirectory(deps/google-test)
add_subdirectory(${DEPS_DIRECTORY}/google-test)
# =============================

# =============================
# Linting
get_target_property(PROJECT_LIBS_INCLUDE_DIRS ${PROJECT_NAME} INCLUDE_DIRECTORIES)
foreach(dir ${PROJECT_LIBS_INCLUDE_DIRS})
string(APPEND LIB_INCLUDE_CLANG_TIDY_STRING "-I${dir};")
endforeach()

# Adding lint target if clang-tidy executable is found
find_program(CLANG_TIDY "clang-tidy")
if(CLANG_TIDY)
Expand All @@ -58,8 +61,10 @@ if(CLANG_TIDY)
--
-std=c++${CMAKE_CXX_STANDARD}
-I${INCLUDE_DIRECTORY}
# NOTE: need to add include directory for every library
-I./_deps/json-src/include/
# NOTE:might need to add include directory if library's
# include directory is not in LIB_INCLUDE_CLANG_TIDY_STRING
-I${CMAKE_BINARY_DIR}/_deps/json-src/single_include
${LIB_INCLUDE_CLANG_TIDY_STRING}
)
else()
message(FATAL_ERROR "clang-tidy executable not found. Check the README for steps to install it on your system")
Expand Down
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ RUN apt-get update \
gdb \
git \
cmake \
clang-tidy
clang-tidy \
wget
31 changes: 31 additions & 0 deletions deps/arena-sdk/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
if(UNIX AND NOT APPLE)
set(ARENA_SDK_DIR "${CMAKE_BINARY_DIR}/_deps/arena-sdk")
set(INSTALL_SCRIPT "${PROJECT_SOURCE_DIR}/deps/arena-sdk/install-arena.sh")

# run install script with output directory as argument
execute_process(
COMMAND sh ${INSTALL_SCRIPT} ${ARENA_SDK_DIR}
RESULT_VARIABLE ret
)
if(ret EQUAL "0")
# Add a preprocessor macro that will enable us to compile
# functionality that depends on the Arena SDK.
target_compile_definitions(${PROJECT_NAME} PRIVATE
ARENA_SDK_INSTALLED
)
else()
message(FATAL_ERROR "Unable to install Arena-SDK. ${INSTALL_SCRIPT} script exited with code ${ret}.")
endif()

target_include_directories(${PROJECT_NAME} PRIVATE
"${ARENA_SDK_DIR}/extracted/include/Arena"
"${ARENA_SDK_DIR}/extracted/GenICam/library/CPP/include"
)
file(GLOB_RECURSE ARENA_LIBS
"${ARENA_SDK_DIR}/extracted/lib64/*.so"
"${ARENA_SDK_DIR}/extracted/ffmpeg/*.so"
)
target_link_libraries(${PROJECT_NAME} PRIVATE
${ARENA_LIBS}
)
endif()
64 changes: 64 additions & 0 deletions deps/arena-sdk/install-arena.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/bin/sh

set -e

PKGS_DIR=$1

if [ ! "$PKGS_DIR" ]; then
echo "ERROR: Could not install Arena SDK. Did not specify installation directory. Must provide installation directory as an argument"
exit 1
fi

mkdir -p "$PKGS_DIR"

ARCH=`uname -m`
OS=`uname`

echo "Installing Arena SDK for $ARCH on $OS to $PKGS_DIR"
if [ $OS != "Linux" ]; then
echo "ERROR: Arena SDK can only be installed on Linux"
exit 1
else
# pull Arena SDK from TUAS Google Drive
# https://drive.google.com/drive/folders/1Ek1luFtO-FpDUJHP9_NQ9RH5dYhyhWXi?usp=share_link
if [ $ARCH = "aarch64" ]; then
FILE_NAME="ArenaSDK_v0.1.49_Linux_ARM64.tar.gz"
FILE_ID="1VtBji-cWfetM5nXZwt55JuHPWPGahQOH"
ARENA_SDK_DIR="ArenaSDK_Linux_ARM64"
ARENA_CONF="Arena_SDK_ARM64.conf"
elif [ $ARCH = "x86_64" ]; then
FILE_NAME="ArenaSDK_v0.1.68_Linux_x64.tar.gz"
FILE_ID="1pQtheOK-f2N4C2CDi43HTqttGuxHKptg"
ARENA_SDK_DIR="ArenaSDK_Linux_x64"
ARENA_CONF="Arena_SDK_Linux_x64.conf"
else
echo "ERROR: Unable to install Arena-SDK. Unkown architecture $ARCH. Architecture must be aarch64 or x86_64."
exit 1
fi;

if [ ! -d "$PKGS_DIR/$ARENA_SDK_DIR" ]; then \
# Check that wget is installed
if ! command -v wget > /dev/null; then \
echo "ERROR: Unable to install Arena-SDK. wget is not installed. Install wget for your system and retry."
exit 1
fi;

# Check that tar is installed
if ! command -v tar > /dev/null; then \
echo "ERROR: Unable to install Arena-SDK. tar is not installed. Install tar for your system and retry."
exit 1
fi;

# This command is kinda crazy to bypass Google drive's virus scanning warning for large files https://medium.com/@acpanjan/download-google-drive-files-using-wget-3c2c025a8b99
wget --load-cookies /tmp/cookies.txt "https://docs.google.com/uc?export=download&confirm=$(wget --quiet --save-cookies /tmp/cookies.txt --keep-session-cookies --no-check-certificate "https://docs.google.com/uc?export=download&id=$FILE_ID" -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1\n/p')&id=$FILE_ID" -O "$PKGS_DIR/$FILE_NAME" && rm -rf /tmp/cookies.txt
tar xf "$PKGS_DIR/$FILE_NAME" --directory="$PKGS_DIR"
else \
echo "WARNING: Arena SDK is already installed at $PKGS_DIR/$ARENA_SDK_DIR. Will not download again."; \
fi;

# Symlink arch specific arena install to architecture agnostic directory.
# Build system can point to this folder without knowing which architecture to use.
SYMLINKED_DIR="$PKGS_DIR/extracted"
echo "Symlinking $ARENA_SDK_DIR to $SYMLINKED_DIR"
ln -sf "$PKGS_DIR/$ARENA_SDK_DIR" "$SYMLINKED_DIR"
fi;
6 changes: 5 additions & 1 deletion deps/json/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,8 @@ FetchContent_Declare(json
GIT_SHALLOW TRUE
GIT_TAG v3.11.2)

FetchContent_MakeAvailable(json)
FetchContent_MakeAvailable(json)

target_link_libraries(${PROJECT_NAME} PRIVATE
nlohmann_json::nlohmann_json
)
6 changes: 5 additions & 1 deletion include/camera/lucid.hpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
#ifndef CAMERA_LUCID_HPP_
#define CAMERA_LUCID_HPP_

#ifdef ARENA_SDK_INSTALLED

#include "interface.hpp"

class LucidCamera : public CameraInterface {
// override all the camera connection interface functions
};

#endif // CAMERA_LUCID_HPP_
#endif // ARENA_SDK_INSTALLED

#endif // CAMERA_LUCID_HPP_

0 comments on commit 0895aad

Please sign in to comment.