38#include <QApplication>
45#include <QProgressBar>
68 QVBoxLayout* layout =
new QVBoxLayout(
this);
71 QHBoxLayout* hlayout =
new QHBoxLayout();
73 QVBoxLayout* left_layout =
new QVBoxLayout();
75 QVBoxLayout* right_layout =
new QVBoxLayout();
80 auto image_path =
getSharePath(
"moveit_setup_assistant") /
"resources/MoveIt_Setup_Assistant2.png";
89 RCLCPP_ERROR_STREAM(setup_step_.
getLogger(),
"FAILED TO LOAD " << image_path);
97 "MoveIt Setup Assistant",
98 "These tools will assist you in creating a Semantic Robot Description Format (SRDF) file, various yaml "
99 "configuration and many roslaunch files for utilizing all aspects of MoveIt functionality.",
101 layout->addWidget(header);
113 "Specify the package name or path of an existing MoveIt configuration package "
114 "to be edited for your robot. Example package name: <i>panda_moveit_config</i>",
115 "optional xacro arguments:",
this,
true);
119 connect(
stack_path_, SIGNAL(pathChanged(QString)),
this, SLOT(onPackagePathChanged(QString)));
124 "Load a URDF or COLLADA Robot Model",
125 "Specify the location of an existing Universal Robot Description Format or COLLADA file for your robot",
126 "optional xacro arguments:",
this,
false,
true);
130 connect(
urdf_file_, SIGNAL(pathChanged(QString)),
this, SLOT(onUrdfPathChanged(QString)));
134 QHBoxLayout* load_files_layout =
new QHBoxLayout();
142 btn_load_ =
new QPushButton(
"&Load Files",
this);
147 load_files_layout->setAlignment(
btn_load_, Qt::AlignRight);
148 connect(
btn_load_, SIGNAL(clicked()),
this, SLOT(loadFilesClick()));
152 QFont next_label_font(QFont().defaultFamily(), 11, QFont::Bold);
154 next_label_->setText(
"Success! Use the left navigation pane to continue.");
159 layout->setAlignment(Qt::AlignTop);
160 hlayout->setAlignment(Qt::AlignTop);
161 left_layout->setAlignment(Qt::AlignTop);
162 right_layout->setAlignment(Qt::AlignTop);
165 left_layout->setSpacing(10);
168 hlayout->addLayout(left_layout);
169 hlayout->addLayout(right_layout);
170 layout->addLayout(hlayout);
173 layout->addItem(
new QSpacerItem(20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding));
178 layout->addLayout(load_files_layout);
180 setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
188 QTimer* update_timer =
new QTimer(
this);
189 update_timer->setSingleShot(
true);
190 connect(update_timer, SIGNAL(timeout()),
btn_load_, SLOT(click()));
191 update_timer->start(100);
206 if (!pkg_path.empty())
213 std::filesystem::path urdf_path = setup_step_.
getURDFPath();
214 if (!urdf_path.empty())
224void StartScreenWidget::showNewOptions()
235 create_new_package_ =
true;
241void StartScreenWidget::showExistingOptions()
252 create_new_package_ =
false;
258void StartScreenWidget::loadFilesClick()
271 if (create_new_package_)
273 result = loadNewFiles();
277 result = loadExistingFiles();
298void StartScreenWidget::onPackagePathChanged(
const QString& )
300 if (!loadPackageSettings(
false))
306void StartScreenWidget::onUrdfPathChanged(
const QString& path)
313 catch (
const std::runtime_error& e)
315 RCLCPP_ERROR(setup_step_.
getLogger(),
"Error Loading URDF Path. %s", e.what());
316 QMessageBox::warning(
this,
"Error Loading URDF Path", QString(e.what()));
320bool StartScreenWidget::loadPackageSettings(
bool show_warnings)
330 catch (
const std::runtime_error& e)
333 QMessageBox::warning(
this,
"Error Loading Files", e.what());
341bool StartScreenWidget::loadExistingFiles()
347 QApplication::processEvents();
349 if (!loadPackageSettings(
true))
352 catch (
const std::runtime_error& e)
354 RCLCPP_ERROR(setup_step_.
getLogger(),
"Error Loading SRDF. %s", e.what());
355 QMessageBox::warning(
this,
"Error Loading SRDF", QString(e.what()));
361 QApplication::processEvents();
366 RCLCPP_INFO(setup_step_.
getLogger(),
"Loading Setup Assistant Complete");
375bool StartScreenWidget::loadNewFiles()
381 if (urdf_path.empty())
383 QMessageBox::warning(
this,
"Error Loading Files",
"No robot model file specified");
388 if (!std::filesystem::is_regular_file(urdf_path))
390 QMessageBox::warning(
this,
"Error Loading Files",
391 QString(
"Unable to locate the URDF file: ").
append(urdf_path.c_str()));
397 QApplication::processEvents();
405 catch (
const std::runtime_error& e)
407 QMessageBox::warning(
this,
"Error Loading URDF", QString(e.what()));
413 QApplication::processEvents();
422 QApplication::processEvents();
426 QApplication::processEvents();
430 RCLCPP_INFO(setup_step_.
getLogger(),
"Loading Setup Assistant Complete");
446 setFrameShape(QFrame::StyledPanel);
447 setFrameShadow(QFrame::Raised);
452 QVBoxLayout* layout =
new QVBoxLayout(
this);
455 QHBoxLayout* hlayout =
new QHBoxLayout();
458 QLabel* widget_title =
new QLabel(
this);
459 widget_title->setText(
"Create new or edit existing?");
460 QFont widget_title_font(QFont().defaultFamily(), 12, QFont::Bold);
461 widget_title->setFont(widget_title_font);
462 layout->addWidget(widget_title);
463 layout->setAlignment(widget_title, Qt::AlignTop);
471 "All settings for MoveIt are stored in the MoveIt configuration package. Here you have the option to create a "
472 "new configuration package or load an existing one. Note: changes to a MoveIt configuration package outside this "
473 "Setup Assistant are likely to be overwritten by this tool.");
480 btn_new_->setText(
"Create &New MoveIt\nConfiguration Package");
485 btn_exist_->setText(
"&Edit Existing MoveIt\nConfiguration Package");
490 layout->addLayout(hlayout);
498#include <pluginlib/class_list_macros.hpp>
PLUGINLIB_EXPORT_CLASS(cached_ik_kinematics_plugin::CachedIKKinematicsPlugin< kdl_kinematics_plugin::KDLKinematicsPlugin >, kinematics::KinematicsBase)
const rclcpp::Logger & getLogger() const
Makes a namespaced logger for this step available to the widget.
std::filesystem::path getURDFPath()
void loadURDFFile(const std::filesystem::path &urdf_file_path, const std::string &xacro_args)
std::filesystem::path getPackagePath()
std::string getXacroArgs()
void loadExisting(const std::filesystem::path &package_path)
std::filesystem::path getSharePath(const std::string &package_name)
Return a path for the given package's share folder.
std::string append(const std::string &left, const std::string &right)