Skip to content

Commit 14a3681

Browse files
committed
Make Player a rosbag2 component
1 parent 34ccb39 commit 14a3681

File tree

2 files changed

+72
-0
lines changed

2 files changed

+72
-0
lines changed

rosbag2/CMakeLists.txt

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,63 @@
11
cmake_minimum_required(VERSION 3.5)
22
project(rosbag2)
33

4+
# Default to C99
5+
if(NOT CMAKE_C_STANDARD)
6+
set(CMAKE_C_STANDARD 99)
7+
endif()
8+
9+
# Default to C++17
10+
if(NOT CMAKE_CXX_STANDARD)
11+
set(CMAKE_CXX_STANDARD 17)
12+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
13+
endif()
14+
15+
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
16+
add_compile_options(-Wall -Wextra -Wpedantic)
17+
endif()
18+
if(CMAKE_BUILD_TYPE STREQUAL "Debug" AND MSVC)
19+
# /bigobj is needed to avoid error C1128:
20+
# https://msdn.microsoft.com/en-us/library/8578y171.aspx
21+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj")
22+
endif()
23+
24+
# Windows supplies macros for min and max by default. We should only use min and max from stl
25+
if(WIN32)
26+
add_definitions(-DNOMINMAX)
27+
endif()
28+
429
find_package(ament_cmake REQUIRED)
30+
find_package(rclcpp_components REQUIRED)
31+
find_package(rosbag2_transport REQUIRED)
32+
33+
add_library(${PROJECT_NAME} SHARED
34+
src/rosbag2/component_player.cpp
35+
)
36+
37+
target_link_libraries(${PROJECT_NAME}
38+
rclcpp::rclcpp
39+
${rclcpp_components_TARGETS}
40+
rosbag2_transport::rosbag2_transport
41+
)
42+
43+
rclcpp_components_register_node(${PROJECT_NAME}
44+
PLUGIN "rosbag2::Player"
45+
EXECUTABLE player
46+
)
47+
48+
install(
49+
TARGETS ${PROJECT_NAME}
50+
EXPORT export_${PROJECT_NAME}
51+
ARCHIVE DESTINATION lib
52+
LIBRARY DESTINATION lib
53+
RUNTIME DESTINATION bin
54+
)
55+
56+
ament_export_libraries(${PROJECT_NAME})
57+
58+
ament_export_dependencies(
59+
rclcpp_components
60+
rosbag2_transport
61+
)
62+
563
ament_package()
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#include "rosbag2_transport/player.hpp"
2+
3+
namespace rosbag2 {
4+
class Player : public rosbag2_transport::Player {
5+
using rosbag2_transport::Player::Player;
6+
};
7+
}
8+
9+
#include "rclcpp_components/register_node_macro.hpp"
10+
11+
// Register the component with class_loader.
12+
// This acts as a sort of entry point, allowing the component to be
13+
// discoverable when its library is being loaded into a running process.
14+
RCLCPP_COMPONENTS_REGISTER_NODE(rosbag2::Player)

0 commit comments

Comments
 (0)