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

Prompt user when one or more topics in the rosbag cannot be loaded #183

Merged
merged 1 commit into from
Jun 27, 2019
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
45 changes: 43 additions & 2 deletions plugins/ROS/DataLoadROS/dataload_ros.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <QTextStream>
#include <QFile>
#include <QMessageBox>
#include <QPushButton>
#include <QDebug>
#include <QApplication>
#include <QProgressDialog>
Expand Down Expand Up @@ -42,6 +43,8 @@ std::vector<std::pair<QString,QString>> DataLoadROS::getAndRegisterAllTopics()

RosIntrospectionFactory::reset();

bool ignoreAll = false;

for(auto& conn: bag_view.getConnections() )
{
const auto& topic = conn->topic;
Expand All @@ -50,10 +53,48 @@ std::vector<std::pair<QString,QString>> DataLoadROS::getAndRegisterAllTopics()
const auto& definition = conn->msg_def;

all_topics.push_back( std::make_pair(QString( topic.c_str()), QString( datatype.c_str()) ) );
_ros_parser.registerSchema(
try {
_ros_parser.registerSchema(
topic, md5sum, RosIntrospection::ROSType(datatype), definition);
RosIntrospectionFactory::registerMessage(topic, md5sum, datatype, definition);
}
catch(std::exception &ex)
{
// there was a problem with this topic
// a real life problem example can be found here:
// https://github.com/rosjava/rosjava_bootstrap/issues/16
all_topics.pop_back();

if (ignoreAll) {
// this is not the first error with this load and the
// user has accepted to ignore all errors
continue;
}

RosIntrospectionFactory::registerMessage(topic, md5sum, datatype, definition);
// prompt user to abort or continue
QMessageBox msgBox(nullptr);
msgBox.setWindowTitle("ROS bag error");
msgBox.setText(QString("Topic ") +
QString(topic.c_str()) +
QString(": ") +
QString(ex.what()));

QPushButton* buttonCancel = msgBox.addButton(tr("Cancel"), QMessageBox::RejectRole);
QPushButton* buttonIgnore = msgBox.addButton(tr("Ignore"), QMessageBox::YesRole);
QPushButton* buttonIgnoreAll = msgBox.addButton(tr("Ignore all"), QMessageBox::AcceptRole);
msgBox.setDefaultButton(buttonIgnoreAll);
msgBox.exec();
if( msgBox.clickedButton() == buttonCancel)
{
// abort the file loading
throw;
}
if( msgBox.clickedButton() == buttonIgnoreAll)
{
// accept this and all future errors for this load
ignoreAll = true;
}
}
}
return all_topics;
}
Expand Down