Skip to content

Commit 9f81775

Browse files
authored
Merge pull request #38 from ethz-asl/feature/build_without_bosch_api
Make Bosch api optional
2 parents 6143be4 + d1307d8 commit 9f81775

File tree

3 files changed

+60
-16
lines changed

3 files changed

+60
-16
lines changed

.github/workflows/ubuntu20_04.yml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ jobs:
1515
matrix:
1616
rosdistro: ['noetic']
1717
gcc: ['8', '9', '10']
18+
submodule: ['exclude', 'BMI08x-Sensor-API', 'BMP3-Sensor-API', 'all']
1819
container: ros:${{ matrix.rosdistro }}-ros-base-focal
19-
name: ROS ${{ matrix.rosdistro }} - GCC ${{ matrix.gcc }}
20+
name: GCC ${{ matrix.gcc }} - Submodule ${{ matrix.submodule }} - ROS ${{ matrix.rosdistro }}
2021
steps:
2122
- uses: actions/checkout@v4
2223
name: Checkout lpp
@@ -45,8 +46,20 @@ jobs:
4546
token: ${{ secrets.PAT }}
4647
path: catkin_ws/src/mav_sensors
4748

49+
- name: Exclude submodules
50+
if: matrix.submodule == 'exclude'
51+
run: rm -rf mav_sensors_drivers/lib/*
52+
shell: bash
53+
working-directory: catkin_ws/src/mav_sensors
54+
55+
- name: Exclude submodules except ${{ matrix.submodule }}
56+
if: matrix.submodule != 'exclude' && matrix.submodule != 'all'
57+
run: find . -mindepth 1 -type d ! -name ${{ matrix.submodule }} -exec rm -rf {} +
58+
working-directory: catkin_ws/src/mav_sensors/mav_sensors_drivers/lib
59+
shell: bash
60+
4861
- name: Build mav_sensors
49-
run: source /opt/ros/${{ matrix.rosdistro }}/setup.bash && catkin build mav_sensors_demo && source ${GITHUB_WORKSPACE}/catkin_ws/devel/setup.bash
62+
run: source /opt/ros/${{ matrix.rosdistro }}/setup.bash && catkin build -v mav_sensors_demo --no-status && source ${GITHUB_WORKSPACE}/catkin_ws/devel/setup.bash
5063
shell: bash
5164
working-directory: catkin_ws
5265

mav_sensors_demo/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,12 @@ include_directories(
2929
add_executable(${PROJECT_NAME}_xwr18xx_mmw_demo src/xwr18xx_mmw_demo_node.cpp)
3030
target_link_libraries(${PROJECT_NAME}_xwr18xx_mmw_demo ${catkin_LIBRARIES})
3131

32+
if (MAV_SENSORS_BMI08X_SUPPORT)
3233
add_executable(${PROJECT_NAME}_bmi088_demo src/bmi088_demo.cpp)
3334
target_link_libraries(${PROJECT_NAME}_bmi088_demo ${catkin_LIBRARIES})
35+
endif ()
3436

37+
if (MAV_SENSORS_BMP3_SUPPORT)
3538
add_executable(${PROJECT_NAME}_bmp390_demo src/bmp390_demo.cpp)
36-
target_link_libraries(${PROJECT_NAME}_bmp390_demo ${catkin_LIBRARIES})
39+
target_link_libraries(${PROJECT_NAME}_bmp390_demo ${catkin_LIBRARIES})
40+
endif ()

mav_sensors_drivers/CMakeLists.txt

Lines changed: 40 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,10 @@ project(mav_sensors_drivers)
33

44
add_compile_options(-std=c++17)
55

6-
find_package(catkin REQUIRED roscpp lpp mav_sensors_core)
7-
8-
catkin_package(
9-
INCLUDE_DIRS include lib/BMP3-Sensor-API lib/BMI08x-Sensor-API
10-
LIBRARIES ${PROJECT_NAME} ${PROJECT_NAME}_BMP3 ${PROJECT_NAME}_BMI08x
11-
CATKIN_DEPENDS roscpp lpp mav_sensors_core
6+
find_package(catkin REQUIRED COMPONENTS
7+
roscpp
8+
lpp
9+
mav_sensors_core
1210
)
1311

1412
add_compile_definitions(MODE_LPP)
@@ -17,28 +15,57 @@ add_compile_definitions(MODE_LPP)
1715
## Build ##
1816
###########
1917

18+
if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/lib/BMP3-Sensor-API/)
19+
set(MAV_SENSORS_BMP3_SUPPORT ON)
20+
set(MAV_SENSORS_OPTIONAL_SRC_FILES ${MAV_SENSORS_OPTIONAL_SRC_FILES} src/barometer/bmp390.cpp)
21+
set(MAV_SENSORS_OPTIONAL_INCLUDE_DIRS ${MAV_SENSORS_OPTIONAL_INCLUDE_DIRS} lib/BMP3-Sensor-API)
22+
set(MAV_SENSORS_OPTIONAL_LIBRARIES ${MAV_SENSORS_OPTIONAL_LIBRARIES} ${PROJECT_NAME}_BMP3)
23+
message(STATUS "Found BMP3-Sensor-API")
24+
else()
25+
message(WARNING "BMP3-Sensor-API not found. BMP3 sensor will not be supported.")
26+
endif()
27+
28+
if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/lib/BMI08x-Sensor-API/)
29+
set(MAV_SENSORS_BMI08X_SUPPORT ON)
30+
set(MAV_SENSORS_OPTIONAL_SRC_FILES ${MAV_SENSORS_OPTIONAL_SRC_FILES} src/imu/bmi088.cpp)
31+
set(MAV_SENSORS_OPTIONAL_INCLUDE_DIRS ${MAV_SENSORS_OPTIONAL_INCLUDE_DIRS} lib/BMI08x-Sensor-API)
32+
set(MAV_SENSORS_OPTIONAL_LIBRARIES ${MAV_SENSORS_OPTIONAL_LIBRARIES} ${PROJECT_NAME}_BMI08x)
33+
message(STATUS "Found BMI08x-Sensor-API")
34+
else()
35+
message(WARNING "BMI08x-Sensor-API not found. BMI08x sensor will not be supported.")
36+
endif()
37+
38+
catkin_package(
39+
INCLUDE_DIRS include ${MAV_SENSORS_OPTIONAL_INCLUDE_DIRS}
40+
LIBRARIES ${PROJECT_NAME} ${MAV_SENSORS_OPTIONAL_LIBRARIES}
41+
CATKIN_DEPENDS roscpp lpp mav_sensors_core
42+
)
43+
2044
include_directories(
21-
include
22-
lib/BMP3-Sensor-API
23-
lib/BMI08x-Sensor-API
45+
include
46+
${MAV_SENSORS_OPTIONAL_INCLUDE_DIRS}
2447
${catkin_INCLUDE_DIRS}
2548
)
2649

2750
add_library(${PROJECT_NAME}
2851
src/imu/adis16448.cpp
29-
src/barometer/bmp390.cpp
30-
src/imu/bmi088.cpp
31-
src/radar/xwr18xx_mmw_demo.cpp)
52+
src/radar/xwr18xx_mmw_demo.cpp
53+
${MAV_SENSORS_OPTIONAL_SRC_FILES})
3254

55+
if (MAV_SENSORS_BMP3_SUPPORT)
3356
add_library(${PROJECT_NAME}_BMP3
3457
lib/BMP3-Sensor-API/bmp3.c)
58+
set(MAV_SENSOR_LIBRARIES ${MAV_SENSOR_LIBRARIES} ${PROJECT_NAME}_BMP3)
59+
endif()
3560

61+
if (MAV_SENSORS_BMI08X_SUPPORT)
3662
add_library(${PROJECT_NAME}_BMI08x
3763
lib/BMI08x-Sensor-API/bmi08a.c
3864
lib/BMI08x-Sensor-API/bmi08g.c
3965
lib/BMI08x-Sensor-API/bmi08xa.c)
66+
endif()
4067

41-
target_link_libraries(${PROJECT_NAME} PUBLIC ${PROJECT_NAME}_BMP3 ${catkin_LIBRARIES})
68+
target_link_libraries(${PROJECT_NAME} PUBLIC ${MAV_SENSOR_LIBRARIES} ${catkin_LIBRARIES})
4269

4370
install(TARGETS ${PROJECT_NAME}
4471
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}

0 commit comments

Comments
 (0)