40 #include <QFormLayout> 41 #include <QMessageBox> 42 #include <QApplication> 53 QVBoxLayout* layout =
new QVBoxLayout();
58 new HeaderWidget(
"Define End Effectors",
"Setup your robot's end effectors. These are planning groups " 59 "corresponding to grippers or tools, attached to a parent " 60 "planning group (an arm). The specified parent link is used as the " 61 "reference frame for IK attempts.",
63 layout->addWidget(header);
76 QWidget* stacked_layout_widget =
new QWidget(
this);
79 layout->addWidget(stacked_layout_widget);
82 this->setLayout(layout);
91 QWidget* content_widget =
new QWidget(
this);
94 QVBoxLayout* layout =
new QVBoxLayout(
this);
101 data_table_->setSelectionBehavior(QAbstractItemView::SelectRows);
107 QStringList header_list;
108 header_list.append(
"End Effector Name");
109 header_list.append(
"Group Name");
110 header_list.append(
"Parent Link");
111 header_list.append(
"Parent Group");
112 data_table_->setHorizontalHeaderLabels(header_list);
116 QHBoxLayout* controls_layout =
new QHBoxLayout();
119 QWidget* spacer =
new QWidget(
this);
120 spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
121 controls_layout->addWidget(spacer);
124 btn_edit_ =
new QPushButton(
"&Edit Selected",
this);
125 btn_edit_->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
130 controls_layout->setAlignment(
btn_edit_, Qt::AlignRight);
133 btn_delete_ =
new QPushButton(
"&Delete Selected",
this);
136 controls_layout->setAlignment(
btn_delete_, Qt::AlignRight);
139 QPushButton* btn_add =
new QPushButton(
"&Add End Effector",
this);
140 btn_add->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
141 btn_add->setMaximumWidth(300);
142 connect(btn_add, SIGNAL(clicked()),
this, SLOT(
showNewScreen()));
143 controls_layout->addWidget(btn_add);
144 controls_layout->setAlignment(btn_add, Qt::AlignRight);
147 layout->addLayout(controls_layout);
150 content_widget->setLayout(layout);
152 return content_widget;
161 QWidget* edit_widget =
new QWidget(
this);
163 QVBoxLayout* layout =
new QVBoxLayout();
166 QFormLayout* form_layout =
new QFormLayout();
168 form_layout->setRowWrapPolicy(QFormLayout::WrapAllRows);
191 layout->addLayout(form_layout);
195 QHBoxLayout* controls_layout =
new QHBoxLayout();
196 controls_layout->setContentsMargins(0, 25, 0, 15);
199 QWidget* spacer =
new QWidget(
this);
200 spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
201 controls_layout->addWidget(spacer);
204 QPushButton*
btn_save_ =
new QPushButton(
"&Save",
this);
205 btn_save_->setMaximumWidth(200);
206 connect(btn_save_, SIGNAL(clicked()),
this, SLOT(
doneEditing()));
207 controls_layout->addWidget(btn_save_);
208 controls_layout->setAlignment(btn_save_, Qt::AlignRight);
211 QPushButton*
btn_cancel_ =
new QPushButton(
"&Cancel",
this);
212 btn_cancel_->setMaximumWidth(200);
213 connect(btn_cancel_, SIGNAL(clicked()),
this, SLOT(
cancelEditing()));
214 controls_layout->addWidget(btn_cancel_);
215 controls_layout->setAlignment(btn_cancel_, Qt::AlignRight);
218 layout->addLayout(controls_layout);
221 edit_widget->setLayout(layout);
261 QList<QTableWidgetItem*> selected =
data_table_->selectedItems();
264 if (!selected.size())
299 QList<QTableWidgetItem*> selected =
data_table_->selectedItems();
302 if (!selected.size())
306 edit(selected[0]->
text().toStdString());
327 QMessageBox::critical(
this,
"Error Loading",
"Unable to find parent link in drop down box");
336 QMessageBox::critical(
this,
"Error Loading",
"Unable to find group name in drop down box");
345 QMessageBox::critical(
this,
"Error Loading",
"Unable to find parent group name in drop down box");
368 for (std::vector<srdf::Model::Group>::iterator group_it =
config_data_->srdf_->groups_.begin();
369 group_it !=
config_data_->srdf_->groups_.end(); ++group_it)
385 std::vector<const robot_model::LinkModel*> link_models =
config_data_->getRobotModel()->getLinkModels();
388 for (std::vector<const robot_model::LinkModel*>::const_iterator link_it = link_models.begin();
389 link_it < link_models.end(); ++link_it)
403 for (std::vector<srdf::Model::EndEffector>::iterator effector_it =
config_data_->srdf_->end_effectors_.begin();
404 effector_it !=
config_data_->srdf_->end_effectors_.end(); ++effector_it)
406 if (effector_it->name_ == name)
408 searched_group = &(*effector_it);
414 if (searched_group ==
NULL)
416 QMessageBox::critical(
this,
"Error Saving",
"An internal error has occured while saving. Quitting.");
417 QApplication::quit();
420 return searched_group;
429 QList<QTableWidgetItem*> selected =
data_table_->selectedItems();
432 if (!selected.size())
439 if (QMessageBox::question(
this,
"Confirm End Effector Deletion",
440 QString(
"Are you sure you want to delete the end effector '")
443 QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Cancel)
449 for (std::vector<srdf::Model::EndEffector>::iterator effector_it =
config_data_->srdf_->end_effectors_.begin();
450 effector_it !=
config_data_->srdf_->end_effectors_.end(); ++effector_it)
477 if (effector_name.empty())
479 QMessageBox::warning(
this,
"Error Saving",
"A name must be specified for the end effector!");
491 for (std::vector<srdf::Model::EndEffector>::const_iterator data_it =
config_data_->srdf_->end_effectors_.begin();
492 data_it !=
config_data_->srdf_->end_effectors_.end(); ++data_it)
494 if (data_it->name_.compare(effector_name) == 0)
497 if (&(*data_it) != searched_data)
499 QMessageBox::warning(
500 this,
"Error Saving",
501 QString(
"An end-effector named '").
append(effector_name.c_str()).
append(
"'already exists!"));
510 QMessageBox::warning(
this,
"Error Saving",
"A group that contains the links of the end-effector must be chosen!");
517 QMessageBox::warning(
this,
"Error Saving",
"A parent link must be chosen!");
521 const robot_model::JointModelGroup* jmg =
538 QMessageBox::warning(
this,
"Error Saving",
539 QString::fromStdString(
"The specified parent group '" +
541 "' must contain the specified parent link '" +
552 if (searched_data ==
NULL)
560 searched_data->
name_ = effector_name;
568 config_data_->srdf_->end_effectors_.push_back(*searched_data);
613 for (std::vector<srdf::Model::EndEffector>::const_iterator data_it =
config_data_->srdf_->end_effectors_.begin();
614 data_it !=
config_data_->srdf_->end_effectors_.end(); ++data_it)
617 QTableWidgetItem* data_name =
new QTableWidgetItem(data_it->name_.c_str());
618 data_name->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
619 QTableWidgetItem* group_name =
new QTableWidgetItem(data_it->component_group_.c_str());
620 group_name->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
621 QTableWidgetItem* parent_name =
new QTableWidgetItem(data_it->parent_link_.c_str());
622 group_name->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
623 QTableWidgetItem* parent_group_name =
new QTableWidgetItem(data_it->parent_group_.c_str());
624 parent_group_name->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
ROSCPP_DECL std::string append(const std::string &left, const std::string &right)
std::string component_group_
std::string parent_group_