00001 /* 00002 * Copyright (c) 2009, 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 #ifndef INTERACTIVE_MANIPULATION_FRONTEND 00031 #define INTERACTIVE_MANIPULATION_FRONTEND 00032 00033 #include <QWidget> 00034 00035 #include <ros/ros.h> 00036 00037 #include <actionlib/client/simple_action_client.h> 00038 00039 #include <std_msgs/String.h> 00040 00041 #include "pr2_msgs/PowerState.h" 00042 00043 #include "pr2_interactive_manipulation/advanced_options_dialog.h" 00044 #include "pr2_object_manipulation_msgs/IMGUIOptions.h" 00045 #include "pr2_object_manipulation_msgs/IMGUIAdvancedOptions.h" 00046 #include "pr2_object_manipulation_msgs/IMGUIAction.h" 00047 #include "pr2_object_manipulation_msgs/ActionInfo.h" 00048 00049 namespace Ui 00050 { 00051 class InteractiveManipulation; 00052 } 00053 00054 namespace rviz { 00055 class DisplayContext; 00056 class FrameManager; 00057 } 00058 00059 namespace pr2_interactive_manipulation { 00060 00061 class InteractiveManipulationFrontend : public QWidget 00062 { 00063 Q_OBJECT 00064 public: 00065 InteractiveManipulationFrontend(rviz::DisplayContext* context, QWidget* parent = 0); 00066 00067 ~InteractiveManipulationFrontend(); 00068 00069 void update(); 00070 00071 void setAdvancedOptions(pr2_object_manipulation_msgs::IMGUIAdvancedOptions ago){adv_options_ = ago;} 00072 00073 int interface_number_; 00074 00075 int task_number_; 00076 00077 protected Q_SLOTS: 00078 void graspButtonClicked(); 00079 00080 void placeButtonClicked(); 00081 00082 void plannedMoveButtonClicked(); 00083 00084 void cancelButtonClicked(); 00085 00086 void stopNavButtonClicked(); 00087 00088 void centerHeadButtonClicked(); 00089 00090 void drawReachableZonesButtonClicked(); 00091 00092 void resetButtonClicked(); 00093 00094 void armGoButtonClicked(); 00095 00096 void cameraLeftButtonClicked(); 00097 00098 void cameraRightButtonClicked(); 00099 00100 void cameraFrontButtonClicked(); 00101 00102 void cameraTopButtonClicked(); 00103 00104 void advancedOptionsClicked(); 00105 00106 void modelObjectClicked(); 00107 00108 //void openDrawerButtonClicked(); 00109 00110 void rcommandRunButtonClicked(); 00111 00112 void rcommandRefreshButtonClicked(); 00113 00114 void gripperSliderScrollChanged(); 00115 00116 protected: 00117 00118 void feedbackCallback(const pr2_object_manipulation_msgs::IMGUIFeedbackConstPtr &feedback); 00119 00120 void statusCallback( const std_msgs::StringConstPtr &status); 00121 00122 void powerCallback( const pr2_msgs::PowerStateConstPtr &power); 00123 00124 pr2_object_manipulation_msgs::IMGUIOptions getDialogOptions(); 00125 00126 void setCamera(std::vector<double> params); 00127 00128 rviz::DisplayContext* context_; 00129 00130 ros::NodeHandle root_nh_; 00131 ros::NodeHandle priv_nh_; 00132 00133 ros::ServiceClient rcommander_action_info_client_; 00134 actionlib::SimpleActionClient<pr2_object_manipulation_msgs::IMGUIAction> *action_client_; 00135 //actionlib::SimpleActionClient<RunScriptAction> *scripted_action_client_; 00136 //std::string scripted_action_name_; 00137 ros::Subscriber status_sub_; 00138 ros::Subscriber power_sub_; 00139 ros::Publisher draw_reachable_zones_pub_; 00140 00141 std::string rcommander_action_info_name_; 00142 std::string rcommander_group_name_; 00143 std::string action_name_; 00144 std::string status_name_; 00145 std::string power_name_; 00146 00147 std::string status_label_text_; 00148 std::string power_label_text_; 00149 00150 boost::mutex status_label_mutex_; 00151 boost::mutex power_label_mutex_; 00152 00153 pr2_object_manipulation_msgs::IMGUIAdvancedOptions adv_options_; 00154 00155 private: 00156 Ui::InteractiveManipulation* ui_; 00157 }; 00158 00159 } 00160 00161 #endif