From b72c1d75087a58418a67f109893eef2a5675ca30 Mon Sep 17 00:00:00 2001 From: Marina Moreira <67443181+marinagmoreira@users.noreply.github.com> Date: Wed, 12 Jan 2022 14:52:14 -0800 Subject: [PATCH] improve documentation and readability + increase split (#394) --- astrobee/config/management/data_bagger.config | 2 +- .../include/data_bagger/data_bagger.h | 20 +++++++++++++++---- management/data_bagger/readme.md | 6 +++++- management/data_bagger/src/data_bagger.cc | 14 ++++++------- 4 files changed, 29 insertions(+), 13 deletions(-) diff --git a/astrobee/config/management/data_bagger.config b/astrobee/config/management/data_bagger.config index e8d52e25b3..bed1f15835 100644 --- a/astrobee/config/management/data_bagger.config +++ b/astrobee/config/management/data_bagger.config @@ -26,7 +26,7 @@ startup_time_secs = 20 bags_save_directory = "/data/bags/" -bag_size_bytes = 96*1024*1024 +bag_size_bytes = 5*96*1024*1024 default_topics = {{topic="gnc/ctl/traj", downlink="immediate", frequency=-1}, {topic="gnc/ekf", downlink="immediate", frequency=-1}, diff --git a/management/data_bagger/include/data_bagger/data_bagger.h b/management/data_bagger/include/data_bagger/data_bagger.h index 42732f5396..7b50c81e0e 100644 --- a/management/data_bagger/include/data_bagger/data_bagger.h +++ b/management/data_bagger/include/data_bagger/data_bagger.h @@ -54,39 +54,51 @@ class DataBagger : public ff_util::FreeFlyerNodelet { DataBagger(); ~DataBagger(); - bool SetDataToDiskService(ff_msgs::SetDataToDisk::Request &req, + // Service that sets delayed recording settings + bool SetDelayedDataToDiskService(ff_msgs::SetDataToDisk::Request &req, ff_msgs::SetDataToDisk::Response &res); - bool EnableRecordingService(ff_msgs::EnableRecording::Request &req, + // This service enables and disables the delayed recording + bool EnableDelayedRecordingService(ff_msgs::EnableRecording::Request &req, ff_msgs::EnableRecording::Response &res); protected: virtual void Initialize(ros::NodeHandle *nh); - bool ReadParams(); + bool ReadParams(); // Reads data bagger parameters and default profile private: + // Reads all topic names published by the robot void GetTopicNames(); + // Recursively created bag destionation folder bool MakeDir(std::string dir, bool assert_init_fault, std::string &err_msg); + // Gets the date for name generation std::string GetDate(bool with_time); - void FixTopicNamespace(std::string &topic); + // Adds the namespace to topic names + void AddTopicNamespace(std::string &topic); + // Timer for when the robot finishes startup, starts immediate recording void OnStartupTimer(ros::TimerEvent const& event); + // Sets immediate recording settings bool SetImmediateDataToDisk(std::string &err_msg); bool SetDelayedDataToDisk(ff_msgs::DataToDiskState &state, std::string &err_msg); + // Start Recordings void StartDelayedRecording(); void StartImmediateRecording(); + // Clear topics, stop recording void ResetRecorders(bool immediate); + // Update data bagger profile state void GenerateCombinedState(ff_msgs::DataToDiskState *ground_state); + // Publish data bagger state void PublishState(); astrobee_rosbag::Recorder *delayed_recorder_, *immediate_recorder_; diff --git a/management/data_bagger/readme.md b/management/data_bagger/readme.md index f5e27da6e3..5b68552acf 100644 --- a/management/data_bagger/readme.md +++ b/management/data_bagger/readme.md @@ -1,3 +1,7 @@ \page data_bagger Data Bagger -TBD +This node manages recording for the Astrobee robot. This node is mainly used with GDS where different profiles can be easily loaded and managed. + +It distinguishes between two types of recording, immediate and delayed. + * Immediate recording: enabled for the entire duration where the flight software is on. The topics it records are defined in the config file "management/data_bagger.config" and can't be customized during flight. + * Delayed recording: used for data collection, the topics it records can be customized and the recording can start and stop at any time. diff --git a/management/data_bagger/src/data_bagger.cc b/management/data_bagger/src/data_bagger.cc index 71fb1be7c4..3aff0165d1 100644 --- a/management/data_bagger/src/data_bagger.cc +++ b/management/data_bagger/src/data_bagger.cc @@ -61,12 +61,12 @@ void DataBagger::Initialize(ros::NodeHandle *nh) { set_service_ = nh->advertiseService(SERVICE_MANAGEMENT_DATA_BAGGER_SET_DATA_TO_DISK, - &DataBagger::SetDataToDiskService, + &DataBagger::SetDelayedDataToDiskService, this); record_service_ = nh->advertiseService(SERVICE_MANAGEMENT_DATA_BAGGER_ENABLE_RECORDING, - &DataBagger::EnableRecordingService, + &DataBagger::EnableDelayedRecordingService, this); // Timer used to determine when to query ros for the topic list. Timer is one @@ -134,7 +134,7 @@ bool DataBagger::ReadParams() { return false; } - FixTopicNamespace(save_settings.topic_name); + AddTopicNamespace(save_settings.topic_name); if (!topic_entry.GetStr("downlink", &downlink)) { this->AssertFault(ff_util::INITIALIZATION_FAILED, @@ -244,7 +244,7 @@ bool DataBagger::MakeDir(std::string dir, // give the ros bagger the topic gnc/ekf and there is a namespace of bumble, it // will subscribe to /bumble/gnc/ekf but the topic in the bag it records will be // gnc/ekf. -void DataBagger::FixTopicNamespace(std::string &topic) { +void DataBagger::AddTopicNamespace(std::string &topic) { // This function assumes a user doesn't put the namespace in the topic. If // they do, this won't work // Check topic not empty @@ -277,7 +277,7 @@ void DataBagger::OnStartupTimer(ros::TimerEvent const& event) { } } -bool DataBagger::SetDataToDiskService(ff_msgs::SetDataToDisk::Request &req, +bool DataBagger::SetDelayedDataToDiskService(ff_msgs::SetDataToDisk::Request &req, ff_msgs::SetDataToDisk::Response &res) { // Don't allow set data to disk when we are recording if (combined_data_state_.recording) { @@ -311,7 +311,7 @@ bool DataBagger::SetDataToDiskService(ff_msgs::SetDataToDisk::Request &req, return true; } - FixTopicNamespace(setting.topic_name); + AddTopicNamespace(setting.topic_name); recorder_options_delayed_.topics.push_back(setting.topic_name); // TODO(Someone) Need to figure out how to record topics at different @@ -334,7 +334,7 @@ bool DataBagger::SetDataToDiskService(ff_msgs::SetDataToDisk::Request &req, return true; } -bool DataBagger::EnableRecordingService(ff_msgs::EnableRecording::Request &req, +bool DataBagger::EnableDelayedRecordingService(ff_msgs::EnableRecording::Request &req, ff_msgs::EnableRecording::Response &res) { // Check if we are starting a recording or stopping a recording if (req.enable) {