Skip to content
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@ on:
jobs:
industrial-ci:
name: Run Industrial CI

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ros_distro: ["noetic", "kilted", "rolling"]
env:
- {UPSTREAM_WORKSPACE: liboculus.repos, ROS_DISTRO: noetic}
- {UPSTREAM_WORKSPACE: liboculus.repos, ROS_DISTRO: kilted}
- {UPSTREAM_WORKSPACE: liboculus.repos, ROS_DISTRO: rolling}

steps:
- name: Checkout repository
Expand All @@ -24,6 +27,4 @@ jobs:

- name: Run ROS Industrial CI
uses: ros-industrial/industrial_ci@master
environment:
CI_ROS_DISTRO: ${{ matrix.ros_distro }}
UPSTREAM_WORKSPACE: liboculus.repos
env: ${{matrix.env}}
28 changes: 28 additions & 0 deletions .github/workflows/ci_cmake.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: ROS Industrial CI

on:
push:
branches:
- main
pull_request:
workflow_dispatch:

jobs:
cmake:
name: Build with CMake
runs-on: ubuntu-24.04

steps:
- name: Install dependencesi with awalsh128/cache-apt-pkgs-action
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: libboost-all-dev
version: 1.0

- name: Checkout repository
uses: actions/checkout@v5
with:
submodules: recursive

- name: Build Project
uses: threeal/cmake-action@v2.1.0
204 changes: 104 additions & 100 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.8)
project(liboculus)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_compile_options(-std=c++17)

# == Code common to all builds =======================================
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)

# ROS build, determine which version...
find_package(ros_environment REQUIRED)
set(ROS_VERSION $ENV{ROS_VERSION})

set(oculus_SRCS
lib/DataRx.cpp
lib/SonarConfiguration.cpp
Expand All @@ -19,106 +19,110 @@ set(oculus_SRCS
lib/IoServiceThread.cpp
)

if(${ROS_VERSION} EQUAL 2)
# == ament/ROS2 section =================================

find_package(ament_cmake REQUIRED)
find_package(Boost REQUIRED COMPONENTS system)
find_package(g3log_ros REQUIRED)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_compile_options(-std=c++17)

add_library(oculus SHARED ${oculus_SRCS})

target_include_directories(
oculus
PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/thirdparty>"
"$<INSTALL_INTERFACE:include/${PROJECT_NAME}>"
"$<INSTALL_INTERFACE:include/thirdparty>"
)

target_link_libraries(oculus PUBLIC Boost::system g3log_ros::g3log)

install(
TARGETS oculus
EXPORT export_${PROJECT_NAME}
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
)

install(
DIRECTORY include/${PROJECT_NAME} thirdparty
DESTINATION include
FILES_MATCHING
PATTERN "*.hpp"
PATTERN "*.h"
PATTERN ".git" EXCLUDE
)

ament_export_targets(export_${PROJECT_NAME} HAS_LIBRARY_TARGET)
ament_export_libraries(oculus)

ament_package()
elseif(${ROS_VERSION} EQUAL 1)
# Catkin/ROS1 section =====
find_package(catkin REQUIRED COMPONENTS g3log_ros)
find_package(Boost REQUIRED COMPONENTS system)

catkin_package(
CATKIN_DEPENDS g3log_ros
INCLUDE_DIRS include thirdparty
LIBRARIES liboculus
)

add_compile_options(-std=c++14)

add_library(liboculus ${oculus_SRCS})

include_directories(liboculus include thirdparty ${catkin_INCLUDE_DIRS})

target_link_libraries(liboculus ${catkin_LIBRARIES})

install(
TARGETS liboculus
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}
)

## Install headers
install(
DIRECTORY include/${PROJECT_NAME}/ thirdparty/
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
FILES_MATCHING
PATTERN "*.hpp"
PATTERN "*.h"
PATTERN ".git" EXCLUDE
)

