From f9d71a3800979584cb6dc0e60d2852596260a6d8 Mon Sep 17 00:00:00 2001 From: Ian Reid Date: Tue, 30 Dec 2025 13:21:51 -0700 Subject: [PATCH 1/3] cleanup: Cleaned up CMAKE for estimation --- roscopter/CMakeLists.txt | 62 ++++++++++++++++++++++------------------ 1 file changed, 34 insertions(+), 28 deletions(-) diff --git a/roscopter/CMakeLists.txt b/roscopter/CMakeLists.txt index 7f39496..d93b172 100644 --- a/roscopter/CMakeLists.txt +++ b/roscopter/CMakeLists.txt @@ -101,17 +101,15 @@ add_executable(estimator src/ekf/estimator_ekf.cpp src/ekf/estimator_continuous_discrete.cpp src/utils/geomag.c) -target_link_libraries(estimator - ${YAML_CPP_LIBRARIES} -) ament_target_dependencies(estimator roscopter_msgs rosflight_msgs sensor_msgs rclcpp Eigen3 ament_index_cpp) -target_link_libraries(estimator param_manager) +target_link_libraries(estimator ${ament_LIBRARIES} param_manager ${YAML_CPP_LIBRARIES}) target_include_directories(estimator PUBLIC include) install(TARGETS estimator DESTINATION lib/${PROJECT_NAME}) -add_library(estimator_lib +# ESTIMATOR LIB +add_library(estimation_lib SHARED src/ekf/estimator_node.cpp src/ekf/estimator_ros.cpp src/ekf/estimator_ekf.cpp @@ -120,9 +118,17 @@ add_library(estimator_lib include/ekf/estimator_ros.hpp include/ekf/estimator_ekf.hpp include/ekf/estimator_continuous_discrete.hpp) -target_link_libraries(estimator_lib param_manager) -target_link_libraries(estimator estimator_lib) -ament_target_dependencies(estimator_lib rclcpp geometry_msgs rosflight_msgs sensor_msgs Eigen3 roscopter_msgs ament_index_cpp) +target_link_libraries(estimation_lib) +ament_target_dependencies(estimation_lib rclcpp geometry_msgs rosflight_msgs sensor_msgs Eigen3 roscopter_msgs ament_index_cpp) +ament_export_targets(estimation_lib HAS_LIBRARY_TARGET) +install(DIRECTORY include/ekf DESTINATION include) +install(TARGETS estimation_lib + EXPORT estimation_lib + ARCHIVE DESTINATION lib + LIBRARY DESTINATION lib + RUNTIME DESTINATION bin + INCLUDES DESTINATION include +) # External attitude transcriber add_executable(ext_att_transcriber @@ -175,25 +181,25 @@ install( DESTINATION lib/${PROJECT_NAME}) -if(BUILD_TESTING) - - find_package(ament_cmake_gtest REQUIRED) - ament_add_gtest(estimator_test test/estimator_test.cpp) - ament_target_dependencies(estimator_test rclcpp geometry_msgs rosflight_msgs sensor_msgs Eigen3 roscopter_msgs) - target_include_directories(estimator_test PUBLIC - include - ) - target_link_libraries(estimator_test estimator_lib) - - find_package(ament_lint_auto REQUIRED) - # the following line skips the linter which checks for copyrights - # comment the line when a copyright and license is added to all source files - set(ament_cmake_copyright_FOUND TRUE) - # the following line skips cpplint (only works in a git repo) - # comment the line when this package is in a git repo and when - # a copyright and license is added to all source files - set(ament_cmake_cpplint_FOUND TRUE) - ament_lint_auto_find_test_dependencies() -endif() +# if(BUILD_TESTING) +# +# find_package(ament_cmake_gtest REQUIRED) +# ament_add_gtest(estimator_test test/estimator_test.cpp) +# ament_target_dependencies(estimator_test rclcpp geometry_msgs rosflight_msgs sensor_msgs Eigen3 roscopter_msgs) +# target_include_directories(estimator_test PUBLIC +# include +# ) +# target_link_libraries(estimator_test estimation_lib) +# +# find_package(ament_lint_auto REQUIRED) +# # the following line skips the linter which checks for copyrights +# # comment the line when a copyright and license is added to all source files +# set(ament_cmake_copyright_FOUND TRUE) +# # the following line skips cpplint (only works in a git repo) +# # comment the line when this package is in a git repo and when +# # a copyright and license is added to all source files +# set(ament_cmake_cpplint_FOUND TRUE) +# ament_lint_auto_find_test_dependencies() +# endif() ament_package() From 729539e953948eaa9326efbaea3cdaea2534fd25 Mon Sep 17 00:00:00 2001 From: Ian Reid Date: Tue, 30 Dec 2025 13:25:20 -0700 Subject: [PATCH 2/3] Fixed param_manager linking bug. --- roscopter/CMakeLists.txt | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/roscopter/CMakeLists.txt b/roscopter/CMakeLists.txt index d93b172..4d02c6d 100644 --- a/roscopter/CMakeLists.txt +++ b/roscopter/CMakeLists.txt @@ -181,25 +181,25 @@ install( DESTINATION lib/${PROJECT_NAME}) -# if(BUILD_TESTING) -# -# find_package(ament_cmake_gtest REQUIRED) -# ament_add_gtest(estimator_test test/estimator_test.cpp) -# ament_target_dependencies(estimator_test rclcpp geometry_msgs rosflight_msgs sensor_msgs Eigen3 roscopter_msgs) -# target_include_directories(estimator_test PUBLIC -# include -# ) -# target_link_libraries(estimator_test estimation_lib) -# -# find_package(ament_lint_auto REQUIRED) -# # the following line skips the linter which checks for copyrights -# # comment the line when a copyright and license is added to all source files -# set(ament_cmake_copyright_FOUND TRUE) -# # the following line skips cpplint (only works in a git repo) -# # comment the line when this package is in a git repo and when -# # a copyright and license is added to all source files -# set(ament_cmake_cpplint_FOUND TRUE) -# ament_lint_auto_find_test_dependencies() -# endif() +if(BUILD_TESTING) + + find_package(ament_cmake_gtest REQUIRED) + ament_add_gtest(estimator_test test/estimator_test.cpp) + ament_target_dependencies(estimator_test rclcpp geometry_msgs rosflight_msgs sensor_msgs Eigen3 roscopter_msgs) + target_include_directories(estimator_test PUBLIC + include + ) + target_link_libraries(estimator_test estimation_lib param_manager) + + find_package(ament_lint_auto REQUIRED) + # the following line skips the linter which checks for copyrights + # comment the line when a copyright and license is added to all source files + set(ament_cmake_copyright_FOUND TRUE) + # the following line skips cpplint (only works in a git repo) + # comment the line when this package is in a git repo and when + # a copyright and license is added to all source files + set(ament_cmake_cpplint_FOUND TRUE) + ament_lint_auto_find_test_dependencies() +endif() ament_package() From 5685d63c70b3ecdc40135ce9b7f42b07cdf8e7c5 Mon Sep 17 00:00:00 2001 From: Jacob Moore Date: Mon, 12 Jan 2026 15:30:49 -0700 Subject: [PATCH 3/3] add estimation lib as linked library for estimator exec --- roscopter/CMakeLists.txt | 49 +++++++++++++++++----------------------- 1 file changed, 21 insertions(+), 28 deletions(-) diff --git a/roscopter/CMakeLists.txt b/roscopter/CMakeLists.txt index 4d02c6d..3b72066 100644 --- a/roscopter/CMakeLists.txt +++ b/roscopter/CMakeLists.txt @@ -52,7 +52,7 @@ else() endif() ament_export_include_directories(include ${EIGEN3_INCLUDE_DIRS}) -ament_export_dependencies(rclcpp rclpy roscopter_msgs rosflight_msgs std_msgs nav_msgs sensor_msgs EIGEN3 geometry_msgs) +ament_export_dependencies(rclcpp rclpy roscopter_msgs rosflight_msgs std_msgs nav_msgs sensor_msgs Eigen3 geometry_msgs) add_definitions(-DROSCOPTER_DIR="${CMAKE_CURRENT_LIST_DIR}") @@ -90,45 +90,38 @@ install(TARGETS param_manager INCLUDES DESTINATION include ) - -### EXECUTABLES ### - -# Estimator -set_source_files_properties(geomag.c PROPERTIES LANGUAGE C) -add_executable(estimator - src/ekf/estimator_node.cpp - src/ekf/estimator_ros.cpp - src/ekf/estimator_ekf.cpp - src/ekf/estimator_continuous_discrete.cpp - src/utils/geomag.c) -ament_target_dependencies(estimator roscopter_msgs rosflight_msgs sensor_msgs rclcpp Eigen3 ament_index_cpp) -target_link_libraries(estimator ${ament_LIBRARIES} param_manager ${YAML_CPP_LIBRARIES}) -target_include_directories(estimator PUBLIC include) -install(TARGETS - estimator - DESTINATION lib/${PROJECT_NAME}) - # ESTIMATOR LIB +set_source_files_properties(geomag.c PROPERTIES LANGUAGE C) add_library(estimation_lib SHARED - src/ekf/estimator_node.cpp src/ekf/estimator_ros.cpp src/ekf/estimator_ekf.cpp src/ekf/estimator_continuous_discrete.cpp - src/utils/geomag.c - include/ekf/estimator_ros.hpp - include/ekf/estimator_ekf.hpp - include/ekf/estimator_continuous_discrete.hpp) -target_link_libraries(estimation_lib) + src/utils/geomag.c) +target_include_directories(estimation_lib + PUBLIC + "$" + "$") ament_target_dependencies(estimation_lib rclcpp geometry_msgs rosflight_msgs sensor_msgs Eigen3 roscopter_msgs ament_index_cpp) -ament_export_targets(estimation_lib HAS_LIBRARY_TARGET) install(DIRECTORY include/ekf DESTINATION include) install(TARGETS estimation_lib - EXPORT estimation_lib + EXPORT export_estimation_lib ARCHIVE DESTINATION lib LIBRARY DESTINATION lib RUNTIME DESTINATION bin - INCLUDES DESTINATION include ) +ament_export_targets(export_estimation_lib HAS_LIBRARY_TARGET) + +### EXECUTABLES ### + +# Estimator +add_executable(estimator + src/ekf/estimator_node.cpp) +ament_target_dependencies(estimator PUBLIC roscopter_msgs rosflight_msgs sensor_msgs rclcpp Eigen3 ament_index_cpp) +target_link_libraries(estimator PUBLIC estimation_lib ${ament_LIBRARIES} param_manager ${YAML_CPP_LIBRARIES}) +target_include_directories(estimator PUBLIC include) +install(TARGETS + estimator + DESTINATION lib/${PROJECT_NAME}) # External attitude transcriber add_executable(ext_att_transcriber