Skip to content

Commit

Permalink
improve documentation and readability + increase split (#394)
Browse files Browse the repository at this point in the history
  • Loading branch information
marinagmoreira authored Jan 12, 2022
1 parent 4a40f5b commit b72c1d7
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 13 deletions.
2 changes: 1 addition & 1 deletion astrobee/config/management/data_bagger.config
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down
20 changes: 16 additions & 4 deletions management/data_bagger/include/data_bagger/data_bagger.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_;
Expand Down
6 changes: 5 additions & 1 deletion management/data_bagger/readme.md
Original file line number Diff line number Diff line change
@@ -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.
14 changes: 7 additions & 7 deletions management/data_bagger/src/data_bagger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand All @@ -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) {
Expand Down

0 comments on commit b72c1d7

Please sign in to comment.