update for ROS
This commit is contained in:
parent
e0db8d0e20
commit
ff90ea2f29
|
|
@ -1,105 +1,181 @@
|
||||||
cmake_minimum_required(VERSION 3.10)
|
cmake_minimum_required(VERSION 3.0.2)
|
||||||
|
project(robot_tf3_geometry_msgs VERSION 1.0.0 LANGUAGES CXX)
|
||||||
|
|
||||||
# ========================================================
|
|
||||||
# Dual-mode CMakeLists.txt: Supports both Catkin and Standalone CMake
|
|
||||||
# ========================================================
|
|
||||||
|
|
||||||
# Detect if building with Catkin
|
|
||||||
if(DEFINED CATKIN_DEVEL_PREFIX OR DEFINED CATKIN_TOPLEVEL)
|
if(DEFINED CATKIN_DEVEL_PREFIX OR DEFINED CATKIN_TOPLEVEL)
|
||||||
set(BUILDING_WITH_CATKIN TRUE)
|
set(BUILDING_WITH_CATKIN TRUE)
|
||||||
message(STATUS "Building robot_tf3_geometry_msgs with Catkin")
|
message(STATUS "Building robot_tf3_geometry_msgs with Catkin")
|
||||||
find_package(catkin REQUIRED)
|
|
||||||
else()
|
else()
|
||||||
set(BUILDING_WITH_CATKIN FALSE)
|
set(BUILDING_WITH_CATKIN FALSE)
|
||||||
message(STATUS "Building robot_tf3_geometry_msgs with Standalone CMake")
|
message(STATUS "Building robot_tf3_geometry_msgs with Standalone CMake")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
project(robot_tf3_geometry_msgs)
|
# C++ Standard - must be set before find_package
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||||
|
|
||||||
|
# Find dependencies
|
||||||
|
find_package(Boost REQUIRED COMPONENTS thread)
|
||||||
|
find_package(Eigen3 REQUIRED)
|
||||||
|
find_package(GTest REQUIRED)
|
||||||
|
|
||||||
|
if (NOT BUILDING_WITH_CATKIN)
|
||||||
|
|
||||||
|
# Enable Position Independent Code
|
||||||
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||||
|
|
||||||
|
# Cấu hình RPATH để tránh cycle trong runtime search path
|
||||||
|
set(CMAKE_BUILD_RPATH_USE_ORIGIN TRUE)
|
||||||
|
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
||||||
|
set(CMAKE_BUILD_RPATH "${CMAKE_BINARY_DIR}")
|
||||||
|
|
||||||
|
set(PACKAGES_DIR
|
||||||
|
robot_geometry_msgs
|
||||||
|
data_convert
|
||||||
|
tf3
|
||||||
|
)
|
||||||
|
|
||||||
|
else()
|
||||||
|
|
||||||
# ========================================================
|
# ========================================================
|
||||||
# Catkin specific configuration
|
# Catkin specific configuration
|
||||||
# ========================================================
|
# ========================================================
|
||||||
|
find_package(catkin REQUIRED COMPONENTS
|
||||||
|
robot_geometry_msgs
|
||||||
|
data_convert
|
||||||
|
tf3
|
||||||
|
)
|
||||||
|
|
||||||
if(BUILDING_WITH_CATKIN)
|
|
||||||
catkin_package(
|
catkin_package(
|
||||||
INCLUDE_DIRS include
|
INCLUDE_DIRS include
|
||||||
# LIBRARIES không cần vì đây là header-only library
|
# LIBRARIES không cần vì đây là header-only library
|
||||||
# CATKIN_DEPENDS không cần vì dependencies không phải Catkin packages
|
CATKIN_DEPENDS robot_geometry_msgs data_convert tf3
|
||||||
DEPENDS Eigen3 Boost
|
DEPENDS Eigen3 Boost
|
||||||
)
|
)
|
||||||
endif()
|
|
||||||
|
|
||||||
# Find dependencies
|
include_directories(
|
||||||
find_package(Boost COMPONENTS thread REQUIRED)
|
include
|
||||||
find_package(GTest REQUIRED)
|
${catkin_INCLUDE_DIRS}
|
||||||
# Finding Eigen3
|
${EIGEN3_INCLUDE_DIRS}
|
||||||
find_package(Eigen3 REQUIRED)
|
${Boost_INCLUDE_DIRS}
|
||||||
|
|
||||||
# Include directories
|
|
||||||
include_directories(
|
|
||||||
include
|
|
||||||
${EIGEN3_INCLUDE_DIRS}
|
|
||||||
${Boost_INCLUDE_DIRS}
|
|
||||||
${GTEST_INCLUDE_DIRS}
|
|
||||||
)
|
|
||||||
|
|
||||||
# Install headers
|
|
||||||
if(NOT BUILDING_WITH_CATKIN)
|
|
||||||
install(DIRECTORY include/${PROJECT_NAME}/
|
|
||||||
DESTINATION include/${PROJECT_NAME}
|
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_library(robot_tf3_geometry_msgs INTERFACE
|
# Tìm tất cả header files
|
||||||
)
|
file(GLOB_RECURSE HEADERS "include/robot_tf3_geometry_msgs/*.h")
|
||||||
|
|
||||||
target_include_directories(robot_tf3_geometry_msgs
|
# Tạo INTERFACE library (header-only)
|
||||||
|
add_library(${PROJECT_NAME} INTERFACE)
|
||||||
|
|
||||||
|
if(BUILDING_WITH_CATKIN)
|
||||||
|
add_dependencies(${PROJECT_NAME} ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
|
||||||
|
|
||||||
|
# Set include directories
|
||||||
|
target_include_directories(${PROJECT_NAME}
|
||||||
|
INTERFACE
|
||||||
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||||
|
$<INSTALL_INTERFACE:include>
|
||||||
|
)
|
||||||
|
|
||||||
|
# Link dependencies (header-only, chỉ cần include paths)
|
||||||
|
target_link_libraries(${PROJECT_NAME}
|
||||||
INTERFACE
|
INTERFACE
|
||||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
${catkin_LIBRARIES}
|
||||||
$<INSTALL_INTERFACE:include>
|
)
|
||||||
)
|
|
||||||
|
|
||||||
# Liên kết với robot_std_msgs nếu bạn có file Header.h trong include/robot_std_msgs/
|
else()
|
||||||
target_link_libraries(robot_tf3_geometry_msgs INTERFACE
|
|
||||||
geometry_msgs
|
|
||||||
data_convert
|
|
||||||
)
|
|
||||||
|
|
||||||
# --- Cài đặt thư viện vào hệ thống khi chạy make install ---
|
# Set include directories
|
||||||
install(TARGETS robot_tf3_geometry_msgs
|
target_include_directories(${PROJECT_NAME}
|
||||||
EXPORT robot_tf3_geometry_msgs-targets
|
INTERFACE
|
||||||
INCLUDES DESTINATION include # Cài đặt include
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||||
)
|
$<INSTALL_INTERFACE:include>
|
||||||
|
)
|
||||||
|
|
||||||
# --- Xuất export set robot_tf3_geometry_msgs-targets thành file CMake module ---
|
# Link dependencies (header-only, chỉ cần include paths)
|
||||||
# --- Tạo file lib/cmake/robot_tf3_geometry_msgs/robot_tf3_geometry_msgs-targets.cmake ---
|
target_link_libraries(${PROJECT_NAME}
|
||||||
# --- File này chứa cấu hình giúp project khác có thể dùng ---
|
INTERFACE
|
||||||
# --- Find_package(robot_tf3_geometry_msgs REQUIRED) ---
|
${PACKAGES_DIR}
|
||||||
# --- Target_link_libraries(my_app PRIVATE tf3_robot_geometry_msgs::robot_tf3_geometry_msgs) ---
|
)
|
||||||
install(EXPORT robot_tf3_geometry_msgs-targets
|
|
||||||
FILE robot_tf3_geometry_msgs-targets.cmake
|
endif()
|
||||||
DESTINATION lib/cmake/robot_tf3_geometry_msgs
|
|
||||||
)
|
if(BUILDING_WITH_CATKIN)
|
||||||
|
## Mark libraries for installation
|
||||||
# # Test: tomsg_frommsg
|
## See http://docs.ros.org/melodic/api/catkin/html/howto/format1/building_libraries.html
|
||||||
add_executable(test_tomsg_frommsg test/test_tomsg_frommsg.cpp)
|
install(TARGETS ${PROJECT_NAME}
|
||||||
target_link_libraries(test_tomsg_frommsg
|
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
|
||||||
${GTEST_LIBRARIES}
|
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
|
||||||
robot_tf3_geometry_msgs
|
RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}
|
||||||
|
)
|
||||||
|
|
||||||
|
## Mark cpp header files for installation
|
||||||
|
install(DIRECTORY include/${PROJECT_NAME}/
|
||||||
|
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
|
||||||
|
FILES_MATCHING PATTERN "*.h"
|
||||||
|
PATTERN ".svn" EXCLUDE
|
||||||
|
)
|
||||||
|
|
||||||
|
else()
|
||||||
|
|
||||||
|
install(TARGETS ${PROJECT_NAME}
|
||||||
|
EXPORT ${PROJECT_NAME}-targets
|
||||||
|
ARCHIVE DESTINATION lib
|
||||||
|
LIBRARY DESTINATION lib
|
||||||
|
RUNTIME DESTINATION bin
|
||||||
|
)
|
||||||
|
|
||||||
|
# Export targets
|
||||||
|
install(EXPORT ${PROJECT_NAME}-targets
|
||||||
|
FILE ${PROJECT_NAME}-targets.cmake
|
||||||
|
NAMESPACE ${PROJECT_NAME}::
|
||||||
|
DESTINATION lib/cmake/${PROJECT_NAME}
|
||||||
|
)
|
||||||
|
|
||||||
|
## Mark cpp header files for installation
|
||||||
|
install(DIRECTORY include/${PROJECT_NAME}/
|
||||||
|
DESTINATION include
|
||||||
|
FILES_MATCHING PATTERN "*.h"
|
||||||
|
PATTERN ".svn" EXCLUDE
|
||||||
|
)
|
||||||
|
|
||||||
|
# Print configuration info
|
||||||
|
message(STATUS "=================================")
|
||||||
|
message(STATUS "Project: ${PROJECT_NAME} (Header-Only)")
|
||||||
|
message(STATUS "Version: ${PROJECT_VERSION}")
|
||||||
|
message(STATUS "C++ Standard: ${CMAKE_CXX_STANDARD}")
|
||||||
|
message(STATUS "Headers found:")
|
||||||
|
foreach(hdr ${HEADERS})
|
||||||
|
message(STATUS " - ${hdr}")
|
||||||
|
endforeach()
|
||||||
|
message(STATUS "Dependencies: geometry_msgs, data_convert, tf3, Eigen3, Boost")
|
||||||
|
message(STATUS "=================================")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# ========================================================
|
||||||
|
# Test executables
|
||||||
|
# ========================================================
|
||||||
|
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/test/test_tomsg_frommsg.cpp)
|
||||||
|
add_executable(${PROJECT_NAME}_tomsg_frommsg_test test/test_tomsg_frommsg.cpp)
|
||||||
|
target_link_libraries(${PROJECT_NAME}_tomsg_frommsg_test PRIVATE
|
||||||
|
${PROJECT_NAME}
|
||||||
|
GTest::GTest
|
||||||
|
GTest::Main
|
||||||
Threads::Threads
|
Threads::Threads
|
||||||
tf3
|
tf3
|
||||||
data_convert
|
data_convert
|
||||||
)
|
)
|
||||||
# # Test: tf2_geometry_msgs
|
endif()
|
||||||
add_executable(test_geometry_msgs test/test_tf2_geometry_msgs.cpp)
|
|
||||||
target_link_libraries(test_geometry_msgs
|
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/test/test_tf2_geometry_msgs.cpp)
|
||||||
${GTEST_LIBRARIES}
|
add_executable(${PROJECT_NAME}_geometry_msgs_test test/test_tf2_geometry_msgs.cpp)
|
||||||
|
target_link_libraries(${PROJECT_NAME}_geometry_msgs_test PRIVATE
|
||||||
|
${PROJECT_NAME}
|
||||||
|
GTest::GTest
|
||||||
|
GTest::Main
|
||||||
Threads::Threads
|
Threads::Threads
|
||||||
tf3
|
tf3
|
||||||
robot_tf3_geometry_msgs
|
|
||||||
data_convert
|
data_convert
|
||||||
)
|
)
|
||||||
|
endif()
|
||||||
|
|
|
||||||
|
|
@ -111,7 +111,11 @@ void fromMsg(const robot_geometry_msgs::Vector3& in, tf3::Vector3& out)
|
||||||
*/
|
*/
|
||||||
template <>
|
template <>
|
||||||
inline
|
inline
|
||||||
const tf3::Time& getTimestamp(const robot_geometry_msgs::Vector3Stamped& t) {return data_convert::convertTime(t.header.stamp);}
|
const tf3::Time& getTimestamp(const robot_geometry_msgs::Vector3Stamped& t) {
|
||||||
|
static thread_local tf3::Time stamp;
|
||||||
|
stamp = data_convert::convertTime(t.header.stamp);
|
||||||
|
return stamp;
|
||||||
|
}
|
||||||
|
|
||||||
/** \brief Extract a frame ID from the header of a Vector message.
|
/** \brief Extract a frame ID from the header of a Vector message.
|
||||||
* This function is a specialization of the getFrameId template defined in tf3/convert.h.
|
* This function is a specialization of the getFrameId template defined in tf3/convert.h.
|
||||||
|
|
@ -219,7 +223,11 @@ void fromMsg(const robot_geometry_msgs::Point& in, tf3::Vector3& out)
|
||||||
*/
|
*/
|
||||||
template <>
|
template <>
|
||||||
inline
|
inline
|
||||||
const tf3::Time& getTimestamp(const robot_geometry_msgs::PointStamped& t) {return data_convert::convertTime(t.header.stamp);}
|
const tf3::Time& getTimestamp(const robot_geometry_msgs::PointStamped& t) {
|
||||||
|
static thread_local tf3::Time stamp;
|
||||||
|
stamp = data_convert::convertTime(t.header.stamp);
|
||||||
|
return stamp;
|
||||||
|
}
|
||||||
|
|
||||||
/** \brief Extract a frame ID from the header of a Point message.
|
/** \brief Extract a frame ID from the header of a Point message.
|
||||||
* This function is a specialization of the getFrameId template defined in tf3/convert.h.
|
* This function is a specialization of the getFrameId template defined in tf3/convert.h.
|
||||||
|
|
@ -328,7 +336,11 @@ void fromMsg(const robot_geometry_msgs::Quaternion& in, tf3::Quaternion& out)
|
||||||
*/
|
*/
|
||||||
template <>
|
template <>
|
||||||
inline
|
inline
|
||||||
const tf3::Time& getTimestamp(const robot_geometry_msgs::QuaternionStamped& t) {return data_convert::convertTime(t.header.stamp);}
|
const tf3::Time& getTimestamp(const robot_geometry_msgs::QuaternionStamped& t) {
|
||||||
|
static thread_local tf3::Time stamp;
|
||||||
|
stamp = data_convert::convertTime(t.header.stamp);
|
||||||
|
return stamp;
|
||||||
|
}
|
||||||
|
|
||||||
/** \brief Extract a frame ID from the header of a Quaternion message.
|
/** \brief Extract a frame ID from the header of a Quaternion message.
|
||||||
* This function is a specialization of the getFrameId template defined in tf3/convert.h.
|
* This function is a specialization of the getFrameId template defined in tf3/convert.h.
|
||||||
|
|
@ -461,7 +473,11 @@ void fromMsg(const robot_geometry_msgs::Pose& in, tf3::Transform& out)
|
||||||
*/
|
*/
|
||||||
template <>
|
template <>
|
||||||
inline
|
inline
|
||||||
const tf3::Time& getTimestamp(const robot_geometry_msgs::PoseStamped& t) {return data_convert::convertTime(t.header.stamp);}
|
const tf3::Time& getTimestamp(const robot_geometry_msgs::PoseStamped& t) {
|
||||||
|
static thread_local tf3::Time stamp;
|
||||||
|
stamp = data_convert::convertTime(t.header.stamp);
|
||||||
|
return stamp;
|
||||||
|
}
|
||||||
|
|
||||||
/** \brief Extract a frame ID from the header of a Pose message.
|
/** \brief Extract a frame ID from the header of a Pose message.
|
||||||
* This function is a specialization of the getFrameId template defined in tf3/convert.h.
|
* This function is a specialization of the getFrameId template defined in tf3/convert.h.
|
||||||
|
|
@ -535,7 +551,11 @@ void fromMsg(const robot_geometry_msgs::PoseStamped& msg, tf3::Stamped<tf3::Tran
|
||||||
*/
|
*/
|
||||||
template <>
|
template <>
|
||||||
inline
|
inline
|
||||||
const tf3::Time& getTimestamp(const robot_geometry_msgs::PoseWithCovarianceStamped& t) {return data_convert::convertTime(t.header.stamp);}
|
const tf3::Time& getTimestamp(const robot_geometry_msgs::PoseWithCovarianceStamped& t) {
|
||||||
|
static thread_local tf3::Time stamp;
|
||||||
|
stamp = data_convert::convertTime(t.header.stamp);
|
||||||
|
return stamp;
|
||||||
|
}
|
||||||
|
|
||||||
/** \brief Extract a frame ID from the header of a PoseWithCovarianceStamped message.
|
/** \brief Extract a frame ID from the header of a PoseWithCovarianceStamped message.
|
||||||
* This function is a specialization of the getFrameId template defined in tf3/convert.h.
|
* This function is a specialization of the getFrameId template defined in tf3/convert.h.
|
||||||
|
|
@ -659,7 +679,11 @@ void fromMsg(const tf3::TransformMsg& in, tf3::Transform& out)
|
||||||
*/
|
*/
|
||||||
template <>
|
template <>
|
||||||
inline
|
inline
|
||||||
const tf3::Time& getTimestamp(const robot_geometry_msgs::TransformStamped& t) {return data_convert::convertTime(t.header.stamp);}
|
const tf3::Time& getTimestamp(const robot_geometry_msgs::TransformStamped& t) {
|
||||||
|
static thread_local tf3::Time stamp;
|
||||||
|
stamp = data_convert::convertTime(t.header.stamp);
|
||||||
|
return stamp;
|
||||||
|
}
|
||||||
|
|
||||||
/** \brief Extract a frame ID from the header of a Transform message.
|
/** \brief Extract a frame ID from the header of a Transform message.
|
||||||
* This function is a specialization of the getFrameId template defined in tf3/convert.h.
|
* This function is a specialization of the getFrameId template defined in tf3/convert.h.
|
||||||
|
|
@ -1014,7 +1038,11 @@ inline
|
||||||
/**********************/
|
/**********************/
|
||||||
template <>
|
template <>
|
||||||
inline
|
inline
|
||||||
const tf3::Time& getTimestamp(const robot_geometry_msgs::WrenchStamped& t) {return data_convert::convertTime(t.header.stamp);}
|
const tf3::Time& getTimestamp(const robot_geometry_msgs::WrenchStamped& t) {
|
||||||
|
static thread_local tf3::Time stamp;
|
||||||
|
stamp = data_convert::convertTime(t.header.stamp);
|
||||||
|
return stamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
|
|
|
||||||
|
|
@ -19,5 +19,10 @@
|
||||||
|
|
||||||
<buildtool_depend version_gte="0.5.68">catkin</buildtool_depend>
|
<buildtool_depend version_gte="0.5.68">catkin</buildtool_depend>
|
||||||
|
|
||||||
|
<build_depend>robot_geometry_msgs</build_depend>
|
||||||
|
<build_depend>data_convert</build_depend>
|
||||||
|
<build_depend>tf3</build_depend>
|
||||||
|
<run_depend>robot_geometry_msgs</run_depend>
|
||||||
|
<run_depend>data_convert</run_depend>
|
||||||
|
<run_depend>tf3</run_depend>
|
||||||
</package>
|
</package>
|
||||||
|
|
@ -1,98 +1,176 @@
|
||||||
cmake_minimum_required(VERSION 3.10)
|
cmake_minimum_required(VERSION 3.0.2)
|
||||||
|
project(robot_tf3_sensor_msgs VERSION 1.0.0 LANGUAGES CXX)
|
||||||
|
|
||||||
# ========================================================
|
|
||||||
# Dual-mode CMakeLists.txt: Supports both Catkin and Standalone CMake
|
|
||||||
# ========================================================
|
|
||||||
|
|
||||||
# Detect if building with Catkin
|
|
||||||
if(DEFINED CATKIN_DEVEL_PREFIX OR DEFINED CATKIN_TOPLEVEL)
|
if(DEFINED CATKIN_DEVEL_PREFIX OR DEFINED CATKIN_TOPLEVEL)
|
||||||
set(BUILDING_WITH_CATKIN TRUE)
|
set(BUILDING_WITH_CATKIN TRUE)
|
||||||
message(STATUS "Building robot_tf3_sensor_msgs with Catkin")
|
message(STATUS "Building robot_tf3_sensor_msgs with Catkin")
|
||||||
find_package(catkin REQUIRED)
|
|
||||||
else()
|
else()
|
||||||
set(BUILDING_WITH_CATKIN FALSE)
|
set(BUILDING_WITH_CATKIN FALSE)
|
||||||
message(STATUS "Building robot_tf3_sensor_msgs with Standalone CMake")
|
message(STATUS "Building robot_tf3_sensor_msgs with Standalone CMake")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
project(robot_tf3_sensor_msgs)
|
# C++ Standard - must be set before find_package
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||||
|
|
||||||
|
# Find dependencies
|
||||||
|
find_package(Boost REQUIRED COMPONENTS thread)
|
||||||
|
find_package(Eigen3 REQUIRED)
|
||||||
|
find_package(GTest REQUIRED)
|
||||||
|
|
||||||
|
if (NOT BUILDING_WITH_CATKIN)
|
||||||
|
|
||||||
|
# Enable Position Independent Code
|
||||||
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||||
|
|
||||||
|
# Cấu hình RPATH để tránh cycle trong runtime search path
|
||||||
|
set(CMAKE_BUILD_RPATH_USE_ORIGIN TRUE)
|
||||||
|
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
||||||
|
set(CMAKE_BUILD_RPATH "${CMAKE_BINARY_DIR}")
|
||||||
|
|
||||||
|
set(PACKAGES_DIR
|
||||||
|
robot_sensor_msgs
|
||||||
|
data_convert
|
||||||
|
tf3
|
||||||
|
robot_geometry_msgs
|
||||||
|
)
|
||||||
|
|
||||||
|
else()
|
||||||
|
|
||||||
# ========================================================
|
# ========================================================
|
||||||
# Catkin specific configuration
|
# Catkin specific configuration
|
||||||
# ========================================================
|
# ========================================================
|
||||||
|
find_package(catkin REQUIRED COMPONENTS
|
||||||
|
robot_sensor_msgs
|
||||||
|
data_convert
|
||||||
|
tf3
|
||||||
|
robot_geometry_msgs
|
||||||
|
)
|
||||||
|
|
||||||
if(BUILDING_WITH_CATKIN)
|
|
||||||
catkin_package(
|
catkin_package(
|
||||||
INCLUDE_DIRS include
|
INCLUDE_DIRS include
|
||||||
# LIBRARIES không cần vì đây là header-only library
|
# LIBRARIES không cần vì đây là header-only library
|
||||||
# CATKIN_DEPENDS không cần vì dependencies không phải Catkin packages
|
CATKIN_DEPENDS robot_sensor_msgs data_convert tf3 robot_geometry_msgs
|
||||||
DEPENDS Eigen3 Boost
|
DEPENDS Eigen3 Boost
|
||||||
)
|
)
|
||||||
|
|
||||||
|
include_directories(
|
||||||
|
include
|
||||||
|
${catkin_INCLUDE_DIRS}
|
||||||
|
${EIGEN3_INCLUDE_DIRS}
|
||||||
|
${Boost_INCLUDE_DIRS}
|
||||||
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Find dependencies
|
# Tìm tất cả header files
|
||||||
find_package(Boost COMPONENTS thread REQUIRED)
|
file(GLOB_RECURSE HEADERS "include/robot_tf3_sensor_msgs/*.h")
|
||||||
find_package(GTest REQUIRED)
|
|
||||||
|
|
||||||
# Finding Eigen3
|
# Tạo INTERFACE library (header-only)
|
||||||
find_package(Eigen3 REQUIRED)
|
add_library(${PROJECT_NAME} INTERFACE)
|
||||||
|
|
||||||
|
if(BUILDING_WITH_CATKIN)
|
||||||
|
add_dependencies(${PROJECT_NAME} ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
|
||||||
|
|
||||||
# Include directories
|
# Set include directories
|
||||||
include_directories(
|
target_include_directories(${PROJECT_NAME}
|
||||||
include
|
INTERFACE
|
||||||
${EIGEN3_INCLUDE_DIRS}
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||||
${Boost_INCLUDE_DIRS}
|
$<INSTALL_INTERFACE:include>
|
||||||
${GTEST_INCLUDE_DIRS}
|
)
|
||||||
)
|
|
||||||
|
|
||||||
add_library(robot_tf3_sensor_msgs INTERFACE
|
# Link dependencies (header-only, chỉ cần include paths)
|
||||||
)
|
target_link_libraries(${PROJECT_NAME}
|
||||||
|
|
||||||
target_include_directories(robot_tf3_sensor_msgs
|
|
||||||
INTERFACE
|
INTERFACE
|
||||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
${catkin_LIBRARIES}
|
||||||
$<INSTALL_INTERFACE:include>
|
)
|
||||||
)
|
|
||||||
|
|
||||||
target_link_libraries(robot_tf3_sensor_msgs INTERFACE
|
else()
|
||||||
robot_sensor_msgs
|
|
||||||
data_convert
|
|
||||||
)
|
|
||||||
|
|
||||||
# --- Cài đặt thư viện vào hệ thống khi chạy make install ---
|
# Set include directories
|
||||||
install(TARGETS robot_tf3_sensor_msgs
|
target_include_directories(${PROJECT_NAME}
|
||||||
EXPORT robot_tf3_sensor_msgs-targets
|
INTERFACE
|
||||||
INCLUDES DESTINATION include # Cài đặt include
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||||
)
|
$<INSTALL_INTERFACE:include>
|
||||||
|
)
|
||||||
|
|
||||||
# --- Xuất export set robot_tf3_sensor_msgs-targets thành file CMake module ---
|
# Link dependencies (header-only, chỉ cần include paths)
|
||||||
# --- Tạo file lib/cmake/robot_tf3_sensor_msgs/robot_tf3_sensor_msgs-targets.cmake ---
|
target_link_libraries(${PROJECT_NAME}
|
||||||
# --- File này chứa cấu hình giúp project khác có thể dùng ---
|
INTERFACE
|
||||||
# --- Find_package(robot_tf3_sensor_msgs REQUIRED) ---
|
${PACKAGES_DIR}
|
||||||
# --- Target_link_libraries(my_app PRIVATE robot_tf3_sensor_msgs::robot_tf3_sensor_msgs) ---
|
)
|
||||||
install(EXPORT robot_tf3_sensor_msgs-targets
|
|
||||||
FILE robot_tf3_sensor_msgs-targets.cmake
|
endif()
|
||||||
NAMESPACE robot_tf3_sensor_msgs::
|
|
||||||
DESTINATION lib/cmake/robot_tf3_sensor_msgs
|
if(BUILDING_WITH_CATKIN)
|
||||||
)
|
## Mark libraries for installation
|
||||||
|
## See http://docs.ros.org/melodic/api/catkin/html/howto/format1/building_libraries.html
|
||||||
add_executable(test_tf2_sensor_msgs test/test_tf2_sensor_msgs.cpp)
|
install(TARGETS ${PROJECT_NAME}
|
||||||
target_include_directories(test_tf2_sensor_msgs PUBLIC
|
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
|
||||||
${EIGEN3_INCLUDE_DIRS}
|
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
|
||||||
${GTEST_INCLUDE_DIRS}
|
RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}
|
||||||
robot_tf3_sensor_msgs
|
)
|
||||||
geometry_msgs
|
|
||||||
tf3
|
## Mark cpp header files for installation
|
||||||
)
|
install(DIRECTORY include/${PROJECT_NAME}/
|
||||||
target_link_libraries(test_tf2_sensor_msgs
|
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
|
||||||
${GTEST_LIBRARIES}
|
FILES_MATCHING PATTERN "*.h"
|
||||||
Threads::Threads
|
PATTERN ".svn" EXCLUDE
|
||||||
robot_tf3_sensor_msgs
|
)
|
||||||
geometry_msgs
|
|
||||||
tf3
|
else()
|
||||||
data_convert
|
|
||||||
)
|
install(TARGETS ${PROJECT_NAME}
|
||||||
|
EXPORT ${PROJECT_NAME}-targets
|
||||||
|
ARCHIVE DESTINATION lib
|
||||||
|
LIBRARY DESTINATION lib
|
||||||
|
RUNTIME DESTINATION bin
|
||||||
|
)
|
||||||
|
|
||||||
|
# Export targets
|
||||||
|
install(EXPORT ${PROJECT_NAME}-targets
|
||||||
|
FILE ${PROJECT_NAME}-targets.cmake
|
||||||
|
NAMESPACE ${PROJECT_NAME}::
|
||||||
|
DESTINATION lib/cmake/${PROJECT_NAME}
|
||||||
|
)
|
||||||
|
|
||||||
|
## Mark cpp header files for installation
|
||||||
|
install(DIRECTORY include/${PROJECT_NAME}/
|
||||||
|
DESTINATION include
|
||||||
|
FILES_MATCHING PATTERN "*.h"
|
||||||
|
PATTERN ".svn" EXCLUDE
|
||||||
|
)
|
||||||
|
|
||||||
|
# Print configuration info
|
||||||
|
message(STATUS "=================================")
|
||||||
|
message(STATUS "Project: ${PROJECT_NAME} (Header-Only)")
|
||||||
|
message(STATUS "Version: ${PROJECT_VERSION}")
|
||||||
|
message(STATUS "C++ Standard: ${CMAKE_CXX_STANDARD}")
|
||||||
|
message(STATUS "Headers found:")
|
||||||
|
foreach(hdr ${HEADERS})
|
||||||
|
message(STATUS " - ${hdr}")
|
||||||
|
endforeach()
|
||||||
|
message(STATUS "Dependencies: robot_sensor_msgs, data_convert, tf3, robot_geometry_msgs, Eigen3, Boost")
|
||||||
|
message(STATUS "=================================")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# ========================================================
|
||||||
|
# Test executables
|
||||||
|
# ========================================================
|
||||||
|
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/test/test_tf2_sensor_msgs.cpp)
|
||||||
|
add_executable(${PROJECT_NAME}_test test/test_tf2_sensor_msgs.cpp)
|
||||||
|
target_include_directories(${PROJECT_NAME}_test PUBLIC
|
||||||
|
${EIGEN3_INCLUDE_DIRS}
|
||||||
|
${GTEST_INCLUDE_DIRS}
|
||||||
|
)
|
||||||
|
target_link_libraries(${PROJECT_NAME}_test PRIVATE
|
||||||
|
${PROJECT_NAME}
|
||||||
|
GTest::GTest
|
||||||
|
GTest::Main
|
||||||
|
Threads::Threads
|
||||||
|
robot_geometry_msgs
|
||||||
|
tf3
|
||||||
|
data_convert
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,11 @@ namespace tf3
|
||||||
*/
|
*/
|
||||||
template <>
|
template <>
|
||||||
inline
|
inline
|
||||||
const tf3::Time& getTimestamp(const robot_sensor_msgs::PointCloud2& p) {return data_convert::convertTime(p.header.stamp);}
|
const tf3::Time& getTimestamp(const robot_sensor_msgs::PointCloud2& p) {
|
||||||
|
static thread_local tf3::Time cached_time;
|
||||||
|
cached_time = data_convert::convertTime(p.header.stamp);
|
||||||
|
return cached_time;
|
||||||
|
}
|
||||||
|
|
||||||
/** \brief Extract a frame ID from the header of a PointCloud2 message.
|
/** \brief Extract a frame ID from the header of a PointCloud2 message.
|
||||||
* This function is a specialization of the getFrameId template defined in tf3/convert.h.
|
* This function is a specialization of the getFrameId template defined in tf3/convert.h.
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,13 @@
|
||||||
|
|
||||||
<buildtool_depend version_gte="0.5.68">catkin</buildtool_depend>
|
<buildtool_depend version_gte="0.5.68">catkin</buildtool_depend>
|
||||||
|
|
||||||
|
<build_depend>robot_sensor_msgs</build_depend>
|
||||||
|
<build_depend>tf3</build_depend>
|
||||||
|
<build_depend>robot_geometry_msgs</build_depend>
|
||||||
|
<build_depend>data_convert</build_depend>
|
||||||
|
|
||||||
|
<run_depend>robot_sensor_msgs</run_depend>
|
||||||
|
<run_depend>robot_geometry_msgs</run_depend>
|
||||||
|
<run_depend>data_convert</run_depend>
|
||||||
|
<run_depend>tf3</run_depend>
|
||||||
</package>
|
</package>
|
||||||
Loading…
Reference in New Issue
Block a user