42 #include <object_recognition_msgs/ObjectRecognitionGoal.h> 44 #include "ui_motion_planning_rviz_plugin_frame.h" 71 std::vector<std::string> objects, object_ids;
72 double min_x =
ui_->roi_center_x->value() -
ui_->roi_size_x->value() / 2.0;
73 double min_y =
ui_->roi_center_y->value() -
ui_->roi_size_y->value() / 2.0;
74 double min_z =
ui_->roi_center_z->value() -
ui_->roi_size_z->value() / 2.0;
76 double max_x =
ui_->roi_center_x->value() +
ui_->roi_size_x->value() / 2.0;
77 double max_y =
ui_->roi_center_y->value() +
ui_->roi_size_y->value() / 2.0;
78 double max_z =
ui_->roi_center_z->value() +
ui_->roi_size_z->value() / 2.0;
88 ROS_DEBUG(
"Found %d objects", (
int)object_ids.size());
94 QList<QListWidgetItem*> sel =
ui_->detected_objects_list->selectedItems();
101 std_msgs::ColorRGBA pick_object_color;
102 pick_object_color.r = 1.0;
103 pick_object_color.g = 0.0;
104 pick_object_color.b = 0.0;
105 pick_object_color.a = 1.0;
131 catch (std::exception& ex)
133 ROS_ERROR(
"Object recognition action: %s", ex.what());
137 object_recognition_msgs::ObjectRecognitionGoal goal;
157 const std::vector<std::string>& objects)
159 ui_->detected_objects_list->setUpdatesEnabled(
false);
160 bool oldState =
ui_->detected_objects_list->blockSignals(
true);
161 ui_->detected_objects_list->clear();
163 for (std::size_t i = 0; i < object_ids.size(); ++i)
165 QListWidgetItem* item =
166 new QListWidgetItem(QString::fromStdString(object_ids[i]),
ui_->detected_objects_list, (
int)i);
167 item->setToolTip(item->text());
168 Qt::ItemFlags flags = item->flags();
169 flags &= ~(Qt::ItemIsUserCheckable);
170 item->setFlags(flags);
171 ui_->detected_objects_list->addItem(item);
174 ui_->detected_objects_list->blockSignals(oldState);
175 ui_->detected_objects_list->setUpdatesEnabled(
true);
176 if (!object_ids.empty())
177 ui_->pick_button->setEnabled(
true);
195 QList<QListWidgetItem*> sel =
ui_->support_surfaces_list->selectedItems();
202 std_msgs::ColorRGBA selected_support_surface_color;
203 selected_support_surface_color.r = 0.0;
204 selected_support_surface_color.g = 0.0;
205 selected_support_surface_color.b = 1.0;
206 selected_support_surface_color.a = 1.0;
219 double min_x =
ui_->roi_center_x->value() -
ui_->roi_size_x->value() / 2.0;
220 double min_y =
ui_->roi_center_y->value() -
ui_->roi_size_y->value() / 2.0;
221 double min_z =
ui_->roi_center_z->value() -
ui_->roi_size_z->value() / 2.0;
223 double max_x =
ui_->roi_center_x->value() +
ui_->roi_size_x->value() / 2.0;
224 double max_y =
ui_->roi_center_y->value() +
ui_->roi_size_y->value() / 2.0;
225 double max_z =
ui_->roi_center_z->value() +
ui_->roi_size_z->value() / 2.0;
226 std::vector<std::string> support_ids =
semantic_world_->getTableNamesInROI(min_x, min_y, min_z, max_x, max_y, max_z);
227 ROS_INFO(
"%d Tables in collision world", (
int)support_ids.size());
229 ui_->support_surfaces_list->setUpdatesEnabled(
false);
230 bool oldState =
ui_->support_surfaces_list->blockSignals(
true);
231 ui_->support_surfaces_list->clear();
233 for (std::size_t i = 0; i < support_ids.size(); ++i)
235 QListWidgetItem* item =
236 new QListWidgetItem(QString::fromStdString(support_ids[i]),
ui_->support_surfaces_list, (
int)i);
237 item->setToolTip(item->text());
238 Qt::ItemFlags flags = item->flags();
239 flags &= ~(Qt::ItemIsUserCheckable);
240 item->setFlags(flags);
241 ui_->support_surfaces_list->addItem(item);
244 ui_->support_surfaces_list->blockSignals(oldState);
245 ui_->support_surfaces_list->setUpdatesEnabled(
true);
251 QList<QListWidgetItem*> sel =
ui_->detected_objects_list->selectedItems();
252 QList<QListWidgetItem*> sel_table =
ui_->support_surfaces_list->selectedItems();
262 if (!sel_table.empty())
268 std::vector<std::string> object_names;
289 QList<QListWidgetItem*> sel_table =
ui_->support_surfaces_list->selectedItems();
292 if (!sel_table.empty())
297 ROS_ERROR(
"Need to specify table to place object on");
301 ui_->pick_button->setEnabled(
false);
302 ui_->place_button->setEnabled(
false);
304 std::vector<const robot_state::AttachedBody*> attached_bodies;
311 const robot_model::JointModelGroup* jmg = ps->getCurrentState().getJointModelGroup(group_name);
313 ps->getCurrentState().getAttachedBodies(attached_bodies, jmg);
315 if (attached_bodies.empty())
321 geometry_msgs::Quaternion upright_orientation;
322 upright_orientation.w = 1.0;
327 upright_orientation, 0.1);
336 ui_->pick_button->setEnabled(
false);
339 ROS_ERROR(
"No pick object set for this group");
348 ui_->place_button->setEnabled(
true);
void listenDetectedObjects(const object_recognition_msgs::RecognizedObjectArrayPtr &msg)
void updateDetectedObjectsList(const std::vector< std::string > &object_ids, const std::vector< std::string > &objects)
planning_scene_monitor::LockedPlanningSceneRW getPlanningSceneRW()
get write access to planning scene
void waitForAction(const T &action, const ros::NodeHandle &node_handle, const ros::Duration &wait_for_server, const std::string &name)
std::string selected_object_name_
std::string place_object_name_
void updateSupportSurfacesList()
void detectObjectsButtonClicked()
void placeObjectButtonClicked()
void detectedObjectChanged(QListWidgetItem *item)
void triggerObjectDetection()
moveit::planning_interface::MoveGroupInterfacePtr move_group_
std::string selected_support_surface_name_
void addBackgroundJob(const boost::function< void()> &job, const std::string &name)
void selectedDetectedObjectChanged()
void visualizePlaceLocations(const std::vector< geometry_msgs::PoseStamped > &place_poses)
std::string getCurrentPlanningGroup() const
#define ROS_WARN_STREAM(args)
MotionPlanningDisplay * planning_display_
Ui::MotionPlanningUI * ui_
const std::string OBJECT_RECOGNITION_ACTION
void addMainLoopJob(const boost::function< void()> &job)
queue the execution of this function for the next time the main update() loop gets called ...
std::string support_surface_name_
#define ROS_INFO_STREAM(args)
void pickObjectButtonClicked()
void processDetectedObjects()
std::vector< geometry_msgs::PoseStamped > place_poses_
std::map< std::string, std::string > pick_object_name_
std::unique_ptr< actionlib::SimpleActionClient< object_recognition_msgs::ObjectRecognitionAction > > object_recognition_client_
void selectedSupportSurfaceChanged()
moveit::planning_interface::PlanningSceneInterfacePtr planning_scene_interface_
planning_scene_monitor::LockedPlanningSceneRO getPlanningSceneRO() const
get read-only access to planning scene
moveit::semantic_world::SemanticWorldPtr semantic_world_