9 #include <QListWidgetItem> 12 #include <ui_selection_widget.h> 16 #include <choreo_msgs/ElementNumberRequest.h> 17 #include <choreo_msgs/VisualizeSelectedPath.h> 18 #include <choreo_msgs/QueryComputationRecord.h> 29 if(
"spatial_extrusion" == p_at)
31 at = choreo_gui::SelectionWidget::ASSEMBLY_TYPE::SPATIAL_EXTRUSION;
35 if(
"picknplace" == p_at)
37 at = choreo_gui::SelectionWidget::ASSEMBLY_TYPE::PICKNPLACE;
45 at = choreo_gui::SelectionWidget::ASSEMBLY_TYPE::SPATIAL_EXTRUSION;
57 mode_(PATH_SELECTION),
60 selected_grasp_id_(0),
62 use_saved_result_(false)
65 ui_ =
new Ui::SelectionWidgetWindow;
68 this->setWindowFlags(Qt::WindowStaysOnTopHint);
127 choreo_msgs::ElementNumberRequest srv;
133 srv.request.action = choreo_msgs::ElementNumberRequest::Request::REQUEST_ELEMENT_NUMBER;
138 srv.request.action = choreo_msgs::ElementNumberRequest::Request::REQUEST_SELECTED_TASK_NUMBER;
143 ROS_ERROR_STREAM(
"Unknown element_number parameter loading request in selection widget");
155 if (element_number_param_client.
call(srv))
166 ROS_ERROR_STREAM(
"[Selection Widget] Unable to fetch model's element number!");
171 ui_->slider_select_number->setValue(0);
173 ui_->slider_sim_speed->setValue(1);
175 ui_->lineedit_select_number->setText(QString::number(0));
188 ui_->lineedit_select_number->setValidator(
new QIntValidator(0,
max_value_,
this));
198 ui_->lineedit_select_grasp->setValidator(
new QIntValidator(0,
max_grasp_num_,
this));
228 choreo_msgs::VisualizeSelectedPath srv;
233 srv.request.assembly_type = srv.request.SPATIAL_EXTRUSION;
247 ui_->plan_list_widget->clearSelection();
249 std::vector<int> not_found_index;
250 std::vector<int>::iterator it;
255 std::vector<int>::iterator it =
264 not_found_index.push_back(i);
268 if(0 != not_found_index.size())
270 std::string error_msg = std::to_string(not_found_index.size()) +
" plans not found";
271 ui_->status_bar->setStyleSheet(
"QLabel { color : red; }");
272 ui_->status_bar->setText(QString::fromStdString(error_msg));
289 ui_->lineedit_sim_speed->setText(QString::number(
sim_speed_));
294 std::string::size_type sz;
296 int i_dec = std::stoi(str, &sz);
303 ui_->plan_list_widget->clear();
306 for (
const auto& plan : plan_names)
317 QListWidgetItem *item =
new QListWidgetItem();
318 item->setText(QString::number(
id));
319 ui_->plan_list_widget->addItem(item);
327 QList<QListWidgetItem*> qt_chosen_items =
ui_->plan_list_widget->selectedItems();
329 for(
auto q_item : qt_chosen_items)
343 ui_->status_bar->setStyleSheet(
"QLabel { color : green; }");
347 ui_->status_bar->setStyleSheet(
"QLabel { color : red; }");
350 ui_->status_bar->setText(QString::fromStdString(
string));
357 choreo_msgs::VisualizeSelectedPath srv;
358 srv.request.index = -1;
378 std::string msg =
"Saved task sequence plan record found.";
385 std::string msg =
"No saved task sequence plan record found.";
396 std::string msg =
"Currently we don't support sequence planning for general picknplace.";
419 ui_->pushbutton_select_backward->setEnabled(enabled);
420 ui_->pushbutton_select_forward->setEnabled(enabled);
421 ui_->slider_select_number->setEnabled(enabled);
422 ui_->lineedit_select_number->setEnabled(enabled);
424 ui_->pushbutton_select_for_plan->setEnabled(enabled);
425 ui_->pushbutton_select_all->setEnabled(enabled);
426 ui_->pushbutton_simulate_single->setEnabled(
false);
427 ui_->pushbutton_simulate_until->setEnabled(
false);
435 ui_->pushbutton_close_widget->setEnabled(
false);
438 ui_->tab_widget->setEnabled(enabled);
439 ui_->tab_widget->setTabEnabled(0, enabled);
440 ui_->tab_widget->setTabEnabled(1,
false);
441 ui_->tab_widget->setCurrentIndex(0);
448 ui_->pushbutton_select_backward->setEnabled(enabled);
449 ui_->pushbutton_select_forward->setEnabled(enabled);
450 ui_->slider_select_number->setEnabled(enabled);
451 ui_->lineedit_select_number->setEnabled(enabled);
453 ui_->pushbutton_select_for_plan->setEnabled(
false);
454 ui_->pushbutton_select_all->setEnabled(
false);
455 ui_->pushbutton_simulate_single->setEnabled(
false);
456 ui_->pushbutton_simulate_until->setEnabled(
false);
462 ui_->pushbutton_close_widget->setEnabled(
false);
464 ui_->tab_widget->setEnabled(enabled);
465 ui_->tab_widget->setTabEnabled(0, enabled);
466 ui_->tab_widget->setTabEnabled(1,
false);
467 ui_->tab_widget->setCurrentIndex(0);
472 ui_->pushbutton_select_backward->setEnabled(enabled);
473 ui_->pushbutton_select_forward->setEnabled(enabled);
474 ui_->slider_select_number->setEnabled(enabled);
475 ui_->lineedit_select_number->setEnabled(enabled);
477 ui_->pushbutton_select_for_plan->setEnabled(
false);
478 ui_->pushbutton_select_all->setEnabled(enabled);
479 ui_->pushbutton_simulate_single->setEnabled(enabled);
480 ui_->pushbutton_simulate_until->setEnabled(enabled);
485 ui_->pushbutton_close_widget->setEnabled(
true);
487 ui_->tab_widget->setEnabled(enabled);
488 ui_->tab_widget->setTabEnabled(0,
false);
489 ui_->tab_widget->setTabEnabled(1,
true);
490 ui_->tab_widget->setCurrentIndex(1);
496 ui_->checkbox_visualize_ee->setEnabled(enabled);
501 ui_->slider_select_grasp->setEnabled(enabled);
502 ui_->lineedit_select_grasp->setEnabled(enabled);
507 ui_->slider_select_ik_solution->setEnabled(enabled);
508 ui_->lineedit_select_ik_solution->setEnabled(enabled);
546 case SIMULATE_TYPE::SINGLE:
553 case SIMULATE_TYPE::ALL_UNTIL:
562 case SIMULATE_TYPE::CHOSEN:
592 ui_->plan_list_widget->clearSelection();
619 choreo_msgs::QueryComputationRecord srv;
620 bool saved_record_found =
false;
622 srv.request.action = choreo_msgs::QueryComputationRecordRequest::SAVED_LADDER_GRAPH;
631 saved_record_found = srv.response.record_found;
632 const int found_record_size = srv.response.found_record_size;
635 if(saved_record_found && found_record_size > 0)
637 std::string msg =
"Previous ladder graph record found: 0 - " + std::to_string(found_record_size-1);
644 std::string msg =
"No previous ladder graph record found.";
650 std::string msg =
"Unable to fetch model's element number.";
652 saved_record_found =
false;
ServiceClient serviceClient(const std::string &service_name, bool persistent=false, const M_string &header_values=M_string())
bool call(MReq &req, MRes &res)
bool waitForExistence(ros::Duration timeout=ros::Duration(-1))
#define ROS_WARN_STREAM(args)
#define ROS_ERROR_STREAM(args)