Skip to content

Add rosbag2 keyboard handler patch #445

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions repositories/patches/rosbag2_keyboard-handler.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
diff --git a/rosbag2_transport/src/rosbag2_transport/recorder.cpp b/rosbag2_transport/src/rosbag2_transport/recorder.cpp
index 4d0c2649..aa303b8d 100644
--- a/rosbag2_transport/src/rosbag2_transport/recorder.cpp
+++ b/rosbag2_transport/src/rosbag2_transport/recorder.cpp
@@ -95,11 +95,16 @@ Recorder::Recorder(
}

std::string key_str = enum_key_code_to_str(Recorder::kPauseResumeToggleKey);
- toggle_paused_key_callback_handle_ =
- keyboard_handler_->add_key_press_callback(
- [this](KeyboardHandler::KeyCode /*key_code*/,
- KeyboardHandler::KeyModifiers /*key_modifiers*/) {this->toggle_paused();},
- Recorder::kPauseResumeToggleKey);
+ if (keyboard_handler_) {
+ toggle_paused_key_callback_handle_ =
+ keyboard_handler_->add_key_press_callback(
+ [this](KeyboardHandler::KeyCode /*key_code*/,
+ KeyboardHandler::KeyModifiers /*key_modifiers*/) {
+ this->toggle_paused();
+ },
+ Recorder::kPauseResumeToggleKey);
+ }
+
// show instructions
RCLCPP_INFO_STREAM(
get_logger(),
@@ -112,7 +117,10 @@ Recorder::Recorder(

Recorder::~Recorder()
{
- keyboard_handler_->delete_key_press_callback(toggle_paused_key_callback_handle_);
+ if (keyboard_handler_) {
+ keyboard_handler_->delete_key_press_callback(
+ toggle_paused_key_callback_handle_);
+ }
stop();
}

5 changes: 4 additions & 1 deletion repositories/ros2_repositories_impl.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,10 @@ def ros2_repositories_impl():
name = "ros2_rosbag2",
build_file = "@com_github_mvukov_rules_ros2//repositories:rosbag2.BUILD.bazel",
patch_args = ["-p1"],
patches = ["@com_github_mvukov_rules_ros2//repositories/patches:rosbag2_relax_plugin_errors.patch"],
patches = [
"@com_github_mvukov_rules_ros2//repositories/patches:rosbag2_relax_plugin_errors.patch",
"@com_github_mvukov_rules_ros2//repositories/patches:rosbag2_keyboard-handler.patch",
],
sha256 = "035f4346bdc4bee7b86fed277658bc045b627f5517085fdf3a453285b274ee3c",
strip_prefix = "rosbag2-0.15.13",
url = "https://github.com/ros2/rosbag2/archive/refs/tags/0.15.13.tar.gz",
Expand Down
Loading