00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef INTERACTIVE_MANIPULATION_FRAME
00031 #define INTERACTIVE_MANIPULATION_FRAME
00032
00033 #include "pr2_interactive_manipulation/interactive_manipulation_ui.h"
00034 #include "pr2_interactive_manipulation/object_selection_frame.h"
00035 #include "pr2_interactive_manipulation/advanced_options_dialog.h"
00036 #include "pr2_interactive_manipulation/gripper_controller.h"
00037
00038 #include <boost/thread/thread.hpp>
00039 #include <boost/thread/mutex.hpp>
00040
00041 #include <ros/ros.h>
00042
00043 #include <object_manipulator/tools/mechanism_interface.h>
00044
00045 #include <tabletop_collision_map_processing/collision_map_interface.h>
00046
00047 #include <object_manipulation_msgs/PickupAction.h>
00048 #include <object_manipulation_msgs/PlaceAction.h>
00049
00050 #include <pr2_create_object_model/ModelObjectInHandAction.h>
00051 #include <pr2_create_object_model/ObjectInHand.h>
00052
00053 #include <pr2_interactive_object_detection/GraspableObjectList.h>
00054
00055 #include <sensor_msgs/point_cloud_conversion.h>
00056
00057 namespace pr2_interactive_manipulation {
00058
00059 class InteractiveManipulationDisplay;
00060
00061 class InteractiveManipulationFrame : public InteractiveManipulationFrameBase
00062 {
00063 public:
00064 InteractiveManipulationFrame(InteractiveManipulationDisplay *display, wxWindow *parent,
00065 rviz::VisualizationManager* manager);
00066
00067 ~InteractiveManipulationFrame();
00068
00069 void update();
00070
00071 void setAdvancedGraspOptions(AdvancedGraspOptions ago){ago_ = ago;}
00072
00073 protected:
00074
00075 struct GraspInfo
00076 {
00077 static geometry_msgs::Pose somePose()
00078 {
00079 geometry_msgs::Pose pose;
00080 pose.position.x = -0.08;
00081 pose.position.y = -0.00;
00082 pose.position.z = 0.27;
00083 pose.orientation.x = -0.517361;
00084 pose.orientation.y = 0.417646;
00085 pose.orientation.z = 0.323392;
00086 pose.orientation.w = 0.673295;
00087 return pose;
00088 }
00089
00090 GraspInfo()
00091 {
00092
00093 grasp_.grasp_pose = somePose();
00094 }
00095 std::string object_collision_name_;
00096 object_manipulation_msgs::Grasp grasp_;
00097 sensor_msgs::PointCloud2 object_cluster_;
00098 };
00099
00100 struct DialogOptions
00101 {
00102 bool collision_checked_;
00103 int arm_selection_;
00104 };
00105
00106 virtual void graspButtonClicked( wxCommandEvent& event );
00107
00108 virtual void placeButtonClicked( wxCommandEvent& event );
00109
00110 virtual void cancelButtonClicked( wxCommandEvent& event );
00111
00112 virtual void takeMapButtonClicked( wxCommandEvent& event );
00113
00114 virtual void resetButtonClicked( wxCommandEvent& event );
00115
00116 virtual void armGoButtonClicked( wxCommandEvent& event );
00117
00118 virtual void lookButtonClicked( wxCommandEvent& event );
00119
00120 virtual void collisionBoxClicked( wxCommandEvent& event );
00121
00122 virtual void advancedOptionsClicked( wxCommandEvent& event );
00123
00124 virtual void modelObjectClicked( wxCommandEvent& event);
00125
00126 virtual void gripperSliderScrollChanged( wxScrollEvent& event );
00127
00128 void executeGrasp(DialogOptions options,
00129 AdvancedGraspOptions ago);
00130
00131 void executeRecognizedObjectGrasp(DialogOptions options,
00132 AdvancedGraspOptions ago,
00133 object_manipulation_msgs::GraspableObject object);
00134
00135 void executePlace(DialogOptions options,
00136 AdvancedGraspOptions ago);
00137
00138 void modelObject(DialogOptions options);
00139
00140 void takeMap();
00141
00142 void moveGripper(int arm_selection_choice, double value);
00143
00144 void collisionReset(int reset_choice);
00145
00146 void armMotion(int arm_selection_choice, int arm_action_choice, int arm_planner_choice, bool collision);
00147
00148 void lookAtTable();
00149
00150 void setStatusLabel(std::string text);
00151
00152 DialogOptions getDialogOptions();
00153
00154 void graspableObjectsCallback(const pr2_interactive_object_detection::GraspableObjectListConstPtr &objects);
00155
00156 void modeledObjectsCallback(const pr2_create_object_model::ObjectInHandConstPtr &object);
00157
00158 std::string getGraspableObjectName(const object_manipulation_msgs::GraspableObject &obj);
00159
00160 InteractiveManipulationDisplay *display_;
00161
00162 ObjectSelectionFrame *object_selection_frame_;
00163
00164 ros::ServiceClient grasp_planning_srv_;
00165 ros::ServiceClient place_planning_srv_;
00166 ros::ServiceClient get_model_description_srv_;
00167 ros::Subscriber graspable_objects_sub_;
00168 ros::Subscriber modeled_object_sub_;
00169
00170 ros::NodeHandle root_nh_;
00171
00172 ros::NodeHandle priv_nh_;
00173
00174 boost::thread *executing_thread_;
00175
00176 boost::mutex mutex_;
00177
00178 boost::mutex status_label_mutex_;
00179
00180 boost::mutex object_list_mutex_;
00181
00182 boost::mutex modeled_object_mutex_;
00183
00184 std::string status_label_text_;
00185
00186 bool interrupt_request_;
00187
00188 std::string grasp_planning_service_name_;
00189 std::string place_planning_service_name_;
00190
00191 std::string pickup_action_name_;
00192 std::string place_action_name_;
00193
00194 std::string create_model_action_name_;
00195
00196 tabletop_collision_map_processing::CollisionMapInterface collision_map_interface_;
00197
00198 object_manipulator::MechanismInterface mech_interface_;
00199
00200 GripperController l_gripper_controller_;
00201 GripperController r_gripper_controller_;
00202
00203 actionlib::SimpleActionClient<object_manipulation_msgs::PickupAction> *pickup_client_;
00204 actionlib::SimpleActionClient<object_manipulation_msgs::PlaceAction> *place_client_;
00205 actionlib::SimpleActionClient<pr2_create_object_model::ModelObjectInHandAction> *create_model_client_;
00206
00207
00208 std::vector<object_manipulation_msgs::GraspableObject> graspable_objects_;
00209
00210
00211 pr2_interactive_object_detection::GraspableObjectListConstPtr received_objects_;
00212
00213 bool new_object_list_;
00214
00215 GraspInfo grasp_info_right_;
00216
00217 GraspInfo grasp_info_left_;
00218
00219 AdvancedGraspOptions ago_;
00220 };
00221
00222 }
00223
00224 #endif