You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When closing a recording, occasionally, the ros2 bag is apparently not closed correctly, which makes a reindex of the bag necessary.
This happens for both the sqlite3 and the mcap plugins. Usually, this is no big issue and takes only a few seconds, but reindexing these mcap files seems to be not possible for now (which is another issue).
For our setup (recording point clouds, images, and GNSS data), this issue occurs in most cases.
Expected Behavior
The recording should stop and write the remaining messages from the cache to the bag. A metadata.yaml file should be created.
...
[INFO] [1662381739.854492546] [rosbag2_recorder]: Subscribed to topic '/sensing/gnss/fixed'
[INFO] [1662381739.856257118] [rosbag2_recorder]: Subscribed to topic '/sensing/gnss/pose'
[INFO] [1662381746.062154306] [rclcpp]: signal_handler(signum=2)
[INFO] [1662381746.159286989] [rosbag2_cpp]: Writing remaining messages from cache to the bag. It may take a while
Actual Behavior
ros2 bag record is stuck at signal_handler(signum=2). The remaining messages are not written to the bag and killing the recording process or closing the terminal is required. No metadata.yaml file is created.
...
[INFO] [1662381748.073734704] [rosbag2_recorder]: Subscribed to topic '/sensing/gnss/fixed'
[INFO] [1662381748.076060419] [rosbag2_recorder]: Subscribed to topic '/sensing/gnss/pose'
[INFO] [1662381754.862466740] [rclcpp]: signal_handler(signum=2)
To Reproduce
** Steps to reproduce the behavior, e.g.
Start a recording with ros2 bag record -a. Actually, this issue also occurs when no other node is running and only the recording is started.
Stop recording with Ctrl+C.
It might need a few tries, but for me, in roughly half of the cases the recording is not stopped correctly, and killing the process is required.
System (please complete the following information)
OS: Ubuntu Jammy
ROS 2 Distro: Humble
Version: 0.15.2-1jammy.20220729 (apt release)
RCA (Root Cause Analysis)
Rosbag2 player and recorder not finishing correctly because it's waiting for Enter key to be pressed after CTRL+C. If press Enter key after CTRL+C rosbag2 finishes correctly.
which is imply to block next read from std input until Enter key will be pressed. Which normal and default behavior when we returning to the console.
However we are not returning to the console right after SIGINT but rather trying to dismiss it on upper level and call rclcpp::shutdown() for instance here to invalidate context and force finishing current application.
inside executor_>spin(); call
6. We are exiting from infinite loop and going in to rosbag2 destructor when we triggering rclcpp::shutdown()
7. Hangout with wait for Enter key happening when we are trying to destruct keyboard_handler_ instance and waiting to join main keyboard handler thread in it's own destructor.
if (key_handler_thread_.joinable()) {
key_handler_thread_.join();
}
Main keyboard_handler thread hangout for joining because it got blocked on read_fn system function call which became as a blocking call and waiting for Enter key to be pressed after we changed input to the canonical mode in signal handler.
Proposed solution
Do not use signal handler in Keyboard handler class since we are going to ignore it and correctly finish our application on upper level. There are available specific parameter in keyboard_handler constructor to avoid handling SIGINT.
Trigger internal exit variable to true from signal handler in keyboard handler to avoid getting stuck on next read function after changing the canonical input mode.
The text was updated successfully, but these errors were encountered:
FranzAlbers
changed the title
ros2 bag record does not properly close recoring
ros2 bag record does not properly close recording
Sep 5, 2022
FranzAlbers
changed the title
ros2 bag record does not properly close recording
ros2 bag record does occasionally not properly close recording
Sep 5, 2022
@FranzAlbers It seems that I know what is causing this issue and I have a fix for it.
To double check can you please try to press Enter key when you see that rosbag2 reorder hangout after Ctrl+C?
Sorry for inconvenience. I am expecting that pressing Enter should work as workaround until we will fix this issue with a proper way.
@MichaelOrlov, thanks for your help and for the hint!
Pressing enter indeed works as a workaround.
MichaelOrlov
changed the title
ros2 bag record does occasionally not properly close recording
ros2 bag record and play does occasionally not properly closing when pressing Ctrl+C
Sep 8, 2022
Description
When closing a recording, occasionally, the ros2 bag is apparently not closed correctly, which makes a reindex of the bag necessary.
This happens for both the sqlite3 and the mcap plugins. Usually, this is no big issue and takes only a few seconds, but reindexing these mcap files seems to be not possible for now (which is another issue).
For our setup (recording point clouds, images, and GNSS data), this issue occurs in most cases.
Expected Behavior
The recording should stop and write the remaining messages from the cache to the bag. A metadata.yaml file should be created.
Actual Behavior
ros2 bag record is stuck at
signal_handler(signum=2)
. The remaining messages are not written to the bag and killing the recording process or closing the terminal is required. No metadata.yaml file is created.To Reproduce
** Steps to reproduce the behavior, e.g.
ros2 bag record -a
. Actually, this issue also occurs when no other node is running and only the recording is started.System (please complete the following information)
RCA (Root Cause Analysis)
Enter
key to be pressed afterCTRL+C
. If pressEnter
key afterCTRL+C
rosbag2 finishes correctly.Enter
key because we catchingSIGINT
signal in keyboard handler and returning input from unbuffered to the canonical modeEnter
key will be pressed. Which normal and default behavior when we returning to the console.rclcpp::shutdown()
for instance here to invalidate context and force finishing current application.rosbag2/rosbag2_py/src/rosbag2_py/_transport.cpp
Line 228 in 8a77246
inside
executor_>spin();
call6. We are exiting from infinite loop and going in to rosbag2 destructor when we triggering
rclcpp::shutdown()
7. Hangout with wait for
Enter
key happening when we are trying to destructkeyboard_handler_
instance and waiting to join main keyboard handler thread in it's own destructor.keyboard_handler
thread hangout for joining because it got blocked onread_fn
system function call which became as a blocking call and waiting forEnter
key to be pressed after we changed input to the canonical mode in signal handler.Proposed solution
Keyboard handler
class since we are going to ignore it and correctly finish our application on upper level. There are available specific parameter in keyboard_handler constructor to avoid handlingSIGINT
.exit
variable to true from signal handler in keyboard handler to avoid getting stuck on next read function after changing the canonical input mode.The text was updated successfully, but these errors were encountered: