motion_planning_frame.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2012, Willow Garage, Inc.
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions are met:
00007  *
00008  *     * Redistributions of source code must retain the above copyright
00009  *       notice, this list of conditions and the following disclaimer.
00010  *     * Redistributions in binary form must reproduce the above copyright
00011  *       notice, this list of conditions and the following disclaimer in the
00012  *       documentation and/or other materials provided with the distribution.
00013  *     * Neither the name of the Willow Garage, Inc. nor the names of its
00014  *       contributors may be used to endorse or promote products derived from
00015  *       this software without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00018  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00019  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00020  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00021  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00022  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00023  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00024  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00025  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00026  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00027  * POSSIBILITY OF SUCH DAMAGE.
00028  */
00029 
00030 /* Author: Ioan Sucan */
00031 
00032 #ifndef MOVEIT_MOTION_PLANNING_RVIZ_PLUGIN_MOTION_PLANNING_FRAME_
00033 #define MOVEIT_MOTION_PLANNING_RVIZ_PLUGIN_MOTION_PLANNING_FRAME_
00034 
00035 #include <QWidget>
00036 #include <QTreeWidgetItem>
00037 #include <QListWidgetItem>
00038 
00039 #ifndef Q_MOC_RUN
00040 #include <moveit/move_group_interface/move_group.h>
00041 #include <moveit/planning_scene_monitor/planning_scene_monitor.h>
00042 #include <moveit/robot_interaction/robot_interaction.h>
00043 #include <interactive_markers/interactive_marker_server.h>
00044 #include <rviz/default_plugin/interactive_markers/interactive_marker.h>
00045 #endif
00046 
00047 #include <moveit_msgs/MotionPlanRequest.h>
00048 #include <map>
00049 #include <string>
00050 
00051 namespace rviz
00052 {
00053 class DisplayContext;
00054 }
00055 
00056 namespace Ui
00057 {
00058 class MotionPlanningUI;
00059 }
00060 
00061 namespace moveit_warehouse
00062 {
00063 class PlanningSceneStorage;
00064 class ConstraintsStorage;
00065 class RobotStateStorage;
00066 }
00067 
00068 namespace moveit_rviz_plugin
00069 {
00070 class MotionPlanningDisplay;
00071 
00072 class MotionPlanningFrame : public QWidget
00073 {
00074   friend class MotionPlanningDisplay;
00075   Q_OBJECT
00076 
00077 public:
00078   MotionPlanningFrame(MotionPlanningDisplay *pdisplay, rviz::DisplayContext *context, QWidget *parent = 0);
00079   ~MotionPlanningFrame();
00080 
00081   void changePlanningGroup();
00082   void enable();
00083   void disable();
00084   void sceneUpdate(planning_scene_monitor::PlanningSceneMonitor::SceneUpdateType update_type);
00085 
00086 protected:
00087   static const int ITEM_TYPE_SCENE = 1;
00088   static const int ITEM_TYPE_QUERY = 2;
00089 
00090   void constructPlanningRequest(moveit_msgs::MotionPlanRequest &mreq);
00091 
00092   void updateSceneMarkers(float wall_dt, float ros_dt);
00093 
00094   MotionPlanningDisplay *planning_display_;
00095   rviz::DisplayContext* context_;
00096   Ui::MotionPlanningUI *ui_;
00097 
00098   boost::shared_ptr<moveit::planning_interface::MoveGroup> move_group_;
00099 
00100   boost::shared_ptr<moveit::planning_interface::MoveGroup::Plan> current_plan_;
00101   boost::shared_ptr<moveit_warehouse::PlanningSceneStorage> planning_scene_storage_;
00102   boost::shared_ptr<moveit_warehouse::ConstraintsStorage> constraints_storage_;
00103   boost::shared_ptr<moveit_warehouse::RobotStateStorage> robot_state_storage_;
00104 
00105   boost::shared_ptr<rviz::InteractiveMarker> scene_marker_;
00106 
00107   typedef std::map<std::string, moveit_msgs::RobotState> RobotStateMap;
00108   typedef std::pair<std::string, moveit_msgs::RobotState> RobotStatePair;
00109   RobotStateMap robot_states_;
00110 
00111 private Q_SLOTS:
00112 
00113   //Context tab
00114   void databaseConnectButtonClicked();
00115   void publishSceneButtonClicked();
00116   void planningAlgorithmIndexChanged(int index);
00117   void resetDbButtonClicked();
00118   void approximateIKChanged(int state);
00119   
00120   //Planning tab
00121   void planButtonClicked();
00122   void executeButtonClicked();
00123   void planAndExecuteButtonClicked();
00124   void allowReplanningToggled(bool checked);
00125   void allowLookingToggled(bool checked);
00126   void pathConstraintsIndexChanged(int index);
00127   void useStartStateButtonClicked();
00128   void useGoalStateButtonClicked();
00129 
00130   //Scene Objects tab
00131   void importFileButtonClicked();
00132   void importUrlButtonClicked();
00133   void clearSceneButtonClicked();
00134   void sceneScaleChanged(int value);
00135   void sceneScaleStartChange();
00136   void sceneScaleEndChange();
00137   void removeObjectButtonClicked();
00138   void selectedCollisionObjectChanged();
00139   void objectPoseValueChanged(double value);
00140   void collisionObjectChanged(QListWidgetItem *item);
00141   void imProcessFeedback(visualization_msgs::InteractiveMarkerFeedback &feedback);
00142   void copySelectedCollisionObject();
00143   void exportAsTextButtonClicked();
00144   void importFromTextButtonClicked();
00145 
00146   //Stored scenes tab
00147   void saveSceneButtonClicked();
00148   void planningSceneItemClicked();
00149   void saveQueryButtonClicked();
00150   void deleteSceneButtonClicked();
00151   void deleteQueryButtonClicked();
00152   void loadSceneButtonClicked();
00153   void loadQueryButtonClicked();
00154   void warehouseItemNameChanged(QTreeWidgetItem *item, int column);
00155 
00156   //States tab
00157   void loadStateButtonClicked();
00158   void saveStartStateButtonClicked();
00159   void saveGoalStateButtonClicked();
00160   void removeStateButtonClicked();
00161   void clearStatesButtonClicked();
00162   void setAsStartStateButtonClicked();
00163   void setAsGoalStateButtonClicked();
00164 
00165   //General
00166   void tabChanged(int index);
00167 
00168 private:
00169 
00170   //Context tab
00171   void computeDatabaseConnectButtonClicked();
00172   void computeDatabaseConnectButtonClickedHelper(int mode);
00173   void computeResetDbButtonClicked(const std::string &db);
00174   void populatePlannersList(const moveit_msgs::PlannerInterfaceDescription &desc);
00175 
00176   //Planning tab
00177   void computePlanButtonClicked();
00178   void computeExecuteButtonClicked();
00179   void computePlanAndExecuteButtonClicked();
00180   void computePlanAndExecuteButtonClickedDisplayHelper();
00181   void populateConstraintsList();
00182   void populateConstraintsList(const std::vector<std::string> &constr);
00183   void configureForPlanning();
00184   void configureWorkspace();
00185   void updateQueryStateHelper(robot_state::RobotState &state, const std::string &v);
00186   void fillStateSelectionOptions();
00187 
00188   //Scene objects tab
00189   void addObject(const collision_detection::WorldPtr &world, const std::string &id,
00190                  const shapes::ShapeConstPtr &shape, const Eigen::Affine3d &pose);
00191   void updateCollisionObjectPose(bool update_marker_position);
00192   void createSceneInteractiveMarker();
00193   void renameCollisionObject(QListWidgetItem *item);
00194   void attachDetachCollisionObject(QListWidgetItem *item);
00195   void populateCollisionObjectsList();
00196   void computeImportFromText(const std::string &path);
00197   void computeExportAsText(const std::string &path);
00198 
00199   //Stored scenes tab
00200   void computeSaveSceneButtonClicked();
00201   void computeSaveQueryButtonClicked(const std::string &scene, const std::string &query_name);
00202   void computeLoadSceneButtonClicked();
00203   void computeLoadQueryButtonClicked();
00204   void populatePlanningSceneTreeView();
00205   void computeDeleteSceneButtonClicked();
00206   void computeDeleteQueryButtonClicked();
00207   void computeDeleteQueryButtonClickedHelper(QTreeWidgetItem *s);
00208   void checkPlanningSceneTreeEnabledButtons();
00209 
00210 
00211   //States tab
00212   void saveRobotStateButtonClicked(const robot_state::RobotState &state);
00213   void populateRobotStatesList();
00214 
00215   //General
00216   void changePlanningGroupHelper();
00217   void importResource(const std::string &path);
00218 
00219 
00220   /* Selects or unselects a item in a list by the item name */
00221   void setItemSelectionInList(const std::string &item_name, bool selection, QListWidget *list);
00222 
00223   ros::NodeHandle nh_;
00224   ros::Publisher planning_scene_publisher_;
00225   ros::Publisher planning_scene_world_publisher_;
00226 
00227   collision_detection::CollisionWorld::ObjectConstPtr scaled_object_;
00228 
00229   std::vector< std::pair<std::string, bool> > known_collision_objects_;
00230   long unsigned int known_collision_objects_version_;
00231   bool first_time_;
00232 
00233 };
00234 
00235 }
00236 
00237 #endif


visualization
Author(s): Ioan Sucan , Dave Coleman
autogenerated on Mon Oct 6 2014 02:34:03