39 #include <moveit_msgs/JointLimits.h> 41 #include <QFormLayout> 42 #include <QMessageBox> 43 #include <QDoubleValidator> 44 #include <QApplication> 47 #include <moveit_msgs/DisplayRobotState.h> 61 QVBoxLayout* layout =
new QVBoxLayout();
66 "Define Robot Poses",
"Create poses for the robot. Poses are defined as sets of joint values for " 67 "particular planning groups. This is useful for things like <i>home position</i>.",
69 layout->addWidget(header);
81 QWidget* stacked_layout_widget =
new QWidget(
this);
84 layout->addWidget(stacked_layout_widget);
87 this->setLayout(layout);
96 config_data_->getPlanningScene()->setName(
"MoveIt! Planning Scene");
113 QWidget* content_widget =
new QWidget(
this);
116 QVBoxLayout* layout =
new QVBoxLayout(
this);
123 data_table_->setSelectionBehavior(QAbstractItemView::SelectRows);
129 QStringList header_list;
130 header_list.append(
"Pose Name");
131 header_list.append(
"Group Name");
132 data_table_->setHorizontalHeaderLabels(header_list);
136 QHBoxLayout* controls_layout =
new QHBoxLayout();
139 QPushButton* btn_default =
new QPushButton(
"&Show Default Pose",
this);
140 btn_default->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
141 btn_default->setMaximumWidth(300);
142 connect(btn_default, SIGNAL(clicked()),
this, SLOT(
showDefaultPose()));
143 controls_layout->addWidget(btn_default);
144 controls_layout->setAlignment(btn_default, Qt::AlignLeft);
147 QPushButton* btn_play =
new QPushButton(
"&MoveIt!",
this);
148 btn_play->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
149 btn_play->setMaximumWidth(300);
150 connect(btn_play, SIGNAL(clicked()),
this, SLOT(
playPoses()));
151 controls_layout->addWidget(btn_play);
152 controls_layout->setAlignment(btn_play, Qt::AlignLeft);
155 QWidget* spacer =
new QWidget(
this);
156 spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
157 controls_layout->addWidget(spacer);
160 btn_edit_ =
new QPushButton(
"&Edit Selected",
this);
161 btn_edit_->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
166 controls_layout->setAlignment(
btn_edit_, Qt::AlignRight);
169 btn_delete_ =
new QPushButton(
"&Delete Selected",
this);
172 controls_layout->setAlignment(
btn_delete_, Qt::AlignRight);
175 QPushButton* btn_add =
new QPushButton(
"&Add Pose",
this);
176 btn_add->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
177 btn_add->setMaximumWidth(300);
178 connect(btn_add, SIGNAL(clicked()),
this, SLOT(
showNewScreen()));
179 controls_layout->addWidget(btn_add);
180 controls_layout->setAlignment(btn_add, Qt::AlignRight);
183 layout->addLayout(controls_layout);
186 content_widget->setLayout(layout);
188 return content_widget;
197 QWidget* edit_widget =
new QWidget(
this);
199 QVBoxLayout* layout =
new QVBoxLayout();
203 QHBoxLayout* columns_layout =
new QHBoxLayout();
204 QVBoxLayout* column1 =
new QVBoxLayout();
210 QFormLayout* form_layout =
new QFormLayout();
212 form_layout->setRowWrapPolicy(QFormLayout::WrapAllRows);
228 collision_warning_ =
new QLabel(
"<font color='red'><b>Robot in Collision State</b></font>",
this);
233 column1->addLayout(form_layout);
234 columns_layout->addLayout(column1);
248 columns_layout->addLayout(
column2_);
251 layout->addLayout(columns_layout);
255 QHBoxLayout* controls_layout =
new QHBoxLayout();
256 controls_layout->setContentsMargins(0, 25, 0, 15);
259 QWidget* spacer =
new QWidget(
this);
260 spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
261 controls_layout->addWidget(spacer);
264 QPushButton*
btn_save_ =
new QPushButton(
"&Save",
this);
265 btn_save_->setMaximumWidth(200);
266 connect(btn_save_, SIGNAL(clicked()),
this, SLOT(
doneEditing()));
267 controls_layout->addWidget(btn_save_);
268 controls_layout->setAlignment(btn_save_, Qt::AlignRight);
271 QPushButton*
btn_cancel_ =
new QPushButton(
"&Cancel",
this);
272 btn_cancel_->setMaximumWidth(200);
273 connect(btn_cancel_, SIGNAL(clicked()),
this, SLOT(
cancelEditing()));
274 controls_layout->addWidget(btn_cancel_);
275 controls_layout->setAlignment(btn_cancel_, Qt::AlignRight);
278 layout->addLayout(controls_layout);
281 edit_widget->setLayout(layout);
322 const std::string&
name =
data_table_->item(row, 0)->text().toStdString();
337 for (std::map<std::string, std::vector<double> >::const_iterator value_it = pose->
joint_values_.begin();
360 std::vector<const robot_model::JointModel*> joint_models =
config_data_->getRobotModel()->getJointModels();
363 for (std::vector<const robot_model::JointModel*>::const_iterator joint_it = joint_models.begin();
364 joint_it < joint_models.end(); ++joint_it)
367 if ((*joint_it)->getVariableCount() == 1)
372 (*joint_it)->getVariableDefaultPositions(&init_value);
392 for (std::vector<srdf::Model::GroupState>::iterator pose_it =
config_data_->srdf_->group_states_.begin();
393 pose_it !=
config_data_->srdf_->group_states_.end(); ++pose_it)
398 QApplication::processEvents();
408 const auto& ranges =
data_table_->selectedRanges();
411 edit(ranges[0].bottomRow());
419 const std::string&
name =
data_table_->item(row, 0)->text().toStdString();
433 QMessageBox::critical(
this,
"Error Loading",
"Unable to find group name in drop down box");
439 for (std::map<std::string, std::vector<double> >::const_iterator value_it = pose->
joint_values_.begin();
468 for (std::vector<srdf::Model::Group>::iterator group_it =
config_data_->srdf_->groups_.begin();
469 group_it !=
config_data_->srdf_->groups_.end(); ++group_it)
486 const std::string group_name = selected.toStdString();
489 if (!
config_data_->getRobotModel()->hasJointModelGroup(group_name))
491 QMessageBox::critical(
this,
"Error Loading", QString(
"Unable to find joint model group for group: ")
492 .
append(group_name.c_str())
493 .
append(
" Are you sure this group has associated joints/links?"));
512 const robot_model::JointModelGroup* joint_model_group =
config_data_->getRobotModel()->getJointModelGroup(group_name);
517 for (
const robot_model::JointModel* joint_model :
joint_models_)
519 if (joint_model->getVariableCount() != 1 ||
520 joint_model->isPassive() ||
521 joint_model->getMimic())
531 joint_model->getVariableDefaultPositions(&init_value);
540 joint_list_layout_->addWidget(sw);
543 connect(sw, SIGNAL(jointValueChanged(
const std::string&,
double)),
this,
572 searched_state = &state;
577 return searched_state;
585 const auto& ranges =
data_table_->selectedRanges();
588 int row = ranges[0].bottomRow();
590 const std::string&
name =
data_table_->item(row, 0)->text().toStdString();
594 if (QMessageBox::question(
this,
"Confirm Pose Deletion",
595 QString(
"Are you sure you want to delete the pose '").
append(name.c_str()).
append(
"'?"),
596 QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Cancel)
602 for (std::vector<srdf::Model::GroupState>::iterator pose_it =
config_data_->srdf_->group_states_.begin();
603 pose_it !=
config_data_->srdf_->group_states_.end(); ++pose_it)
606 if (pose_it->name_ == name && pose_it->group_ == group)
633 QMessageBox::warning(
this,
"Error Saving",
"A name must be given for the pose!");
640 QMessageBox::warning(
this,
"Error Saving",
"A planning group must be chosen!");
651 if (QMessageBox::warning(
this,
"Warning Saving",
"A pose already exists with that name! Overwrite?",
652 QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::No)
664 if (searched_data ==
NULL)
671 searched_data->
name_ = name;
672 searched_data->
group_ = group;
680 for (std::vector<const robot_model::JointModel*>::const_iterator joint_it =
joint_models_.begin();
684 if ((*joint_it)->getVariableCount() == 1)
687 std::vector<double> joint_value;
691 searched_data->
joint_values_[(*joint_it)->getName()] = joint_value;
698 config_data_->srdf_->group_states_.push_back(*searched_data);
740 for (std::vector<srdf::Model::GroupState>::const_iterator data_it =
config_data_->srdf_->group_states_.begin();
741 data_it !=
config_data_->srdf_->group_states_.end(); ++data_it)
744 QTableWidgetItem* data_name =
new QTableWidgetItem(data_it->name_.c_str());
745 data_name->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
746 QTableWidgetItem* group_name =
new QTableWidgetItem(data_it->group_.c_str());
747 group_name->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
810 moveit_msgs::DisplayRobotState msg;
811 robot_state::robotStateToRobotStateMsg(
config_data_->getPlanningScene()->getCurrentState(), msg.state);
817 config_data_->getPlanningScene()->getCurrentStateNonConst().update();
844 : QWidget(parent), joint_model_(joint_model)
847 QVBoxLayout* layout =
new QVBoxLayout();
848 QHBoxLayout* row2 =
new QHBoxLayout();
872 const std::vector<moveit_msgs::JointLimits>& limits =
joint_model_->getVariableBoundsMsg();
875 QMessageBox::critical(
this,
"Error Loading",
"An internal error has occured while loading the joints");
880 moveit_msgs::JointLimits joint_limit = limits[0];
892 int value = init_value * 10000;
897 layout->addLayout(row2);
899 this->setContentsMargins(0, 0, 0, 0);
901 this->setGeometry(QRect(110, 80, 120, 80));
902 this->setLayout(layout);
905 qRegisterMetaType<std::string>(
"std::string");
921 const double double_value = double(value) / 10000;
924 joint_value_->setText(QString(
"%1").arg(double_value, 0,
'f', 4));
941 joint_value_->setText(QString(
"%1").arg(value, 0,
'f', 4));
std::map< std::string, std::vector< double > > joint_values_
void publish(const boost::shared_ptr< M > &message) const
static const std::string MOVEIT_ROBOT_STATE
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
std::size_t max_contacts_per_pair
#define ROS_INFO_STREAM(args)
ROSCPP_DECL std::string append(const std::string &left, const std::string &right)