$search
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 #include "pr2_interactive_manipulation/advanced_options_dialog.h" 00031 #include "pr2_interactive_manipulation/interactive_manipulation_frontend.h" 00032 00033 namespace pr2_interactive_manipulation { 00034 00035 AdvancedOptionsDialog::AdvancedOptionsDialog(InteractiveManipulationFrontend *frontend) : 00036 AdvancedOptionsDialogBase(frontend), 00037 frontend_(frontend) 00038 { 00039 } 00040 00041 AdvancedOptionsDialog::~AdvancedOptionsDialog() 00042 { 00043 } 00044 00045 void AdvancedOptionsDialog::setDefaultsClicked( wxCommandEvent& ) 00046 { 00047 setOptions( getDefaults() ); 00048 } 00049 00050 AdvancedGraspOptions AdvancedOptionsDialog::getDefaults(int interface_number, int task_number) 00051 { 00052 AdvancedGraspOptions go; 00053 go.reactive_grasping_ = false; 00054 go.reactive_force_ = false; 00055 go.reactive_place_ = false; 00056 go.lift_steps_ = 10; 00057 go.retreat_steps_ = 10; 00058 go.lift_direction_choice_ = 0; 00059 go.desired_approach_ = 10; 00060 go.min_approach_ = 5; 00061 go.max_contact_force_ = 50; 00062 switch (task_number) 00063 { 00064 case 3: 00065 go.lift_direction_choice_ = 1; 00066 break; 00067 } 00068 00069 return go; 00070 } 00071 00072 AdvancedGraspOptions AdvancedOptionsDialog::getOptions() 00073 { 00074 AdvancedGraspOptions go; 00075 go.reactive_grasping_ = reactive_grasping_box_->IsChecked(); 00076 go.reactive_force_ = reactive_transport_box_->IsChecked(); 00077 go.reactive_place_ = reactive_place_box_->IsChecked(); 00078 go.lift_steps_ = lift_distance_spin_->GetValue(); 00079 go.retreat_steps_ = retreat_distance_spin_->GetValue(); 00080 go.lift_direction_choice_ = lift_direction_choice_->GetSelection(); 00081 go.desired_approach_ = desired_grasp_approach_spin_->GetValue(); 00082 go.min_approach_ = min_grasp_approach_spin_->GetValue(); 00083 go.max_contact_force_ = max_contact_force_spin_->GetValue(); 00084 return go; 00085 } 00086 00087 void AdvancedOptionsDialog::setOptions(AdvancedGraspOptions go) 00088 { 00089 reactive_grasping_box_->SetValue(go.reactive_grasping_); 00090 reactive_transport_box_->SetValue(go.reactive_force_); 00091 reactive_place_box_->SetValue(go.reactive_place_); 00092 lift_distance_spin_->SetValue(go.lift_steps_); 00093 retreat_distance_spin_->SetValue(go.retreat_steps_); 00094 lift_direction_choice_->SetSelection(go.lift_direction_choice_); 00095 desired_grasp_approach_spin_->SetValue(go.desired_approach_); 00096 min_grasp_approach_spin_->SetValue(go.min_approach_); 00097 max_contact_force_spin_->SetValue(go.max_contact_force_); 00098 } 00099 00100 void AdvancedOptionsDialog::acceptClicked( wxCommandEvent& event ) 00101 { 00102 frontend_->setAdvancedOptions(getOptionsMsg()); 00103 Close(); 00104 } 00105 00106 00107 pr2_object_manipulation_msgs::IMGUIAdvancedOptions AdvancedOptionsDialog::getDefaultsMsg(int interface_number, int task_number) 00108 { 00109 pr2_object_manipulation_msgs::IMGUIAdvancedOptions go; 00110 go.reactive_grasping = false; 00111 go.reactive_force = false; 00112 go.reactive_place = false; 00113 go.lift_steps = 10; 00114 go.retreat_steps = 10; 00115 go.lift_direction_choice = 0; 00116 go.desired_approach = 10; 00117 go.min_approach = 5; 00118 go.max_contact_force = 50; 00119 switch (task_number) 00120 { 00121 case 3: 00122 go.lift_direction_choice = 1; 00123 break; 00124 } 00125 return go; 00126 } 00127 00128 pr2_object_manipulation_msgs::IMGUIAdvancedOptions AdvancedOptionsDialog::getOptionsMsg() 00129 { 00130 pr2_object_manipulation_msgs::IMGUIAdvancedOptions go; 00131 go.reactive_grasping = reactive_grasping_box_->IsChecked(); 00132 go.reactive_force = reactive_transport_box_->IsChecked(); 00133 go.reactive_place = reactive_place_box_->IsChecked(); 00134 go.lift_steps = lift_distance_spin_->GetValue(); 00135 go.retreat_steps = retreat_distance_spin_->GetValue(); 00136 go.lift_direction_choice = lift_direction_choice_->GetSelection(); 00137 go.desired_approach = desired_grasp_approach_spin_->GetValue(); 00138 go.min_approach = min_grasp_approach_spin_->GetValue(); 00139 go.max_contact_force = max_contact_force_spin_->GetValue(); 00140 return go; 00141 } 00142 00143 void AdvancedOptionsDialog::setOptionsMsg(pr2_object_manipulation_msgs::IMGUIAdvancedOptions go) 00144 { 00145 reactive_grasping_box_->SetValue(go.reactive_grasping); 00146 reactive_transport_box_->SetValue(go.reactive_force); 00147 reactive_place_box_->SetValue(go.reactive_place); 00148 lift_distance_spin_->SetValue(go.lift_steps); 00149 retreat_distance_spin_->SetValue(go.retreat_steps); 00150 lift_direction_choice_->SetSelection(go.lift_direction_choice); 00151 desired_grasp_approach_spin_->SetValue(go.desired_approach); 00152 min_grasp_approach_spin_->SetValue(go.min_approach); 00153 max_contact_force_spin_->SetValue(go.max_contact_force); 00154 } 00155 00156 void AdvancedOptionsDialog::reactiveGraspingClicked( wxCommandEvent& ) 00157 { 00158 //reactive gripper force is only allowed together with reactive grasping 00159 if (!reactive_grasping_box_->IsChecked()) reactive_transport_box_->SetValue(false); 00160 } 00161 00162 void AdvancedOptionsDialog::reactiveForceClicked( wxCommandEvent& ) 00163 { 00164 //reactive gripper force is only allowed together with reactive grasping 00165 if (!reactive_grasping_box_->IsChecked()) reactive_grasping_box_->SetValue(true); 00166 } 00167 00168 }