From 8c20436c2b48e8a647b7609b865c2244b5c47ff0 Mon Sep 17 00:00:00 2001 From: Max Schwarz Date: Mon, 19 Feb 2024 15:53:08 +0100 Subject: [PATCH] cmd_play: basic topic information in status message --- rosbag_fancy/src/cmd_play.cpp | 34 ++++++++--------------- rosbag_fancy_msgs/CMakeLists.txt | 1 + rosbag_fancy_msgs/msg/PlayStatus.msg | 2 +- rosbag_fancy_msgs/msg/PlayTopicStatus.msg | 5 ++++ 4 files changed, 18 insertions(+), 24 deletions(-) create mode 100644 rosbag_fancy_msgs/msg/PlayTopicStatus.msg diff --git a/rosbag_fancy/src/cmd_play.cpp b/rosbag_fancy/src/cmd_play.cpp index 789348a..3c02611 100644 --- a/rosbag_fancy/src/cmd_play.cpp +++ b/rosbag_fancy/src/cmd_play.cpp @@ -237,32 +237,20 @@ int play(const std::vector& options) msg->current = currentTime-startTime; msg->duration = endTime-startTime; - for(const auto & bag : bags) + msg->bagfiles.reserve(bags.size()); + for(const auto& bag : bags) msg->bagfiles.emplace_back(bag.filename_); + msg->topics.reserve(topicManager.topics().size()); + for(const auto& topic : topicManager.topics()) + { + msg->topics.emplace_back(); + auto& topicMsg = msg->topics.back(); - // TODO: fill some of this information - -// auto& counts = writer.messageCounts(); - -// for(auto& topic : topicManager.topics()) -// { -// msg->topics.emplace_back(); -// auto& topicMsg = msg->topics.back(); - -// msg->bandwidth += topic.bandwidth; - -// topicMsg.name = topic.name; -// topicMsg.publishers = topic.numPublishers; -// topicMsg.bandwidth = topic.bandwidth; -// topicMsg.bytes = topic.totalBytes; -// topicMsg.messages = topic.totalMessages; - -// if(topic.id < counts.size()) -// topicMsg.messages_in_current_bag = counts[topic.id]; - -// topicMsg.rate = topic.messageRateAt(now); -// } + topicMsg.name = topic.name; + topicMsg.bandwidth = topic.bandwidth; + topicMsg.rate = topic.messageRate; + } pub_status.publish(msg); })); diff --git a/rosbag_fancy_msgs/CMakeLists.txt b/rosbag_fancy_msgs/CMakeLists.txt index be617fc..de87545 100644 --- a/rosbag_fancy_msgs/CMakeLists.txt +++ b/rosbag_fancy_msgs/CMakeLists.txt @@ -11,6 +11,7 @@ add_message_files(FILES Status.msg TopicStatus.msg PlayStatus.msg + PlayTopicStatus.msg ) generate_messages(DEPENDENCIES diff --git a/rosbag_fancy_msgs/msg/PlayStatus.msg b/rosbag_fancy_msgs/msg/PlayStatus.msg index 42ef9fc..b44f5a4 100644 --- a/rosbag_fancy_msgs/msg/PlayStatus.msg +++ b/rosbag_fancy_msgs/msg/PlayStatus.msg @@ -13,5 +13,5 @@ time startTime time endTime string[] bagfiles -TopicStatus[] topics +PlayTopicStatus[] topics diff --git a/rosbag_fancy_msgs/msg/PlayTopicStatus.msg b/rosbag_fancy_msgs/msg/PlayTopicStatus.msg new file mode 100644 index 0000000..d5710de --- /dev/null +++ b/rosbag_fancy_msgs/msg/PlayTopicStatus.msg @@ -0,0 +1,5 @@ + +string name + +float32 rate +float32 bandwidth