Skip to content
Draft
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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ The Rosbag2 recorder provides the following services for remote control, which c
* Start topic discovery to automatically find and subscribe to new topics. Has no effect if discovery is already running or if the recorder is not in recording state.
* `~/stop_discovery [rosbag2_interfaces/srv/StopDiscovery]`
* Stop topic discovery. Existing subscriptions will be maintained, but new topics will not be discovered automatically.
* `~/get_subscribed_topics [rosbag2_interfaces/srv/GetSubscribedTopics]`
* Returns the list of fully qualified names of topics currently subscribed by the recorder.

These services enable full remote control of the recording process, allowing you to start and stop recording sessions, manage topic discovery, and control the recording state without restarting the recorder node.

Expand Down
2 changes: 2 additions & 0 deletions rosbag2_interfaces/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ rosidl_generate_interfaces(${PROJECT_NAME}
"msg/MessagesLostEvent.msg"
"srv/Burst.srv"
"srv/GetRate.srv"
"srv/GetSubscribedTopics.srv"
"srv/IsDiscoveryRunning.srv"
"srv/IsPaused.srv"
"srv/Pause.srv"
Expand All @@ -31,6 +32,7 @@ rosidl_generate_interfaces(${PROJECT_NAME}
"srv/SetRate.srv"
"srv/Snapshot.srv"
"srv/SplitBagfile.srv"
"srv/SubscribeToTopics.srv"
"srv/StartDiscovery.srv"
"srv/Stop.srv"
"srv/StopDiscovery.srv"
Expand Down
3 changes: 3 additions & 0 deletions rosbag2_interfaces/srv/GetSubscribedTopics.srv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
# Fully qualified names of topics currently subscribed by the recorder.
string[] topics
35 changes: 35 additions & 0 deletions rosbag2_interfaces/srv/SubscribeToTopics.srv
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Fully qualified topic names to subscribe the recorder to.
string[] topics

# Optional list of topic types matching the topics list; must be the same length as `topics` when provided.
# Entries can be empty to request type discovery when the ROS graph has a single type.
string[] topic_types

# TODO(morlov): The topic_types are defined as an auxiliary list of types in addition to another
# list of topics, aka topic_names. They should match by index. However, in practice, this is often a
# source of numerous errors. Need redesign the message definition to move topic_name and topic_type
# into a simple data structure, aka TopicNameAndType, and use it as an array in the
# SubscribeToTopics.srv request instead of the separate topics and topic_types fields?

---

# TODO(morlov): The return code should return 0 on success and some error code in case of an error.
# Please note that if there are no topics discovered and none of the topics got subscribed, this is
# still a successful call. We put all missed topics into the unavailable_topics list in response.
# However, if some topic has an invalid name or we failed to add the topic to the subscription for
# any other reasons, - this is a failure situation, and the client needs to be aware that something
# is wrong with the request via the return_code.
# Also need to put information into the error_string about failure. Similar to what
# we are logging in case of a failed attempt to do something.

# Return code. Returns 1 when none of the topics from the request got subscribed to or in case of error, otherwise 0.
int32 return_code

# Error string. Empty if no error occurred.
string error_string

# Topics that got subscribed after handling the request. This includes topics that were already subscribed to before the call.
string[] subscribed_topics

# Topics that could not be subscribed to because they were unavailable, invalid or the type was ambiguous.
string[] unavailable_topics
4 changes: 4 additions & 0 deletions rosbag2_transport/include/rosbag2_transport/recorder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,10 @@ class Recorder : public rclcpp::Node
ROSBAG2_TRANSPORT_PUBLIC
void set_on_start_recording_callback(OnStartRecordingCallback callback) const;

/// \return List of currently subscribed topics.
ROSBAG2_TRANSPORT_PUBLIC
std::vector<std::string> get_subscribed_topics() const;

inline constexpr static const auto kPauseResumeToggleKey = KeyboardHandler::KeyCode::SPACE;

protected:
Expand Down
Loading
Loading