aws-robotics / rosbag-uploader-ros1

ROS packages for uploading rosbags to AWS cloud services.
Apache License 2.0
30 stars 12 forks source link

Duration Recorder cannot be implemented as an action server (intended for reuse) #75

Open raghaprasad opened 4 years ago

raghaprasad commented 4 years ago

I ran into several roadblocks with duration recorder implementation recently. In light of these discoveries I believe its not possible to proceed as planned for duration recorder to be action server based.

Issue

Duration Recorder cannot be implemented as an action server (intended for reuse)

Root cause

Duration recorder uses rosbag::Recorder for generating the rosbags.

However, rosbag::Recorder has been designed to shutdown after generating the rosbag file.

bool Recorder::checkDuration(const ros::Time& t)
{
    if (options_.max_duration > ros::Duration(0))
    {
        if (t - start_time_ > options_.max_duration)
        {
            if (options_.split)
            {
                while (start_time_ + options_.max_duration < t)
                {
                    stopWriting();
                    split_count_++;
                    checkNumSplits();
                    start_time_ += options_.max_duration;
                    startWriting();
                }
            } else {
                ros::shutdown();
                return true;
            }
        }
    }
    return false;
}

This means any action needed to be taken post creation of the rosbag file, like uploading to s3 or cleaning up the generated files cannot be performed. ros::shutdown is async shutdown of the ros node and therefore any actions invoked after the shutdown are unlikely to succeed.

Callouts & action items

AAlon commented 4 years ago

I would consider implementing our own version of rosbag::recorder:

Doing a POC of copying & renaming that class and building everything together should be really quick, in the order of minutes. If we do that and it goes smoothly it seems to me like the best path forward.

mm318 commented 4 years ago

Additionally, I think changing implementation is less risky than pivoting on the design/architecture of the system.

raghaprasad commented 4 years ago

Additionally, I think changing implementation is less risky than pivoting on the design/architecture of the system.

This might be true is a general context, but certainly not in this case. What we intend to do is to launch duration_recorder as a node instead of an action server.

raghaprasad commented 4 years ago

@AAlon This might actually work! In terms of things needed to be done :

mm318 commented 4 years ago

After some non-trivial modifications to recorder.cpp (fixing cyclical shared_ptr references, increasing NodeHandle lifetimes, etc.), I believe we have a working solution.

EDIT: Please see https://github.com/aws-robotics/rosbag-uploader-ros1/pull/76. Lots of code and CMake file cleanup may be required.

mm318 commented 4 years ago

@raghaprasad and @ryanewel, can you confirm that all that remains of this ticket is to improve code coverage?