42 #include <rviz_common/display_context.hpp>
43 #include <rviz_common/window_manager_interface.hpp>
45 #include <QMessageBox>
46 #include <QInputDialog>
48 #include "ui_motion_planning_rviz_plugin_frame.h"
52 static const rclcpp::Logger
LOGGER = rclcpp::get_logger(
"moveit_ros_visualization.motion_planning_frame_context");
54 void MotionPlanningFrame::databaseConnectButtonClicked()
59 void MotionPlanningFrame::planningPipelineIndexChanged(
int index)
72 void MotionPlanningFrame::planningAlgorithmIndexChanged(
int index)
74 std::string planner_id =
ui_->planning_algorithm_combo_box->itemText(index).toStdString();
78 ui_->planner_param_treeview->setPlannerId(planner_id);
84 void MotionPlanningFrame::resetDbButtonClicked()
86 if (QMessageBox::warning(
this,
"Data about to be deleted",
87 "The following dialog will allow you to drop a MoveIt "
88 "Warehouse database. Are you sure you want to continue?",
89 QMessageBox::Yes | QMessageBox::No) == QMessageBox::No)
93 dbs.append(
"Planning Scenes");
94 dbs.append(
"Constraints");
95 dbs.append(
"Robot States");
99 QInputDialog::getItem(
this, tr(
"Select Database"), tr(
"Choose the database to reset:"), dbs, 2,
false, &ok);
103 if (QMessageBox::critical(
104 this,
"Data about to be deleted",
105 QString(
"All data in database '").
append(response).
append(
"'. Are you sure you want to continue?"),
106 QMessageBox::Yes | QMessageBox::No) == QMessageBox::No)
113 void MotionPlanningFrame::computeDatabaseConnectButtonClicked()
115 RCLCPP_INFO(LOGGER,
"Connect to database: {host: %s, port: %d}",
ui_->database_host->text().toStdString().c_str(),
116 ui_->database_port->value());
130 conn->setParams(
ui_->database_host->text().toStdString(),
ui_->database_port->value(), 5.0);
143 catch (std::exception& ex)
146 RCLCPP_ERROR(LOGGER,
"%s", ex.what());
153 void MotionPlanningFrame::computeDatabaseConnectButtonClickedHelper(
int mode)
157 ui_->planning_scene_tree->setUpdatesEnabled(
false);
158 ui_->planning_scene_tree->clear();
159 ui_->planning_scene_tree->setUpdatesEnabled(
true);
161 ui_->database_connect_button->setUpdatesEnabled(
false);
162 ui_->database_connect_button->setText(QString::fromStdString(
"Connect"));
163 ui_->database_connect_button->setStyleSheet(
"QPushButton { color : green }");
164 ui_->database_connect_button->setUpdatesEnabled(
true);
165 ui_->reset_db_button->hide();
167 ui_->load_scene_button->setEnabled(
false);
168 ui_->load_query_button->setEnabled(
false);
169 ui_->save_query_button->setEnabled(
false);
170 ui_->save_scene_button->setEnabled(
false);
171 ui_->delete_query_button->setEnabled(
false);
172 ui_->delete_scene_button->setEnabled(
false);
173 populateConstraintsList(std::vector<std::string>());
177 ui_->database_connect_button->setUpdatesEnabled(
false);
178 ui_->database_connect_button->setText(QString::fromStdString(
"Connecting ..."));
179 ui_->database_connect_button->setUpdatesEnabled(
true);
180 populateConstraintsList(std::vector<std::string>());
184 ui_->database_connect_button->setUpdatesEnabled(
false);
185 ui_->database_connect_button->setText(QString::fromStdString(
"Connect"));
186 ui_->database_connect_button->setStyleSheet(
"QPushButton { color : green }");
187 ui_->database_connect_button->setUpdatesEnabled(
true);
188 ui_->reset_db_button->hide();
192 ui_->database_connect_button->setUpdatesEnabled(
false);
193 ui_->database_connect_button->setText(QString::fromStdString(
"Disconnect"));
194 ui_->database_connect_button->setStyleSheet(
"QPushButton { color : darkBlue }");
195 ui_->database_connect_button->setUpdatesEnabled(
true);
196 ui_->save_scene_button->setEnabled(
true);
197 ui_->reset_db_button->show();
198 populatePlanningSceneTreeView();
199 loadStoredStates(
".*");
202 move_group_->setConstraintsDatabase(
ui_->database_host->text().toStdString(),
ui_->database_port->value());
208 void MotionPlanningFrame::computeResetDbButtonClicked(
const std::string& db)
214 else if (db ==
"Planning Scenes")
moveit_warehouse::PlanningSceneStoragePtr planning_scene_storage_
Ui::MotionPlanningUI * ui_
std::vector< moveit_msgs::msg::PlannerInterfaceDescription > planner_descriptions_
moveit_warehouse::ConstraintsStoragePtr constraints_storage_
moveit::planning_interface::MoveGroupInterfacePtr move_group_
MotionPlanningDisplay * planning_display_
moveit_warehouse::RobotStateStoragePtr robot_state_storage_
void addMainLoopJob(const std::function< void()> &job)
queue the execution of this function for the next time the main update() loop gets called
void addBackgroundJob(const std::function< void()> &job, const std::string &name)
warehouse_ros::DatabaseConnection::Ptr loadDatabase(const rclcpp::Node::SharedPtr &node)
Load a database connection.
std::string append(const std::string &left, const std::string &right)
const rclcpp::Logger LOGGER