42 #include <QMessageBox> 43 #include <QInputDialog> 45 #include "ui_motion_planning_rviz_plugin_frame.h" 51 ui_->list_states->clear();
54 QListWidgetItem* item =
new QListWidgetItem(QString(it->first.c_str()));
55 ui_->list_states->addItem(item);
66 QInputDialog::getText(
this, tr(
"Robot states to load"), tr(
"Pattern:"), QLineEdit::Normal,
".*", &ok);
67 if (ok && !text.isEmpty())
74 QMessageBox::warning(
this,
"Warning",
"Not connected to a database.");
80 std::vector<std::string> names;
85 catch (std::exception& ex)
87 QMessageBox::warning(
this,
"Cannot query the database",
88 QString(
"Wrongly formatted regular expression for robot states: ").
append(ex.what()));
95 for (std::size_t i = 0; i < names.size(); ++i)
98 bool got_state =
false;
103 catch (std::exception& ex)
126 std::stringstream ss;
130 QString
text = QInputDialog::getText(
this, tr(
"Choose a name"), tr(
"State name:"), QLineEdit::Normal,
131 QString(ss.str().c_str()), &ok);
138 name = text.toStdString();
140 QMessageBox::warning(
141 this,
"Name already exists",
142 QString(
"The name '").append(name.c_str()).
append(
"' already exists. Not creating state."));
146 moveit_msgs::RobotState msg;
147 robot_state::robotStateToRobotStateMsg(state, msg);
157 catch (std::exception& ex)
159 ROS_ERROR(
"Cannot save robot state on the database: %s", ex.what());
164 QMessageBox::warning(
this,
"Warning",
165 "Not connected to a database. The state will be created but not stored");
170 QMessageBox::warning(
this,
"Start state not saved",
"Cannot use an empty name for a new start state.");
187 QListWidgetItem* item =
ui_->list_states->currentItem();
192 robot_state::robotStateMsgToRobotState(
robot_states_[item->text().toStdString()], robot_state);
199 QListWidgetItem* item =
ui_->list_states->currentItem();
204 robot_state::robotStateMsgToRobotState(
robot_states_[item->text().toStdString()], robot_state);
215 msgBox.setText(
"All the selected states will be removed from the database");
216 msgBox.setInformativeText(
"Do you want to continue?");
217 msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel);
218 msgBox.setDefaultButton(QMessageBox::No);
219 int ret = msgBox.exec();
223 case QMessageBox::Yes:
225 QList<QListWidgetItem*> found_items =
ui_->list_states->selectedItems();
226 for (
int i = 0; i < found_items.size(); ++i)
228 const std::string&
name = found_items[i]->text().toStdString();
234 catch (std::exception& ex)
void saveStartStateButtonClicked()
void loadStateButtonClicked()
robot_state::RobotStateConstPtr getQueryStartState() const
void setQueryStartState(const robot_state::RobotState &start)
void saveGoalStateButtonClicked()
void removeStateButtonClicked()
void setQueryGoalState(const robot_state::RobotState &goal)
void loadStoredStates(const std::string &pattern)
void clearStatesButtonClicked()
moveit_warehouse::RobotStateStoragePtr robot_state_storage_
void saveRobotStateButtonClicked(const robot_state::RobotState &state)
void populateRobotStatesList()
robot_state::RobotStateConstPtr getQueryGoalState() const
MotionPlanningDisplay * planning_display_
void setAsStartStateButtonClicked()
Ui::MotionPlanningUI * ui_
const robot_model::RobotModelConstPtr & getRobotModel() const
std::pair< std::string, moveit_msgs::RobotState > RobotStatePair
ROSCPP_DECL std::string append(const std::string &left, const std::string &right)
RobotStateMap robot_states_
void setAsGoalStateButtonClicked()