if(CATKIN_ENABLE_TESTING)
add_definitions(
-DTEST_DATA_PATH="${CMAKE_CURRENT_SOURCE_DIR}/test/data"
# ROS build, determine which version...
# QUIET will squelch the warning if the package isn't found
find_package(ros_environment QUIET)

if(${ros_environment_FOUND})
set(ROS_VERSION $ENV{ROS_VERSION})

if(${ROS_VERSION} EQUAL 2)
# == ament/ROS2 section =================================

find_package(ament_cmake REQUIRED)
find_package(Boost REQUIRED COMPONENTS system)
find_package(g3log_ros REQUIRED)

add_library(oculus SHARED ${oculus_SRCS})
target_link_libraries(oculus PUBLIC Boost::system g3log_ros::g3log)

target_include_directories(
oculus
PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/thirdparty>"
"$<INSTALL_INTERFACE:include/${PROJECT_NAME}>"
"$<INSTALL_INTERFACE:include/thirdparty>"
)

install(
TARGETS oculus
EXPORT export_${PROJECT_NAME}
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
)
include_directories(test/data/)

file(GLOB oculus_test_SRCS test/unit/*cpp)
install(
DIRECTORY include/${PROJECT_NAME} thirdparty
DESTINATION include
FILES_MATCHING
PATTERN "*.hpp"
PATTERN "*.h"
PATTERN ".git" EXCLUDE
)

ament_export_targets(export_${PROJECT_NAME} HAS_LIBRARY_TARGET)
ament_export_libraries(oculus)

ament_package()
elseif(${ROS_VERSION} EQUAL 1)
# Catkin/ROS1 section =====
find_package(catkin REQUIRED COMPONENTS g3log_ros)
find_package(Boost REQUIRED COMPONENTS system)

catkin_package(
CATKIN_DEPENDS g3log_ros
INCLUDE_DIRS include thirdparty
LIBRARIES liboculus
)

add_library(liboculus ${oculus_SRCS})

catkin_add_gtest(oculus_test ${oculus_test_SRCS})
include_directories(liboculus include thirdparty ${catkin_INCLUDE_DIRS})

target_link_libraries(liboculus ${catkin_LIBRARIES})

install(
TARGETS liboculus
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}
)

## Install headers
install(
DIRECTORY include/${PROJECT_NAME}/ thirdparty/
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
FILES_MATCHING
PATTERN "*.hpp"
PATTERN "*.h"
PATTERN ".git" EXCLUDE
)

target_link_libraries(
oculus_test
${catkin_LIBRARIES}
liboculus
Boost::system
if(CATKIN_ENABLE_TESTING)
add_definitions(
-DTEST_DATA_PATH="${CMAKE_CURRENT_SOURCE_DIR}/test/data"
)
include_directories(test/data/)

file(GLOB oculus_test_SRCS test/unit/*cpp)

catkin_add_gtest(oculus_test ${oculus_test_SRCS})

target_link_libraries(
oculus_test
${catkin_LIBRARIES}
liboculus
Boost::system
)
endif()
else()
message(
"Unsure what sort of build to do. Not in a ROS1 or ROS2 environment"
)
endif()
else()
message(
"Unsure what sort of build to do. Not in a ROS1 or ROS2 environment"
)
message(NOTICE "!! Performing non-ROS build !!")
include(cmake/BuildNonROS.cmake)
endif()
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ This library contains code for:
- Raw streams of binary packets.
- **Note:** This repo includes scaffold code for reading `.oculus` files saved from the Blueprint GUI, but that format is proprietary and undocumented. **We cannot parse `.oculus` files!!**

This package is designed to build in both ROS1 (catkin) and ROS2 (colcon) environments, however it contains no ROS-specific code and could be integrated into other non-ROS environments with some work.
This package is designed to build in both ROS1 (catkin) and ROS2 (colcon) environments, however it contains no ROS-specific code and could be integrated into other non-ROS environments with some work.

It also contains the options to build a "bare" library with `cmake`.

The library contains no special provisions for *saving* sonar data,
but it's straightforward to write packets as a raw binary stream
Expand Down Expand Up @@ -48,6 +50,18 @@ binary `oc_client` requires [CLI11](https://github.com/CLIUtils/CLI11).
Internally, the ethernet interface uses
[Boost::asio](https://www.boost.org/doc/libs/1_66_0/doc/html/boost_asio.html).

## Build with cmake

This package can be built with the standard cmake process:

```
mkdir build && cd build
cmake ..
make
```

Note the `CMakelists.txt` attempts to auto-detect ROS. Cmake build should be done in a session where ROS has not been loaded.

---
## oc_client binary

Expand Down
Loading