22 #include <QPushButton>
26 #include <QVBoxLayout>
27 #include <QHBoxLayout>
41 SlamToolboxPlugin::SlamToolboxPlugin(QWidget* parent):
48 bool paused_measure =
false, interactive =
false;
49 nh.
getParam(
"/slam_toolbox/paused_new_measurements", paused_measure);
50 nh.
getParam(
"/slam_toolbox/interactive_mode", interactive);
64 _vbox =
new QVBoxLayout();
65 _hbox1 =
new QHBoxLayout();
66 _hbox2 =
new QHBoxLayout();
67 _hbox3 =
new QHBoxLayout();
68 _hbox4 =
new QHBoxLayout();
69 _hbox5 =
new QHBoxLayout();
70 _hbox6 =
new QHBoxLayout();
71 _hbox7 =
new QHBoxLayout();
72 _hbox8 =
new QHBoxLayout();
73 _hbox9 =
new QHBoxLayout();
76 QFrame*
_line =
new QFrame();
77 _line->setFrameShape(QFrame::HLine);
78 _line->setFrameShadow(QFrame::Sunken);
90 _button4->setText(
"Clear Measurement Queue");
102 _button8->setText(
"Deserialize Map");
106 _label1->setText(
"Interactive Mode");
108 _label2->setText(
"Accept New Scans");
110 _label4->setText(
"Merge Map Tool");
111 _label4->setAlignment(Qt::AlignCenter);
113 _label5->setText(
"Create Map Tool");
114 _label5->setAlignment(Qt::AlignCenter);
117 _label6->setAlignment(Qt::AlignCenter);
120 _label7->setAlignment(Qt::AlignCenter);
123 _label8->setAlignment(Qt::AlignCenter);
126 _check1->setChecked(interactive);
129 _check2->setChecked(!paused_measure);
131 _radio1 =
new QRadioButton(tr(
"Start At Dock"));
133 _radio2 =
new QRadioButton(tr(
"Start At Pose Est."));
134 _radio3 =
new QRadioButton(tr(
"Start At Curr. Odom"));
135 _radio4 =
new QRadioButton(tr(
"Localize"));
150 _button1->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
151 _button2->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
152 _button3->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
153 _button4->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
154 _button5->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
155 _button6->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
156 _button7->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
157 _button8->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
158 _check1->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
159 _check2->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
160 _line1->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
161 _line2->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
162 _line3->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
163 _line4->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
164 _line5->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
165 _line6->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
166 _line7->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
239 ROS_INFO(
"Setting initial pose from rviz; you can now deserialize a map given that pose.");
241 _line5->setText(QString::number(msg->pose.pose.position.x,
'f', 2));
242 _line6->setText(QString::number(msg->pose.pose.position.y,
'f', 2));
244 msg->pose.pose.orientation.x,
245 msg->pose.pose.orientation.y,
246 msg->pose.pose.orientation.z,
247 msg->pose.pose.orientation.w);
249 double roll, pitch, yaw;
250 m.
getRPY(roll, pitch, yaw);
251 _line7->setText(QString::number(yaw,
'f', 2));
258 slam_toolbox_msgs::SerializePoseGraph msg;
259 msg.request.filename =
_line3->text().toStdString();
262 ROS_WARN(
"SlamToolbox: Failed to serialize pose graph to file, is service running?");
270 typedef slam_toolbox_msgs::DeserializePoseGraph::Request procType;
272 slam_toolbox_msgs::DeserializePoseGraph msg;
273 msg.request.filename =
_line4->text().toStdString();
276 msg.request.match_type = procType::START_AT_FIRST_NODE;
282 msg.request.match_type = procType::START_AT_GIVEN_POSE;
283 msg.request.initial_pose.x = std::stod(
_line5->text().toStdString());
284 msg.request.initial_pose.y = std::stod(
_line6->text().toStdString());
285 msg.request.initial_pose.theta = std::stod(
_line7->text().toStdString());
287 catch (
const std::invalid_argument& ia)
297 msg.request.match_type = procType::LOCALIZE_AT_POSE;
298 msg.request.initial_pose.x = std::stod(
_line5->text().toStdString());
299 msg.request.initial_pose.y = std::stod(
_line6->text().toStdString());
300 msg.request.initial_pose.theta = std::stod(
_line7->text().toStdString());
302 catch (
const std::invalid_argument& ia)
310 ROS_WARN(
"No match type selected, cannot send request.");
315 ROS_WARN(
"SlamToolbox: Failed to deserialize mapper object "
316 "from file, is service running?");
324 slam_toolbox_msgs::AddSubmap msg;
325 msg.request.filename =
_line2->text().toStdString();
328 ROS_WARN(
"MergeMaps: Failed to load pose graph from file, is service running?");
335 slam_toolbox_msgs::MergeMaps msg;
338 ROS_WARN(
"MergeMaps: Failed to merge maps, is service running?");
346 slam_toolbox_msgs::Clear msg;
349 ROS_WARN(
"SlamToolbox: Failed to clear changes, is service running?");
357 slam_toolbox_msgs::LoopClosure msg;
361 ROS_WARN(
"SlamToolbox: Failed to save changes, is service running?");
369 slam_toolbox_msgs::SaveMap msg;
370 msg.request.name.data =
_line1->text().toStdString();
373 ROS_WARN(
"SlamToolbox: Failed to save map as %s, is service running?",
374 msg.request.name.data.c_str());
382 slam_toolbox_msgs::ClearQueue msg;
385 ROS_WARN(
"Failed to clear queue, is service running?");
393 slam_toolbox_msgs::ToggleInteractive msg;
396 ROS_WARN(
"SlamToolbox: Failed to toggle interactive mode, is service running?");
404 slam_toolbox_msgs::Pause msg;
407 ROS_WARN(
"SlamToolbox: Failed to toggle pause measurements, is service running?");
415 if (
_radio1->isChecked() == Qt::Unchecked)
422 ROS_INFO(
"Processing at first node selected.");
430 if (
_radio2->isChecked() == Qt::Unchecked)
437 ROS_INFO(
"Processing at current pose estimate selected.");
445 if (
_radio3->isChecked() == Qt::Unchecked)
452 ROS_INFO(
"Processing at current odometry selected.");
461 if (
_radio4->isChecked() == Qt::Unchecked)
468 ROS_INFO(
"Processing localization selected.");
479 bool paused_measure =
false, interactive =
false;
482 nh.
getParam(
"/slam_toolbox/paused_new_measurements", paused_measure);
483 nh.
getParam(
"/slam_toolbox/interactive_mode", interactive);
485 bool oldState =
_check1->blockSignals(
true);
486 _check1->setChecked(interactive);
487 _check1->blockSignals(oldState);
489 oldState =
_check2->blockSignals(
true);
490 _check2->setChecked(!paused_measure);
491 _check2->blockSignals(oldState);