Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throw BagException when disk is full #1451

Merged
merged 2 commits into from Aug 3, 2018
Merged
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
38 changes: 28 additions & 10 deletions tools/rosbag/src/recorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,13 +196,11 @@ int Recorder::run() {
check_master_timer = nh.createTimer(ros::Duration(1.0), boost::bind(&Recorder::doCheckMaster, this, _1, boost::ref(nh)));
}

ros::MultiThreadedSpinner s(10);
ros::spin(s);

queue_condition_.notify_all();
ros::AsyncSpinner s(10);
s.start();

record_thread.join();

queue_condition_.notify_all();
delete queue_;

return exit_code_;
Expand Down Expand Up @@ -473,7 +471,19 @@ void Recorder::doRecord() {

// Schedule the disk space check
warn_next_ = ros::WallTime();
checkDisk();

try
{
checkDisk();
}
catch (rosbag::BagException &ex)
{
ROS_ERROR_STREAM(ex.what());
exit_code_ = 1;
stopWriting();
return;
}

check_disk_next_ = ros::WallTime::now() + ros::WallDuration().fromSec(20.0);

// Technically the queue_mutex_ should be locked while checking empty.
Expand Down Expand Up @@ -519,8 +529,17 @@ void Recorder::doRecord() {
if (checkDuration(out.time))
break;

if (scheduledCheckDisk() && checkLogging())
bag_.write(out.topic, out.time, *out.msg, out.connection_header);
try
{
if (scheduledCheckDisk() && checkLogging())
bag_.write(out.topic, out.time, *out.msg, out.connection_header);
}
catch (rosbag::BagException &ex)
{
ROS_ERROR_STREAM(ex.what());
exit_code_ = 1;
break;
}
}

stopWriting();
Expand Down Expand Up @@ -674,9 +693,8 @@ bool Recorder::checkDisk() {
}
if ( info.available < options_.min_space)
{
ROS_ERROR("Less than %s of space free on disk with %s. Disabling recording.", options_.min_space_str.c_str(), bag_.getFileName().c_str());
writing_enabled_ = false;
return false;
throw BagException("Less than " + options_.min_space_str + " of space free on disk with " + bag_.getFileName() + ". Disabling recording.");
}
else if (info.available < 5 * options_.min_space)
{
Expand Down