start_screen_widget.cpp
Go to the documentation of this file.
1 /*********************************************************************
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2012, Willow Garage, Inc.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above
14  * copyright notice, this list of conditions and the following
15  * disclaimer in the documentation and/or other materials provided
16  * with the distribution.
17  * * Neither the name of Willow Garage nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  *********************************************************************/
34 
35 /* Author: Dave Coleman */
36 
37 // Qt
38 #include <QApplication>
39 #include <QFileDialog>
40 #include <QFont>
41 #include <QHBoxLayout>
42 #include <QLabel>
43 #include <QLineEdit>
44 #include <QMessageBox>
45 #include <QProgressBar>
46 #include <QPushButton>
47 #include <QString>
48 #include <QTextEdit>
49 #include <QTimer>
50 #include <QVBoxLayout>
51 
52 // ROS
53 #include <ros/package.h> // for getting file path for loadng images
54 // SA
55 #include "header_widget.h" // title and instructions
56 #include "start_screen_widget.h"
57 // C
58 #include <fstream> // for reading in urdf
59 #include <streambuf>
60 // Boost
61 #include <boost/filesystem/path.hpp> // for reading folders/files
62 #include <boost/filesystem/operations.hpp> // for reading folders/files
63 // MoveIt
65 
66 // chdir
67 #ifdef _WIN32
68 #include <direct.h>
69 #else
70 #include <unistd.h>
71 #endif
72 
73 namespace moveit_setup_assistant
74 {
75 // Boost file system
76 namespace fs = boost::filesystem;
77 
78 // ******************************************************************************************
79 // Start screen user interface for MoveIt Configuration Assistant
80 // ******************************************************************************************
81 StartScreenWidget::StartScreenWidget(QWidget* parent, const MoveItConfigDataPtr& config_data)
82  : SetupScreenWidget(parent), config_data_(config_data)
83 {
84  // Basic widget container
85  QVBoxLayout* layout = new QVBoxLayout(this);
86 
87  // Horizontal layout splitter
88  QHBoxLayout* hlayout = new QHBoxLayout();
89  // Left side of screen
90  QVBoxLayout* left_layout = new QVBoxLayout();
91  // Right side of screen
92  QVBoxLayout* right_layout = new QVBoxLayout();
93 
94  // Right Image Area ----------------------------------------------
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)
99  {
100  ROS_ERROR("FAILED TO CHANGE PACKAGE TO moveit_setup_assistant");
101  }
102 
103  if (right_image_->load(image_path.c_str()))
104  {
105  right_image_label_->setPixmap(QPixmap::fromImage(*right_image_));
106  right_image_label_->setMinimumHeight(384); // size of right_image_label_
107  }
108  else
109  {
110  ROS_ERROR_STREAM("FAILED TO LOAD " << image_path);
111  }
112 
113  right_layout->addWidget(right_image_label_);
114  right_layout->setAlignment(right_image_label_, Qt::AlignRight | Qt::AlignTop);
115 
116  // Top Label Area ---------------------------------------------------
117  HeaderWidget* header = new HeaderWidget("MoveIt Setup Assistant",
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.",
121  this);
122  layout->addWidget(header);
123 
124  // Select Mode Area -------------------------------------------------
125  select_mode_ = new SelectModeWidget(this);
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_);
129 
130  // Path Box Area ----------------------------------------------------
131 
132  // Stack Path Dialog
133  stack_path_ =
134  new LoadPathArgsWidget("Load MoveIt Configuration Package",
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); // directory
138  // user needs to select option before this is shown
139  stack_path_->hide();
140  stack_path_->setArgs("");
141  connect(stack_path_, SIGNAL(pathChanged(QString)), this, SLOT(onPackagePathChanged(QString)));
142  left_layout->addWidget(stack_path_);
143 
144  // URDF File Dialog
145  urdf_file_ = new LoadPathArgsWidget("Load a URDF or COLLADA Robot Model",
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); // no directory, load only
149  // user needs to select option before this is shown
150  urdf_file_->hide();
151  urdf_file_->setArgs("");
152  connect(urdf_file_, SIGNAL(pathChanged(QString)), this, SLOT(onUrdfPathChanged(QString)));
153  left_layout->addWidget(urdf_file_);
154 
155  // Load settings box ---------------------------------------------
156  QHBoxLayout* load_files_layout = new QHBoxLayout();
157 
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_);
163 
164  btn_load_ = new QPushButton("&Load Files", this);
165  btn_load_->setMinimumWidth(180);
166  btn_load_->setMinimumHeight(40);
167  btn_load_->hide();
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()));
171 
172  // Next step instructions
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.");
177  next_label_->hide(); // only show once the files have been loaded.
178 
179  // Final Layout Setup ---------------------------------------------
180  // Alignment
181  layout->setAlignment(Qt::AlignTop);
182  hlayout->setAlignment(Qt::AlignTop);
183  left_layout->setAlignment(Qt::AlignTop);
184  right_layout->setAlignment(Qt::AlignTop);
185 
186  // Stretch
187  left_layout->setSpacing(10);
188 
189  // Attach Layouts
190  hlayout->addLayout(left_layout);
191  hlayout->addLayout(right_layout);
192  layout->addLayout(hlayout);
193 
194  // Verticle Spacer
195  layout->addItem(new QSpacerItem(20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding));
196 
197  // Attach bottom layout
198  layout->addWidget(next_label_);
199  layout->setAlignment(next_label_, Qt::AlignRight);
200  layout->addLayout(load_files_layout);
201 
202  this->setLayout(layout);
203 
204  // Debug mode: auto load the configuration file by clicking button after a timeout
205  if (config_data_->debug_)
206  {
207  // select_mode_->btn_exist_->click();
208 
209  QTimer* update_timer = new QTimer(this);
210  update_timer->setSingleShot(true); // only run once
211  connect(update_timer, SIGNAL(timeout()), btn_load_, SLOT(click()));
212  update_timer->start(100);
213  }
214 }
215 
216 // ******************************************************************************************
217 // Destructor
218 // ******************************************************************************************
220 {
221  delete right_image_; // does not have a parent passed to it
222 }
223 
224 // ******************************************************************************************
225 // Show options for creating a new configuration package
226 // ******************************************************************************************
228 {
229  // Do GUI stuff
230  select_mode_->btn_exist_->setChecked(false);
231  select_mode_->btn_new_->setChecked(true);
233  urdf_file_->show();
234  stack_path_->hide();
235  btn_load_->show();
236 
237  // Remember choice
238  create_new_package_ = true;
239 }
240 
241 // ******************************************************************************************
242 // Show options for editing an existing configuration package
243 // ******************************************************************************************
245 {
246  // Do GUI stuff
247  select_mode_->btn_exist_->setChecked(true);
248  select_mode_->btn_new_->setChecked(false);
250  urdf_file_->hide();
251  stack_path_->show();
252  btn_load_->show();
253 
254  // Remember choice
255  create_new_package_ = false;
256 }
257 
258 // ******************************************************************************************
259 // Load files to parameter server - CLICK
260 // ******************************************************************************************
262 {
263  // Disable start screen GUI components from being changed
264  urdf_file_->setDisabled(true);
265  // srdf_file_->setDisabled(true);
266  stack_path_->setDisabled(true);
267  select_mode_->setDisabled(true);
268  btn_load_->setDisabled(true);
269  progress_bar_->show();
270 
271  bool result;
272 
273  // Decide if this is a new config package, or loading an old one
275  {
276  result = loadNewFiles();
277  // Load 3d_sensors config file
279  }
280  else
281  {
282  result = loadExistingFiles();
283  }
284 
285  // Check if there was a failure loading files
286  if (!result)
287  {
288  // Renable components
289  urdf_file_->setDisabled(false);
290  // srdf_file_->setDisabled(false);
291  stack_path_->setDisabled(false);
292  select_mode_->setDisabled(false);
293  btn_load_->setDisabled(false);
294  progress_bar_->hide();
295  }
296  else
297  {
298  // Hide the logo image so that other screens can resize the rviz thing properly
299  right_image_label_->hide();
300  }
301 }
302 
303 void StartScreenWidget::onPackagePathChanged(const QString& /*path*/)
304 {
305  if (!loadPackageSettings(false))
306  return;
307  // set xacro args from loaded settings
308  stack_path_->setArgs(QString::fromStdString(config_data_->xacro_args_));
309 }
310 
311 void StartScreenWidget::onUrdfPathChanged(const QString& path)
312 {
314 }
315 
316 bool StartScreenWidget::loadPackageSettings(bool show_warnings)
317 {
318  // Get the package path
319  std::string package_path_input = stack_path_->getPath();
320  // Check that input is provided
321  if (package_path_input.empty())
322  {
323  if (show_warnings)
324  QMessageBox::warning(this, "Error Loading Files", "Please specify a configuration package path to load.");
325  return false;
326  }
327 
328  // check that the folder exists
329  if (!config_data_->setPackagePath(package_path_input))
330  {
331  if (show_warnings)
332  QMessageBox::critical(this, "Error Loading Files", "The specified path is not a directory or is not accessable");
333  return false;
334  }
335 
336  std::string setup_assistant_path;
337 
338  // Check if the old package is a setup assistant package. If it is not, quit
339  if (!config_data_->getSetupAssistantYAMLPath(setup_assistant_path))
340  {
341  if (show_warnings)
342  QMessageBox::warning(this, "Incorrect Directory/Package",
343  QString(
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()));
347  return false;
348  }
349 
350  // Get setup assistant data
351  if (!config_data_->inputSetupAssistantYAML(setup_assistant_path))
352  {
353  if (show_warnings)
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()));
357  return false;
358  }
359  return true;
360 }
361 
362 // ******************************************************************************************
363 // Load exisiting package files
364 // ******************************************************************************************
366 {
367  // Progress Indicator
368  progress_bar_->setValue(10);
369  QApplication::processEvents();
370 
371  if (!loadPackageSettings(true))
372  return false;
373 
374  // Progress Indicator
375  progress_bar_->setValue(30);
376  QApplication::processEvents();
377 
378  // Get the URDF path using the loaded .setup_assistant data and check it
379  if (!createFullURDFPath())
380  return false; // error occured
381 
382  // use xacro args from GUI
383  config_data_->xacro_args_ = stack_path_->getArgs().toStdString();
384 
385  // Load the URDF
386  if (!loadURDFFile(config_data_->urdf_path_, config_data_->xacro_args_))
387  return false; // error occured
388 
389  // Get the SRDF path using the loaded .setup_assistant data and check it
390  if (!createFullSRDFPath(config_data_->config_pkg_path_))
391  return false; // error occured
392 
393  // Progress Indicator
394  progress_bar_->setValue(50);
395  QApplication::processEvents();
396 
397  // Load the SRDF
398  if (!loadSRDFFile(config_data_->srdf_path_, config_data_->xacro_args_))
399  return false; // error occured
400 
401  // Progress Indicator
402  progress_bar_->setValue(60);
403  QApplication::processEvents();
404 
405  // Load the allowed collision matrix
406  config_data_->loadAllowedCollisionMatrix(*config_data_->srdf_);
407 
408  // Load kinematics yaml file if available --------------------------------------------------
409  fs::path kinematics_yaml_path = config_data_->config_pkg_path_;
410  kinematics_yaml_path /= "config/kinematics.yaml";
411 
412  if (!config_data_->inputKinematicsYAML(kinematics_yaml_path.make_preferred().string()))
413  {
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 "
418  "at location ")
419  .append(kinematics_yaml_path.make_preferred().string().c_str()));
420  }
421  else
422  {
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());
426  }
427 
428  // Load 3d_sensors config file
430 
431  // Load ros_controllers.yaml file if available-----------------------------------------------
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());
435 
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());
439 
440  // DONE LOADING --------------------------------------------------------------------------
441 
442  // Call a function that enables navigation
443  Q_EMIT readyToProgress();
444 
445  // Progress Indicator
446  progress_bar_->setValue(70);
447  QApplication::processEvents();
448 
449  // Load Rviz
450  Q_EMIT loadRviz();
451 
452  // Progress Indicator
453  progress_bar_->setValue(100);
454  QApplication::processEvents();
455 
456  next_label_->show(); // only show once the files have been loaded
457 
458  ROS_INFO("Loading Setup Assistant Complete");
459  return true; // success!
460 }
461 
462 // ******************************************************************************************
463 // Load chosen files for creating new package
464 // ******************************************************************************************
466 {
467  // Get URDF file path
468  config_data_->urdf_path_ = urdf_file_->getPath();
469 
470  // Check that box is filled out
471  if (config_data_->urdf_path_.empty())
472  {
473  QMessageBox::warning(this, "Error Loading Files", "No robot model file specified");
474  return false;
475  }
476 
477  // Check that this file exits
478  if (!fs::is_regular_file(config_data_->urdf_path_))
479  {
480  QMessageBox::warning(this, "Error Loading Files",
481  QString("Unable to locate the URDF file: ").append(config_data_->urdf_path_.c_str()));
482  return false;
483  }
484 
485  // Attempt to get the ROS package from the path
487  {
488  return false; // An error occurred
489  }
490 
491  // Progress Indicator
492  progress_bar_->setValue(20);
493  QApplication::processEvents();
494 
495  // use xacro args from GUI
496  config_data_->xacro_args_ = urdf_file_->getArgs().toStdString();
497 
498  // Load the URDF to the parameter server and check that it is correct format
499  if (!loadURDFFile(config_data_->urdf_path_, config_data_->xacro_args_))
500  return false; // error occurred
501 
502  // Progress Indicator
503  progress_bar_->setValue(50);
504  QApplication::processEvents();
505 
506  // Create blank SRDF file
507  const std::string blank_srdf = "<?xml version='1.0'?><robot name='" + config_data_->urdf_model_->getName() +
508  "'></"
509  "robot>";
510 
511  // Load a blank SRDF file to the parameter server
512  if (!setSRDFFile(blank_srdf))
513  {
514  QMessageBox::warning(this, "Error Loading Files", "Failure loading blank SRDF file.");
515  return false;
516  }
517 
518  // Progress Indicator
519  progress_bar_->setValue(60);
520  QApplication::processEvents();
521 
522  // DONE LOADING --------------------------------------------------------------------------
523 
524  // Call a function that enables navigation
525  Q_EMIT readyToProgress();
526 
527  // Progress Indicator
528  progress_bar_->setValue(70);
529  QApplication::processEvents();
530 
531  // Load Rviz
532  Q_EMIT loadRviz();
533 
534  // Progress Indicator
535  progress_bar_->setValue(100);
536  QApplication::processEvents();
537 
538  next_label_->show(); // only show once the files have been loaded
539 
540  ROS_INFO("Loading Setup Assistant Complete");
541  return true; // success!
542 }
543 
544 // ******************************************************************************************
545 // Load URDF File to Parameter Server
546 // ******************************************************************************************
547 bool StartScreenWidget::loadURDFFile(const std::string& urdf_file_path, const std::string& xacro_args)
548 {
549  if (!rdf_loader::RDFLoader::loadXmlFileToString(config_data_->urdf_string_, urdf_file_path, { xacro_args }))
550  {
551  QMessageBox::warning(this, "Error Loading Files",
552  QString("URDF/COLLADA file not found: ").append(urdf_file_path.c_str()));
553  return false;
554  }
555 
556  if (config_data_->urdf_string_.empty() && rdf_loader::RDFLoader::isXacroFile(urdf_file_path))
557  {
558  QMessageBox::warning(this, "Error Loading Files", "Running xacro failed.\nPlease check console for errors.");
559  return false;
560  }
561 
562  // Verify that file is in correct format / not an XACRO by loading into robot model
563  if (!config_data_->urdf_model_->initString(config_data_->urdf_string_))
564  {
565  QMessageBox::warning(this, "Error Loading Files", "URDF/COLLADA file is not a valid robot model.");
566  return false;
567  }
568  config_data_->urdf_from_xacro_ = rdf_loader::RDFLoader::isXacroFile(urdf_file_path);
569 
570  ROS_INFO_STREAM("Loaded " << config_data_->urdf_model_->getName() << " robot model.");
571 
572  // Load the robot model to the parameter server
573  ros::NodeHandle nh;
574  int steps = 0;
575  while (!nh.ok() && steps < 4)
576  {
577  ROS_WARN("Waiting for node handle");
578  ros::Duration(1).sleep();
579  steps++;
580  ros::spinOnce();
581  }
582 
583  ROS_INFO("Setting Param Server with Robot Description");
584  // ROS_WARN("Ignore the following error message 'Failed to contact master'. This is a known issue.");
585  nh.setParam("/robot_description", config_data_->urdf_string_);
586 
587  return true;
588 }
589 
590 // ******************************************************************************************
591 // Load SRDF File to Parameter Server
592 // ******************************************************************************************
593 bool StartScreenWidget::loadSRDFFile(const std::string& srdf_file_path, const std::string& xacro_args)
594 {
595  std::string srdf_string;
596  if (!rdf_loader::RDFLoader::loadXmlFileToString(srdf_string, srdf_file_path, { xacro_args }))
597  {
598  QMessageBox::warning(this, "Error Loading Files", QString("SRDF file not found: ").append(srdf_file_path.c_str()));
599  return false;
600  }
601 
602  // Put on param server
603  return setSRDFFile(srdf_string);
604 }
605 
606 // ******************************************************************************************
607 // Put SRDF File on Parameter Server
608 // ******************************************************************************************
609 bool StartScreenWidget::setSRDFFile(const std::string& srdf_string)
610 {
611  // Verify that file is in correct format / not an XACRO by loading into robot model
612  if (!config_data_->srdf_->initString(*config_data_->urdf_model_, srdf_string))
613  {
614  QMessageBox::warning(this, "Error Loading Files", "SRDF file not a valid semantic robot description model.");
615  return false;
616  }
617  ROS_INFO_STREAM("Robot semantic model successfully loaded.");
618 
619  // Load to param server
620  ros::NodeHandle nh;
621  int steps = 0;
622  while (!nh.ok() && steps < 4)
623  {
624  ROS_WARN("Waiting for node handle");
626  steps++;
627  ros::spinOnce();
628  }
629 
630  ROS_INFO("Setting Param Server with Robot Semantic Description");
631  nh.setParam("/robot_description_semantic", srdf_string);
632 
633  return true;
634 }
635 
636 // ******************************************************************************************
637 // Extract the package/stack name and relative path to urdf from an absolute path name
638 // Input: cofig_data_->urdf_path_
639 // Output: cofig_data_->urdf_pkg_name_
640 // cofig_data_->urdf_pkg_relative_path_
641 // ******************************************************************************************
643 {
644  std::string relative_path; // holds the path after the sub_path
645  std::string package_name; // result
646 
647  bool package_found = config_data_->extractPackageNameFromPath(config_data_->urdf_path_, package_name, relative_path);
648 
649  // Assign data to moveit_config_data
650  if (!package_found)
651  {
652  // No package name found, we must be outside ROS
653  config_data_->urdf_pkg_name_ = "";
654  config_data_->urdf_pkg_relative_path_ = config_data_->urdf_path_; // just the absolute path
655  }
656  else
657  {
658  // Check that ROS can find the package
659  const std::string robot_desc_pkg_path = ros::package::getPath(package_name);
660 
661  if (robot_desc_pkg_path.empty())
662  {
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."));
667  }
668 
669  // Success
670  config_data_->urdf_pkg_name_ = package_name;
671  config_data_->urdf_pkg_relative_path_ = relative_path;
672  }
673 
674  ROS_DEBUG_STREAM("URDF Package Name: " << config_data_->urdf_pkg_name_);
675  ROS_DEBUG_STREAM("URDF Package Path: " << config_data_->urdf_pkg_relative_path_);
676 
677  return true; // success
678 }
679 
680 // ******************************************************************************************
681 // Make the full URDF path using the loaded .setup_assistant data
682 // ******************************************************************************************
684 {
685  if (!config_data_->createFullURDFPath())
686  {
687  if (config_data_->urdf_path_.empty()) // no path could be resolved
688  {
689  QMessageBox::warning(this, "Error Loading Files",
690  QString("ROS was unable to find the package name '")
691  .append(config_data_->urdf_pkg_name_.c_str())
692  .append("'. Verify this package is inside your ROS "
693  "workspace and is a proper ROS package."));
694  }
695  else
696  {
697  QMessageBox::warning(this, "Error Loading Files",
698  QString("Unable to locate the URDF file in package. Expected File: \n")
699  .append(config_data_->urdf_path_.c_str()));
700  }
701  return false;
702  }
703 
704  // Check if a package name was provided
705  if (config_data_->urdf_pkg_name_.empty())
706  {
707  ROS_WARN("The URDF path is absolute to the filesystem and not relative to a ROS package/stack");
708  }
709 
710  return true; // success
711 }
712 
713 // ******************************************************************************************
714 // Make the full SRDF path using the loaded .setup_assistant data
715 // ******************************************************************************************
716 bool StartScreenWidget::createFullSRDFPath(const std::string& package_path)
717 {
718  if (!config_data_->createFullSRDFPath(package_path))
719  {
720  QMessageBox::warning(this, "Error Loading Files",
721  QString("Unable to locate the SRDF file: ").append(config_data_->srdf_path_.c_str()));
722  return false;
723  }
724 
725  return true; // success
726 }
727 
728 // ******************************************************************************************
729 // Loads sensors_3d yaml file
730 // ******************************************************************************************
732 {
733  // Loads parameters values from sensors_3d yaml file if available
734  fs::path sensors_3d_yaml_path = config_data_->config_pkg_path_;
735  sensors_3d_yaml_path /= "config/sensors_3d.yaml";
736 
737  if (fs::is_regular_file(sensors_3d_yaml_path))
738  config_data_->input3DSensorsYAML(sensors_3d_yaml_path.make_preferred().string());
739  return true;
740 }
741 
742 // ******************************************************************************************
743 // ******************************************************************************************
744 // Class for selecting which mode
745 // ******************************************************************************************
746 // ******************************************************************************************
747 
748 // ******************************************************************************************
749 // Create the widget
750 // ******************************************************************************************
751 SelectModeWidget::SelectModeWidget(QWidget* parent) : QFrame(parent)
752 {
753  // Set frame graphics
754  setFrameShape(QFrame::StyledPanel);
755  setFrameShadow(QFrame::Raised);
756  setLineWidth(1);
757  setMidLineWidth(0);
758 
759  // Basic widget container
760  QVBoxLayout* layout = new QVBoxLayout(this);
761 
762  // Horizontal layout splitter
763  QHBoxLayout* hlayout = new QHBoxLayout();
764 
765  // Widget Title
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);
772 
773  // Widget Instructions
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.");
783 
784  layout->addWidget(widget_instructions_);
785  layout->setAlignment(widget_instructions_, Qt::AlignTop);
786 
787  // New Button
788  btn_new_ = new QPushButton(this);
789  btn_new_->setText("Create &New MoveIt\nConfiguration Package");
790  hlayout->addWidget(btn_new_);
791 
792  // Exist Button
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_);
797 
798  // Add horizontal layer to verticle layer
799  layout->addLayout(hlayout);
800  setLayout(layout);
801  btn_new_->setCheckable(true);
802 }
803 
804 } // namespace moveit_setup_assistant
moveit_setup_assistant::LoadPathArgsWidget::setArgsEnabled
void setArgsEnabled(bool enabled=true)
Definition: header_widget.cpp:261
moveit_setup_assistant::StartScreenWidget::showNewOptions
void showNewOptions()
User has chosen to show new options.
Definition: start_screen_widget.cpp:259
ros::NodeHandle::setParam
void setParam(const std::string &key, bool b) const
start_screen_widget.h
ros::package::getPath
ROSLIB_DECL std::string getPath(const std::string &package_name)
ROS_ERROR_STREAM
#define ROS_ERROR_STREAM(args)
moveit_setup_assistant::LoadPathArgsWidget::setArgs
void setArgs(const QString &args)
Definition: header_widget.cpp:256
moveit_setup_assistant::StartScreenWidget::~StartScreenWidget
~StartScreenWidget() override
Definition: start_screen_widget.cpp:251
moveit_setup_assistant::StartScreenWidget::next_label_
QLabel * next_label_
Definition: start_screen_widget.h:83
rdf_loader.h
moveit_setup_assistant::LoadPathArgsWidget::getArgs
QString getArgs() const
Definition: header_widget.cpp:251
ros::spinOnce
ROSCPP_DECL void spinOnce()
moveit_setup_assistant::StartScreenWidget::setSRDFFile
bool setSRDFFile(const std::string &srdf_string)
Put SRDF File on Parameter Server.
Definition: start_screen_widget.cpp:641
moveit_setup_assistant::StartScreenWidget::readyToProgress
void readyToProgress()
Event that is fired when the start screen has all its requirements completed and user can move on.
moveit_setup_assistant::SelectModeWidget::btn_exist_
QPushButton * btn_exist_
Definition: start_screen_widget.h:185
moveit_setup_assistant::StartScreenWidget::onUrdfPathChanged
void onUrdfPathChanged(const QString &path)
enable xacro arguments
Definition: start_screen_widget.cpp:343
moveit_setup_assistant::SelectModeWidget
Definition: start_screen_widget.h:173
moveit_setup_assistant::StartScreenWidget::loadURDFFile
bool loadURDFFile(const std::string &urdf_file_path, const std::string &xacro_args)
Load URDF File to Parameter Server.
Definition: start_screen_widget.cpp:579
ROS_DEBUG_STREAM
#define ROS_DEBUG_STREAM(args)
moveit_setup_assistant::StartScreenWidget::loadRviz
void loadRviz()
Inform the parent widget to load rviz. This is done so that progress bar can be more accurate.
moveit_setup_assistant::StartScreenWidget::stack_path_
LoadPathArgsWidget * stack_path_
Definition: start_screen_widget.h:80
moveit_setup_assistant::StartScreenWidget::btn_load_
QPushButton * btn_load_
Definition: start_screen_widget.h:82
moveit_setup_assistant::StartScreenWidget::onPackagePathChanged
void onPackagePathChanged(const QString &path)
load package settings
Definition: start_screen_widget.cpp:335
moveit_setup_assistant::SelectModeWidget::widget_instructions_
QLabel * widget_instructions_
Definition: start_screen_widget.h:186
ROS_ERROR
#define ROS_ERROR(...)
moveit_setup_assistant::StartScreenWidget::StartScreenWidget
StartScreenWidget(QWidget *parent, const MoveItConfigDataPtr &config_data)
Start screen user interface for MoveIt Configuration Assistant.
Definition: start_screen_widget.cpp:113
ROS_WARN
#define ROS_WARN(...)
SetupScreenWidget
Definition: setup_screen_widget.h:44
moveit_setup_assistant::LoadPathArgsWidget
Extend LoadPathWidget with additional line edit for arguments.
Definition: header_widget.h:104
rdf_loader::RDFLoader::isXacroFile
static bool isXacroFile(const std::string &path)
moveit_setup_assistant::SelectModeWidget::SelectModeWidget
SelectModeWidget(QWidget *parent)
Definition: start_screen_widget.cpp:783
ROS_INFO_STREAM
#define ROS_INFO_STREAM(args)
moveit_setup_assistant::StartScreenWidget::create_new_package_
bool create_new_package_
Create new config files, or load existing one?
Definition: start_screen_widget.h:130
package.h
moveit_setup_assistant::StartScreenWidget::loadExistingFiles
bool loadExistingFiles()
Load exisiting package files.
Definition: start_screen_widget.cpp:397
moveit_setup_assistant::SimulationWidget::config_data_
moveit_setup_assistant::MoveItConfigDataPtr config_data_
Contains all the configuration data for the setup assistant.
Definition: simulation_widget.h:100
moveit_setup_assistant::StartScreenWidget::showExistingOptions
void showExistingOptions()
User has chosen to show edit options.
Definition: start_screen_widget.cpp:276
moveit_setup_assistant::StartScreenWidget::progress_bar_
QProgressBar * progress_bar_
Definition: start_screen_widget.h:84
header_widget.h
moveit_setup_assistant
Definition: compute_default_collisions.h:46
moveit_setup_assistant::StartScreenWidget::loadSRDFFile
bool loadSRDFFile(const std::string &srdf_file_path, const std::string &xacro_args)
Load SRDF File.
Definition: start_screen_widget.cpp:625
moveit_setup_assistant::StartScreenWidget::right_image_label_
QLabel * right_image_label_
Definition: start_screen_widget.h:86
moveit_setup_assistant::StartScreenWidget::extractPackageNameFromPath
bool extractPackageNameFromPath()
Definition: start_screen_widget.cpp:674
ros::NodeHandle::ok
bool ok() const
moveit_setup_assistant::StartScreenWidget::select_mode_
SelectModeWidget * select_mode_
Definition: start_screen_widget.h:79
moveit_setup_assistant::LoadPathWidget::getPath
std::string getPath() const
Returns the file path in std::string format.
Definition: header_widget.cpp:217
append
ROSCPP_DECL std::string append(const std::string &left, const std::string &right)
moveit_setup_assistant::StartScreenWidget::config_data_
moveit_setup_assistant::MoveItConfigDataPtr config_data_
Contains all the configuration data for the setup assistant.
Definition: start_screen_widget.h:89
moveit_setup_assistant::HeaderWidget
Definition: header_widget.h:51
rdf_loader::RDFLoader::loadXmlFileToString
static bool loadXmlFileToString(std::string &buffer, const std::string &path, const std::vector< std::string > &xacro_args)
moveit_setup_assistant::StartScreenWidget::loadNewFiles
bool loadNewFiles()
Load chosen files for creating new package.
Definition: start_screen_widget.cpp:497
moveit_setup_assistant::StartScreenWidget::loadPackageSettings
bool loadPackageSettings(bool show_warnings)
load package settings from .setup_assistant file
Definition: start_screen_widget.cpp:348
moveit_setup_assistant::StartScreenWidget::urdf_file_
LoadPathArgsWidget * urdf_file_
Definition: start_screen_widget.h:81
moveit_setup_assistant::StartScreenWidget::load3DSensorsFile
bool load3DSensorsFile()
Loads sensors_3d yaml file.
Definition: start_screen_widget.cpp:763
ros::Duration::sleep
bool sleep() const
moveit_setup_assistant::StartScreenWidget::loadFilesClick
void loadFilesClick()
Button event for loading user chosen files.
Definition: start_screen_widget.cpp:293
header
const std::string header
ROS_INFO
#define ROS_INFO(...)
moveit_setup_assistant::StartScreenWidget::createFullSRDFPath
bool createFullSRDFPath(const std::string &package_path)
Make the full SRDF path using the loaded .setup_assistant data.
Definition: start_screen_widget.cpp:748
ros::Duration
moveit_setup_assistant::SelectModeWidget::btn_new_
QPushButton * btn_new_
Definition: start_screen_widget.h:184
moveit_setup_assistant::StartScreenWidget::right_image_
QImage * right_image_
Definition: start_screen_widget.h:85
ros::NodeHandle
moveit_setup_assistant::StartScreenWidget::createFullURDFPath
bool createFullURDFPath()
Make the full URDF path using the loaded .setup_assistant data.
Definition: start_screen_widget.cpp:715


moveit_setup_assistant
Author(s): Dave Coleman
autogenerated on Sat May 3 2025 02:28:05