diff --git a/cartographer-ros-adapt-glog-0.6.0.patch b/cartographer-ros-adapt-glog-0.6.0.patch deleted file mode 100644 index 8bbe502f5148817c51fe1515be63c09dec416622..0000000000000000000000000000000000000000 --- a/cartographer-ros-adapt-glog-0.6.0.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- ros-humble-cartographer-ros-2.0.9000/src/ros_log_sink.cpp 2022-04-20 08:01:33.000000000 +0800 -+++ ros-humble-cartographer-ros-2.0.9000/src/ros_log_sink.cpp 2023-09-13 10:45:08.000000000 +0800 -@@ -46,7 +46,7 @@ - (void) base_filename; // TODO: remove unused arg ? - - const std::string message_string = ::google::LogSink::ToString( -- severity, GetBasename(filename), line, tm_time, message, message_len); -+ severity, GetBasename(filename), line, ::google::LogMessageTime(*tm_time), message, message_len); - switch (severity) { - case ::google::GLOG_INFO: - RCLCPP_INFO_STREAM(logger_, message_string); diff --git a/cartographer-ros-fix-absl.patch b/cartographer-ros-fix-absl.patch deleted file mode 100644 index 9c6da2176954636969f61e1f0e95a774cd20eda0..0000000000000000000000000000000000000000 --- a/cartographer-ros-fix-absl.patch +++ /dev/null @@ -1,12 +0,0 @@ -diff -Naur ros-humble-cartographer-ros-2.0.9000_orgin/CMakeLists.txt ros-humble-cartographer-ros-2.0.9000/CMakeLists.txt ---- ros-humble-cartographer-ros-2.0.9000_orgin/CMakeLists.txt 2022-04-20 08:01:33.000000000 +0800 -+++ ros-humble-cartographer-ros-2.0.9000/CMakeLists.txt 2023-10-25 10:21:05.000000000 +0800 -@@ -50,6 +50,8 @@ - find_package(urdfdom_headers REQUIRED) - find_package(visualization_msgs REQUIRED) - -+add_definitions(-DABSL_LEGACY_THREAD_ANNOTATIONS) -+ - include_directories( - include - ${PCL_INCLUDE_DIRS} diff --git a/cartographer-ros-fix-multiple-definition-error.patch b/cartographer-ros-fix-multiple-definition-error.patch deleted file mode 100644 index c5c91b3abd06e66c21ef1669d241813dd0fec4ac..0000000000000000000000000000000000000000 --- a/cartographer-ros-fix-multiple-definition-error.patch +++ /dev/null @@ -1,23 +0,0 @@ ---- ros-humble-cartographer-ros-2.0.9000/CMakeLists.txt_org 2023-05-04 15:53:33.555572652 +0800 -+++ ros-humble-cartographer-ros-2.0.9000/CMakeLists.txt 2023-05-04 15:54:17.268212997 +0800 -@@ -59,20 +59,13 @@ - # Library - add_library(${PROJECT_NAME} - src/assets_writer.cpp -- src/assets_writer_main.cpp - src/map_builder_bridge.cpp - src/msg_conversion.cpp - src/node_constants.cpp - src/node.cpp -- src/node_main.cpp - src/node_options.cpp -- src/occupancy_grid_node_main.cpp - src/offline_node.cpp -- src/offline_node_main.cpp -- src/pbstream_map_publisher_main.cpp -- src/pbstream_to_ros_map_main.cpp - src/playable_bag.cpp -- src/rosbag_validate_main.cpp - src/ros_log_sink.cpp - src/ros_map.cpp - src/ros_map_writing_points_processor.cpp diff --git a/cartographer-ros-msgs.spec b/cartographer-ros-msgs.spec index 8398cc851389c564e92817179f5cea62b90a26b7..23f616f42373de49e8667fe66ab9cf1aef1f7aee 100644 --- a/cartographer-ros-msgs.spec +++ b/cartographer-ros-msgs.spec @@ -7,6 +7,7 @@ %global __requires_exclude_from ^/opt/ros/%{ros_distro}/.*$ %define RosPkgName cartographer-ros-msgs +%define ros_distro humble Name: ros-%{ros_distro}-%{RosPkgName} Version: 2.0.9000 diff --git a/cartographer-rviz.spec b/cartographer-rviz.spec index e48a8146d1667083304edc39f1edb7e21a8fa0a4..f7dd81a33fb1be62161dafa84b421c84fc454216 100644 --- a/cartographer-rviz.spec +++ b/cartographer-rviz.spec @@ -6,6 +6,7 @@ %global __requires_exclude_from ^/opt/ros/%{ros_distro}/.*$ %define RosPkgName cartographer-rviz +%define ros_distro humble Name: ros-%{ros_distro}-%{RosPkgName} Version: 2.0.9000 diff --git a/cartographer_ros-2.0.9003.tar.gz b/cartographer_ros-2.0.9003.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..80a890b39eb2c40386fceb50a172ed6c47363aad Binary files /dev/null and b/cartographer_ros-2.0.9003.tar.gz differ diff --git a/cartographer_ros-changes.patch b/cartographer_ros-changes.patch new file mode 100644 index 0000000000000000000000000000000000000000..0ac2e56951c61b30ac6ab87b477d2513eb273b94 --- /dev/null +++ b/cartographer_ros-changes.patch @@ -0,0 +1,142 @@ +diff --git a/cartographer_ros/CMakeLists.txt b/cartographer_ros/CMakeLists.txt +index 6eaeb59..ddc986a 100644 +--- a/cartographer_ros/CMakeLists.txt ++++ b/cartographer_ros/CMakeLists.txt +@@ -16,7 +16,7 @@ + cmake_minimum_required(VERSION 3.5) + + project(cartographer_ros) +- ++set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -include ${CMAKE_CURRENT_SOURCE_DIR}/thread_annotations_fix.h") + find_package(ament_cmake REQUIRED) + + # Default to C++17 +@@ -86,6 +86,7 @@ add_library(${PROJECT_NAME} SHARED + src/metrics/family_factory.cpp + src/metrics/internal/family.cpp + src/metrics/internal/histogram.cpp ++ src/metrics/collect_metrics_flags.cc + ) + target_include_directories(${PROJECT_NAME} PUBLIC + "$" +diff --git a/cartographer_ros/src/cartographer_grpc/node_grpc_main.cpp b/cartographer_ros/src/cartographer_grpc/node_grpc_main.cpp +index 20ee55d..0a80b4a 100644 +--- a/cartographer_ros/src/cartographer_grpc/node_grpc_main.cpp ++++ b/cartographer_ros/src/cartographer_grpc/node_grpc_main.cpp +@@ -21,17 +21,8 @@ + #include "cartographer_ros/ros_log_sink.h" + #include "gflags/gflags.h" + #include "tf2_ros/transform_listener.h" ++#include "cartographer_ros/metrics/collect_metrics_flag.h" + +-DEFINE_bool(collect_metrics, false, +- "Activates the collection of runtime metrics. If activated, the " +- "metrics can be accessed via a ROS service."); +-DEFINE_string(configuration_directory, "", +- "First directory in which configuration files are searched, " +- "second is always the Cartographer installation to allow " +- "including files from there."); +-DEFINE_string(configuration_basename, "", +- "Basename, i.e. not containing any directory prefix, of the " +- "configuration file."); + DEFINE_string(server_address, "localhost:50051", + "gRPC server address to stream the sensor data to."); + DEFINE_bool( +@@ -40,13 +31,6 @@ DEFINE_bool( + DEFINE_string( + save_map_filename, "", + "If non-empty, serialize state and write it to disk before shutting down."); +-DEFINE_string(load_state_filename, "", +- "If non-empty, filename of a .pbstream file " +- "to load, containing a saved SLAM state. " +- "Unless --upload_load_state_file is set, the filepath refers " +- "to the gRPC server's file system."); +-DEFINE_bool(load_frozen_state, true, +- "Load the saved state as frozen (non-optimized) trajectories."); + DEFINE_bool(upload_load_state_file, false, + "Upload the .pbstream file from a local path to the (remote) gRPC " + "server instead of loading it from the server file system."); +diff --git a/cartographer_ros/src/node_main.cpp b/cartographer_ros/src/node_main.cpp +index bdf33b8..e077586 100644 +--- a/cartographer_ros/src/node_main.cpp ++++ b/cartographer_ros/src/node_main.cpp +@@ -22,28 +22,11 @@ + #include "gflags/gflags.h" + #include "rclcpp/rclcpp.hpp" + #include "tf2_ros/transform_listener.h" ++#include "cartographer_ros/metrics/collect_metrics_flag.h" + +-DEFINE_bool(collect_metrics, false, +- "Activates the collection of runtime metrics. If activated, the " +- "metrics can be accessed via a ROS service."); +-DEFINE_string(configuration_directory, "", +- "First directory in which configuration files are searched, " +- "second is always the Cartographer installation to allow " +- "including files from there."); +-DEFINE_string(configuration_basename, "", +- "Basename, i.e. not containing any directory prefix, of the " +- "configuration file."); +-DEFINE_string(load_state_filename, "", +- "If non-empty, filename of a .pbstream file to load, containing " +- "a saved SLAM state."); +-DEFINE_bool(load_frozen_state, true, +- "Load the saved state as frozen (non-optimized) trajectories."); + DEFINE_bool( + start_trajectory_with_default_topics, true, + "Enable to immediately start the first trajectory with default topics."); +-DEFINE_string( +- save_state_filename, "", +- "If non-empty, serialize state and write it to disk before shutting down."); + + namespace cartographer_ros { + namespace { +diff --git a/cartographer_ros/src/offline_node.cpp b/cartographer_ros/src/offline_node.cpp +index 4b3f60e..7fc1bc5 100644 +--- a/cartographer_ros/src/offline_node.cpp ++++ b/cartographer_ros/src/offline_node.cpp +@@ -39,14 +39,8 @@ + #include "rclcpp/exceptions.hpp" + #include + #include ++#include "cartographer_ros/metrics/collect_metrics_flag.h" + +-DEFINE_bool(collect_metrics, false, +- "Activates the collection of runtime metrics. If activated, the " +- "metrics can be accessed via a ROS service."); +-DEFINE_string(configuration_directory, "", +- "First directory in which configuration files are searched, " +- "second is always the Cartographer installation to allow " +- "including files from there."); + DEFINE_string( + configuration_basenames, "", + "Comma-separated list of basenames, i.e. not containing any " +@@ -63,16 +57,6 @@ DEFINE_string(urdf_filenames, "", + "static links for the sensor configuration(s)."); + DEFINE_bool(use_bag_transforms, true, + "Whether to read, use and republish transforms from bags."); +-DEFINE_string(load_state_filename, "", +- "If non-empty, filename of a .pbstream file to load, containing " +- "a saved SLAM state."); +-DEFINE_bool(load_frozen_state, true, +- "Load the saved state as frozen (non-optimized) trajectories."); +-DEFINE_string(save_state_filename, "", +- "Explicit name of the file to which the serialized state will be " +- "written before shutdown. If left empty, the filename will be " +- "inferred from the first bagfile's name as: " +- ".pbstream"); + DEFINE_bool(keep_running, false, + "Keep running the offline node after all messages from the bag " + "have been processed."); +diff --git a/cartographer_ros/src/rosbag_validate_main.cpp b/cartographer_ros/src/rosbag_validate_main.cpp +index 61e16a3..5b2668a 100644 +--- a/cartographer_ros/src/rosbag_validate_main.cpp ++++ b/cartographer_ros/src/rosbag_validate_main.cpp +@@ -41,7 +41,7 @@ + #else + #include "urdf/model.hpp" + #endif +-#include ++#include + + DEFINE_string(bag_filename, "", "Bag to process."); + DEFINE_bool(dump_timing, false, diff --git a/cartographer-ros.spec b/cartographer_ros.spec similarity index 78% rename from cartographer-ros.spec rename to cartographer_ros.spec index e135ee8b75382be12d69cad24d5983d11bd560d4..ede0982bc2590d2475369bce2beced5e3113f25c 100644 --- a/cartographer-ros.spec +++ b/cartographer_ros.spec @@ -5,19 +5,21 @@ %global __provides_exclude_from ^/opt/ros/%{ros_distro}/.*$ %global __requires_exclude_from ^/opt/ros/%{ros_distro}/.*$ -%define RosPkgName cartographer-ros +%define ros_distro humble +%define RosPkgName cartographer-ros Name: ros-%{ros_distro}-%{RosPkgName} -Version: 2.0.9000 -Release: 2%{?dist}%{?release_suffix} +Version: 2.0.9003 +Release: 1%{?dist}%{?release_suffix} Summary: ROS cartographer-ros package -Url: https://github.com/cartographer-project/cartographer_ros -License: Apache 2.0 -Source0: %{name}_%{version}.orig.tar.gz -Patch0: cartographer-ros-fix-multiple-definition-error.patch -Patch1: cartographer-ros-fix-absl.patch -Patch2: cartographer-ros-adapt-glog-0.6.0.patch +Url: https://github.com/ros2/cartographer_ros +License: Apache-2.0 +Source0: cartographer_ros-%{version}.tar.gz +Source1: thread_annotations_fix.h +Source2: collect_metrics_flag.h +Source3: collect_metrics_flags.cc +Patch0: cartographer_ros-changes.patch Requires: ros-%{ros_distro}-builtin-interfaces Requires: ros-%{ros_distro}-cartographer @@ -43,6 +45,7 @@ Requires: ros-%{ros_distro}-urdf Requires: ros-%{ros_distro}-visualization-msgs Requires: ros-%{ros_distro}-launch Requires: ros-%{ros_distro}-robot-state-publisher +Requires: ros-%{ros_distro}-ros-environment Requires: ros-%{ros_distro}-ros-workspace BuildRequires: ros-%{ros_distro}-builtin-interfaces @@ -67,27 +70,33 @@ BuildRequires: ros-%{ros_distro}-tf2-msgs BuildRequires: ros-%{ros_distro}-tf2-ros BuildRequires: ros-%{ros_distro}-urdf BuildRequires: ros-%{ros_distro}-visualization-msgs +BuildRequires: ros-%{ros_distro}-ros-environment BuildRequires: gmock-devel BuildRequires: python3-sphinx BuildRequires: ros-%{ros_distro}-ament-cmake BuildRequires: ros-%{ros_distro}-ros-workspace -%if 0%{?with_tests} -%endif - Provides: %{name}-devel = %{version}-%{release} Provides: %{name}-doc = %{version}-%{release} Provides: %{name}-runtime = %{version}-%{release} %description - - Cartographer is a system that provides real-time simultaneous localization - and mapping (SLAM) in 2D and 3D across multiple platforms and sensor - configurations. This package provides Cartographer's ROS integration. - +Cartographer is a system that provides real-time simultaneous localization +and mapping (SLAM) in 2D and 3D across multiple platforms and sensor +configurations. This package provides Cartographer's ROS integration. %prep -%autosetup -p1 +%setup -q -n cartographer_ros-%{version} + +# Copy additional files to their correct locations +cp %{SOURCE1} thread_annotations_fix.h +mkdir -p include/cartographer_ros/metrics/ +cp %{SOURCE2} include/cartographer_ros/metrics/collect_metrics_flag.h +mkdir -p src/metrics/ +cp %{SOURCE3} src/metrics/collect_metrics_flags.cc + +# Apply patches +%patch -P0 -p2 %build # Needed to bootstrap since the ros_workspace package does not yet exist. @@ -146,7 +155,7 @@ else echo "RPM TESTS SKIPPED"; fi /opt/ros/%{ros_distro} %changelog -* Wed Sep 12 2023 simonaxi <18701881329@163.com> - 2.0.9000-2 -- fix: adapter absl patch -* Thu May 04 2023 Chris Lalancette clalancette@openrobotics.org - 2.0.9000-1 -- Autogenerated by ros-porting-tools +* Thu Nov 14 2024 Your Name - 2.0.9003-1 +- Initial build with custom patches for thread safety +- Add thread_annotations_fix.h and metrics collection files +- Fix tf2/utils.h header issue diff --git a/collect_metrics_flag.h b/collect_metrics_flag.h new file mode 100644 index 0000000000000000000000000000000000000000..ce5704f54f91f9eee1761481a4f1ffe9d688cdf5 --- /dev/null +++ b/collect_metrics_flag.h @@ -0,0 +1,17 @@ +#ifndef CARTOGRAPHER_ROS_METRICS_COLLECT_METRICS_FLAG_H_ +#define CARTOGRAPHER_ROS_METRICS_COLLECT_METRICS_FLAG_H_ + +#include + +// Metrics flags +DECLARE_bool(collect_metrics); +DECLARE_bool(load_frozen_state); + +// Shared configuration flags +DECLARE_string(configuration_directory); +DECLARE_string(load_state_filename); +DECLARE_string(save_state_filename); +DECLARE_string(configuration_basename); + +#endif // CARTOGRAPHER_ROS_METRICS_COLLECT_METRICS_FLAG_H_ + diff --git a/collect_metrics_flags.cc b/collect_metrics_flags.cc new file mode 100644 index 0000000000000000000000000000000000000000..ff62db8b173e6e21e307ba2822c9bbb93f55b43b --- /dev/null +++ b/collect_metrics_flags.cc @@ -0,0 +1,19 @@ +#include + +// Metrics flags +DEFINE_bool(collect_metrics, false, "Enable metrics"); +DEFINE_bool(load_frozen_state, true, "Load frozen state before new trajectory"); + +// Shared configuration flags +DEFINE_string(configuration_directory, "", + "First directory in which configuration files are searched, " + "second is always the Cartographer installation to allow " + "including files from there."); +DEFINE_string(load_state_filename, "", + "If non-empty, filename of a .pbstream file to load, containing " + "a saved SLAM state."); +DEFINE_string(save_state_filename, "", + "If non-empty, serialize state and write it to disk before shutting down."); +DEFINE_string(configuration_basename, "", + "Basename, i.e. not containing any directory prefix, of the " + "configuration file."); diff --git a/ros-humble-cartographer-ros_2.0.9000.orig.tar.gz b/ros-humble-cartographer-ros_2.0.9000.orig.tar.gz deleted file mode 100644 index 02b752d0c5e2999d9682e6e90ec493dff5ef7d6e..0000000000000000000000000000000000000000 Binary files a/ros-humble-cartographer-ros_2.0.9000.orig.tar.gz and /dev/null differ diff --git a/thread_annotations_fix.h b/thread_annotations_fix.h new file mode 100644 index 0000000000000000000000000000000000000000..6de6faa12ae7fbe1dd83082f137ddca82f56e8ef --- /dev/null +++ b/thread_annotations_fix.h @@ -0,0 +1,61 @@ +#ifndef THREAD_ANNOTATIONS_FIX_H +#define THREAD_ANNOTATIONS_FIX_H + +// 定义所有缺失的线程注解宏为空操作 +#ifndef LOCKS_EXCLUDED +#define LOCKS_EXCLUDED(...) +#endif + +#ifndef GUARDED_BY +#define GUARDED_BY(x) +#endif + +#ifndef EXCLUSIVE_LOCKS_REQUIRED +#define EXCLUSIVE_LOCKS_REQUIRED(...) +#endif + +#ifndef SHARED_LOCKS_REQUIRED +#define SHARED_LOCKS_REQUIRED(...) +#endif + +#ifndef ACQUIRED_BEFORE +#define ACQUIRED_BEFORE(...) +#endif + +#ifndef ACQUIRED_AFTER +#define ACQUIRED_AFTER(...) +#endif + +#ifndef REQUIRES +#define REQUIRES(...) +#endif + +#ifndef ACQUIRE +#define ACQUIRE(...) +#endif + +#ifndef RELEASE +#define RELEASE(...) +#endif + +#ifndef EXCLUDES +#define EXCLUDES(...) +#endif + +#ifndef ASSERT_EXCLUSIVE_LOCK +#define ASSERT_EXCLUSIVE_LOCK(...) +#endif + +#ifndef ASSERT_SHARED_LOCK +#define ASSERT_SHARED_LOCK(...) +#endif + +#ifndef RETURN_CAPABILITY +#define RETURN_CAPABILITY(x) +#endif + +#ifndef NO_THREAD_SAFETY_ANALYSIS +#define NO_THREAD_SAFETY_ANALYSIS +#endif + +#endif // THREAD_ANNOTATIONS_FIX_H