7 #include <QApplication> 8 #include <QProgressDialog> 13 #include <QElapsedTimer> 15 #include "../dialog_select_ros_topics.h" 16 #include "../shape_shifter_factory.hpp" 17 #include "../rule_editing.h" 18 #include "../dialog_with_itemlist.h" 26 void StrCat(
const std::string& a,
const std::string& b, std::string& out)
29 out.reserve(a.size() + b.size());
41 std::vector<std::pair<QString,QString>> all_topics;
46 bool ignoreAll =
false;
50 const auto& topic = conn->topic;
51 const auto& md5sum = conn->md5sum;
52 const auto& datatype = conn->datatype;
53 const auto& definition = conn->msg_def;
55 all_topics.push_back( std::make_pair(QString( topic.c_str()), QString( datatype.c_str()) ) );
61 catch(std::exception &ex)
66 all_topics.pop_back();
75 QMessageBox msgBox(
nullptr);
76 msgBox.setWindowTitle(
"ROS bag error");
77 msgBox.setText(QString(
"Topic ") +
78 QString(topic.c_str()) +
82 QPushButton* buttonCancel = msgBox.addButton(tr(
"Cancel"), QMessageBox::RejectRole);
83 QPushButton* buttonIgnore = msgBox.addButton(tr(
"Ignore"), QMessageBox::YesRole);
84 QPushButton* buttonIgnoreAll = msgBox.addButton(tr(
"Ignore all"), QMessageBox::AcceptRole);
85 msgBox.setDefaultButton(buttonIgnoreAll);
87 if( msgBox.clickedButton() == buttonCancel)
92 if( msgBox.clickedButton() == buttonIgnoreAll)
107 _bag = std::make_shared<rosbag::Bag>();
115 QMessageBox::warning(
nullptr, tr(
"Error"),
116 QString(
"rosbag::open thrown an exception:\n")+
117 QString(ex.what()) );
137 if( dialog->exec() !=
static_cast<int>(QDialog::Accepted) )
155 std::set<std::string> topic_selected;
158 topic_selected.insert( topic.toStdString() );
161 QProgressDialog progress_dialog;
162 progress_dialog.setLabelText(
"Loading... please wait");
163 progress_dialog.setWindowModality( Qt::ApplicationModal );
167 progress_dialog.setRange(0, bag_view.
size()-1);
168 progress_dialog.show();
170 std::vector<uint8_t> buffer;
183 const std::string& topic_name = msg_instance.getTopic();
184 double msg_time = msg_instance.getTime().toSec();
186 plot_consecutive.
pushBack( data_point );
188 const std::string* key_ptr = &topic_name ;
190 auto plot_pair = plot_map.
user_defined.find( *key_ptr );
198 if( msg_count++ %100 == 0)
200 progress_dialog.setValue( msg_count );
201 QApplication::processEvents();
203 if( progress_dialog.wasCanceled() ) {
208 if( topic_selected.find( topic_name ) == topic_selected.end() )
213 const size_t msg_size = msg_instance.size();
214 buffer.resize(msg_size);
217 msg_instance.write(stream);
224 qDebug() <<
"The loading operation took" << timer.elapsed() <<
"milliseconds";
237 QDomElement stamp_elem = doc.createElement(
"use_header_stamp");
239 plugin_elem.appendChild( stamp_elem );
241 QDomElement rename_elem = doc.createElement(
"use_renaming_rules");
243 plugin_elem.appendChild( rename_elem );
245 QDomElement discard_elem = doc.createElement(
"discard_large_arrays");
247 plugin_elem.appendChild( discard_elem );
249 QDomElement max_elem = doc.createElement(
"max_array_size");
251 plugin_elem.appendChild( max_elem );
258 QDomElement stamp_elem = parent_element.firstChildElement(
"use_header_stamp" );
261 QDomElement rename_elem = parent_element.firstChildElement(
"use_renaming_rules" );
264 QDomElement discard_elem = parent_element.firstChildElement(
"discard_large_arrays" );
267 QDomElement max_elem = parent_element.firstChildElement(
"max_array_size" );
std::vector< const char * > _extensions
std::vector< std::pair< QString, QString > > getAndRegisterAllTopics()
void saveDefaultSettings()
static void registerMessage(const std::string &topic_name, const std::string &md5sum, const std::string &datatype, const std::string &definition)
bool discard_large_arrays
std::vector< const ConnectionInfo * > getConnections()
virtual bool xmlLoadState(const QDomElement &parent_element) override
QStringList selected_topics
std::unordered_map< std::string, PlotDataAny >::iterator addUserDefined(const std::string &name)
virtual bool xmlSaveState(QDomDocument &doc, QDomElement &parent_element) const override
std::unordered_map< std::string, PlotDataAny > user_defined
RosMessageParser _ros_parser
void setMaxArrayPolicy(size_t max_array_size, bool discard_entire_array)
void loadDefaultSettings()
void pushMessageRef(const std::string &topic_name, const MessageRef &msg, double timestamp) override
static RosIntrospection::SubstitutionRuleMap getRenamingRules()
void StrCat(const std::string &a, const std::string &b, std::string &out)
virtual void extractData(PlotDataMapRef &destination, const std::string &prefix) override
Configuration getResult() const
ROSTIME_DECL const Time TIME_MAX
virtual ~DataLoadROS() override
QStringList selected_datasources
virtual const std::vector< const char * > & compatibleFileExtensions() const override
ROSTIME_DECL const Time TIME_MIN
std::shared_ptr< rosbag::Bag > _bag
DialogSelectRosTopics::Configuration _config
virtual bool readDataFromFile(FileLoadInfo *fileload_info, PlotDataMapRef &destination) override
void setUseHeaderStamp(bool use)
QDomDocument plugin_config
void addRules(const RosIntrospection::SubstitutionRuleMap &rules)
bool registerSchema(const std::string &topic_name, const std::string &md5sum, RosIntrospection::ROSType type, const std::string &definition)