38 #include <QApplication>
39 #include <QFileDialog>
41 #include <QHBoxLayout>
44 #include <QMessageBox>
45 #include <QProgressBar>
46 #include <QPushButton>
50 #include <QVBoxLayout>
61 #include <boost/filesystem/path.hpp>
62 #include <boost/filesystem/operations.hpp>
76 namespace fs = boost::filesystem;
85 QVBoxLayout* layout =
new QVBoxLayout(
this);
88 QHBoxLayout* hlayout =
new QHBoxLayout();
90 QVBoxLayout* left_layout =
new QVBoxLayout();
92 QVBoxLayout* right_layout =
new QVBoxLayout();
95 right_image_ =
new QImage();
96 right_image_label_ =
new QLabel(
this);
97 std::string image_path =
"./resources/MoveIt_Setup_Assistant2.png";
98 if (chdir(
config_data_->setup_assistant_path_.c_str()) != 0)
100 ROS_ERROR(
"FAILED TO CHANGE PACKAGE TO moveit_setup_assistant");
103 if (right_image_->load(image_path.c_str()))
105 right_image_label_->setPixmap(QPixmap::fromImage(*right_image_));
106 right_image_label_->setMinimumHeight(384);
113 right_layout->addWidget(right_image_label_);
114 right_layout->setAlignment(right_image_label_, Qt::AlignRight | Qt::AlignTop);
118 "These tools will assist you in creating a Semantic Robot "
119 "Description Format (SRDF) file, various yaml configuration and many "
120 "roslaunch files for utilizing all aspects of MoveIt functionality.",
122 layout->addWidget(header);
126 connect(select_mode_->btn_new_, SIGNAL(clicked()),
this, SLOT(showNewOptions()));
127 connect(select_mode_->btn_exist_, SIGNAL(clicked()),
this, SLOT(showExistingOptions()));
128 left_layout->addWidget(select_mode_);
135 "Specify the package name or path of an existing MoveIt configuration package to be "
136 "edited for your robot. Example package name: <i>panda_moveit_config</i>",
137 "optional xacro arguments:",
this,
true);
140 stack_path_->setArgs(
"");
141 connect(stack_path_, SIGNAL(pathChanged(QString)),
this, SLOT(onPackagePathChanged(QString)));
142 left_layout->addWidget(stack_path_);
146 "Specify the location of an existing Universal Robot Description Format or "
147 "COLLADA file for your robot",
148 "optional xacro arguments:",
this,
false,
true);
151 urdf_file_->setArgs(
"");
152 connect(urdf_file_, SIGNAL(pathChanged(QString)),
this, SLOT(onUrdfPathChanged(QString)));
153 left_layout->addWidget(urdf_file_);
156 QHBoxLayout* load_files_layout =
new QHBoxLayout();
158 progress_bar_ =
new QProgressBar(
this);
159 progress_bar_->setMaximum(100);
160 progress_bar_->setMinimum(0);
161 progress_bar_->hide();
162 load_files_layout->addWidget(progress_bar_);
164 btn_load_ =
new QPushButton(
"&Load Files",
this);
165 btn_load_->setMinimumWidth(180);
166 btn_load_->setMinimumHeight(40);
168 load_files_layout->addWidget(btn_load_);
169 load_files_layout->setAlignment(btn_load_, Qt::AlignRight);
170 connect(btn_load_, SIGNAL(clicked()),
this, SLOT(loadFilesClick()));
173 next_label_ =
new QLabel(
this);
174 QFont next_label_font(QFont().defaultFamily(), 11, QFont::Bold);
175 next_label_->setFont(next_label_font);
176 next_label_->setText(
"Success! Use the left navigation pane to continue.");
181 layout->setAlignment(Qt::AlignTop);
182 hlayout->setAlignment(Qt::AlignTop);
183 left_layout->setAlignment(Qt::AlignTop);
184 right_layout->setAlignment(Qt::AlignTop);
187 left_layout->setSpacing(10);
190 hlayout->addLayout(left_layout);
191 hlayout->addLayout(right_layout);
192 layout->addLayout(hlayout);
195 layout->addItem(
new QSpacerItem(20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding));
198 layout->addWidget(next_label_);
199 layout->setAlignment(next_label_, Qt::AlignRight);
200 layout->addLayout(load_files_layout);
202 this->setLayout(layout);
209 QTimer* update_timer =
new QTimer(
this);
210 update_timer->setSingleShot(
true);
211 connect(update_timer, SIGNAL(timeout()), btn_load_, SLOT(click()));
212 update_timer->start(100);
321 if (package_path_input.empty())
324 QMessageBox::warning(
this,
"Error Loading Files",
"Please specify a configuration package path to load.");
332 QMessageBox::critical(
this,
"Error Loading Files",
"The specified path is not a directory or is not accessable");
336 std::string setup_assistant_path;
339 if (!
config_data_->getSetupAssistantYAMLPath(setup_assistant_path))
342 QMessageBox::warning(
this,
"Incorrect Directory/Package",
344 "The chosen package location exists but was not created using MoveIt Setup Assistant. "
345 "If this is a mistake, provide the missing file: ")
346 .
append(setup_assistant_path.c_str()));
351 if (!
config_data_->inputSetupAssistantYAML(setup_assistant_path))
354 QMessageBox::warning(
this,
"Setup Assistant File Error",
355 QString(
"Unable to correctly parse the setup assistant configuration file: ")
356 .
append(setup_assistant_path.c_str()));
369 QApplication::processEvents();
376 QApplication::processEvents();
395 QApplication::processEvents();
403 QApplication::processEvents();
409 fs::path kinematics_yaml_path =
config_data_->config_pkg_path_;
410 kinematics_yaml_path /=
"config/kinematics.yaml";
412 if (!
config_data_->inputKinematicsYAML(kinematics_yaml_path.make_preferred().string()))
414 QMessageBox::warning(
this,
"No Kinematic YAML File",
415 QString(
"Failed to parse kinematics yaml file. This file is not critical but any previous "
416 "kinematic solver settings have been lost. To re-populate this file edit each "
417 "existing planning group and choose a solver, then save each change. \n\nFile error "
419 .
append(kinematics_yaml_path.make_preferred().string().c_str()));
423 fs::path planning_context_launch_path =
config_data_->config_pkg_path_;
424 planning_context_launch_path /=
"launch/planning_context.launch";
425 config_data_->inputPlanningContextLaunch(planning_context_launch_path.make_preferred().string());
432 fs::path ros_controllers_yaml_path =
config_data_->config_pkg_path_;
433 ros_controllers_yaml_path /=
"config/ros_controllers.yaml";
434 config_data_->inputROSControllersYAML(ros_controllers_yaml_path.make_preferred().string());
436 fs::path ompl_yaml_path =
config_data_->config_pkg_path_;
437 ompl_yaml_path /=
"config/ompl_planning.yaml";
438 config_data_->inputOMPLYAML(ompl_yaml_path.make_preferred().string());
447 QApplication::processEvents();
454 QApplication::processEvents();
458 ROS_INFO(
"Loading Setup Assistant Complete");
473 QMessageBox::warning(
this,
"Error Loading Files",
"No robot model file specified");
480 QMessageBox::warning(
this,
"Error Loading Files",
481 QString(
"Unable to locate the URDF file: ").
append(
config_data_->urdf_path_.c_str()));
493 QApplication::processEvents();
504 QApplication::processEvents();
507 const std::string blank_srdf =
"<?xml version='1.0'?><robot name='" +
config_data_->urdf_model_->getName() +
514 QMessageBox::warning(
this,
"Error Loading Files",
"Failure loading blank SRDF file.");
520 QApplication::processEvents();
529 QApplication::processEvents();
536 QApplication::processEvents();
540 ROS_INFO(
"Loading Setup Assistant Complete");
551 QMessageBox::warning(
this,
"Error Loading Files",
552 QString(
"URDF/COLLADA file not found: ").
append(urdf_file_path.c_str()));
558 QMessageBox::warning(
this,
"Error Loading Files",
"Running xacro failed.\nPlease check console for errors.");
565 QMessageBox::warning(
this,
"Error Loading Files",
"URDF/COLLADA file is not a valid robot model.");
575 while (!nh.
ok() && steps < 4)
577 ROS_WARN(
"Waiting for node handle");
583 ROS_INFO(
"Setting Param Server with Robot Description");
595 std::string srdf_string;
598 QMessageBox::warning(
this,
"Error Loading Files", QString(
"SRDF file not found: ").
append(srdf_file_path.c_str()));
614 QMessageBox::warning(
this,
"Error Loading Files",
"SRDF file not a valid semantic robot description model.");
622 while (!nh.
ok() && steps < 4)
624 ROS_WARN(
"Waiting for node handle");
630 ROS_INFO(
"Setting Param Server with Robot Semantic Description");
631 nh.
setParam(
"/robot_description_semantic", srdf_string);
644 std::string relative_path;
645 std::string package_name;
647 bool package_found =
config_data_->extractPackageNameFromPath(
config_data_->urdf_path_, package_name, relative_path);
661 if (robot_desc_pkg_path.empty())
663 QMessageBox::warning(
this,
"Package Not Found In ROS Workspace",
664 QString(
"ROS was unable to find the package name '")
665 .
append(package_name.c_str())
666 .append(
"' within the ROS workspace. This may cause issues later."));
689 QMessageBox::warning(
this,
"Error Loading Files",
690 QString(
"ROS was unable to find the package name '")
692 .append(
"'. Verify this package is inside your ROS "
693 "workspace and is a proper ROS package."));
697 QMessageBox::warning(
this,
"Error Loading Files",
698 QString(
"Unable to locate the URDF file in package. Expected File: \n")
707 ROS_WARN(
"The URDF path is absolute to the filesystem and not relative to a ROS package/stack");
720 QMessageBox::warning(
this,
"Error Loading Files",
721 QString(
"Unable to locate the SRDF file: ").
append(
config_data_->srdf_path_.c_str()));
734 fs::path sensors_3d_yaml_path =
config_data_->config_pkg_path_;
735 sensors_3d_yaml_path /=
"config/sensors_3d.yaml";
737 if (fs::is_regular_file(sensors_3d_yaml_path))
738 config_data_->input3DSensorsYAML(sensors_3d_yaml_path.make_preferred().string());
754 setFrameShape(QFrame::StyledPanel);
755 setFrameShadow(QFrame::Raised);
760 QVBoxLayout* layout =
new QVBoxLayout(
this);
763 QHBoxLayout* hlayout =
new QHBoxLayout();
766 QLabel* widget_title =
new QLabel(
this);
767 widget_title->setText(
"Create new or edit existing?");
768 QFont widget_title_font(QFont().defaultFamily(), 12, QFont::Bold);
769 widget_title->setFont(widget_title_font);
770 layout->addWidget(widget_title);
771 layout->setAlignment(widget_title, Qt::AlignTop);
774 widget_instructions_ =
new QLabel(
this);
775 widget_instructions_->setAlignment(Qt::AlignLeft | Qt::AlignTop);
776 widget_instructions_->setWordWrap(
true);
777 widget_instructions_->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
778 widget_instructions_->setText(
779 "All settings for MoveIt are stored in the MoveIt configuration package. Here you have "
780 "the option to create a new configuration package or load an existing one. Note: "
781 "changes to a MoveIt configuration package outside this Setup Assistant are likely to be "
782 "overwritten by this tool.");
784 layout->addWidget(widget_instructions_);
785 layout->setAlignment(widget_instructions_, Qt::AlignTop);
788 btn_new_ =
new QPushButton(
this);
789 btn_new_->setText(
"Create &New MoveIt\nConfiguration Package");
790 hlayout->addWidget(btn_new_);
793 btn_exist_ =
new QPushButton(
this);
794 btn_exist_->setText(
"&Edit Existing MoveIt\nConfiguration Package");
795 btn_exist_->setCheckable(
true);
796 hlayout->addWidget(btn_exist_);
799 layout->addLayout(hlayout);
801 btn_new_->setCheckable(
true);