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_frame.h" 00032 #include "pr2_interactive_manipulation/interactive_manipulation_frontend.h" 00033 00034 namespace pr2_interactive_manipulation { 00035 00036 AdvancedOptionsDialog::AdvancedOptionsDialog(InteractiveManipulationFrame *parent, 00037 InteractiveManipulationFrontend *frontend) : 00038 AdvancedOptionsDialogBase(parent), 00039 parent_(parent), 00040 frontend_(frontend) 00041 { 00042 } 00043 00044 AdvancedOptionsDialog::~AdvancedOptionsDialog() 00045 { 00046 } 00047 00048 void AdvancedOptionsDialog::setDefaultsClicked( wxCommandEvent& ) 00049 { 00050 setOptions( getDefaults() ); 00051 } 00052 00053 AdvancedGraspOptions AdvancedOptionsDialog::getDefaults() 00054 { 00055 AdvancedGraspOptions go; 00056 go.reactive_grasping_ = false; 00057 go.reactive_force_ = false; 00058 go.reactive_place_ = true; 00059 go.lift_steps_ = 10; 00060 go.retreat_steps_ = 10; 00061 go.lift_vertically_ = 0; 00062 return go; 00063 } 00064 00065 AdvancedGraspOptions AdvancedOptionsDialog::getOptions() 00066 { 00067 AdvancedGraspOptions go; 00068 go.reactive_grasping_ = reactive_grasping_box_->IsChecked(); 00069 go.reactive_force_ = reactive_transport_box_->IsChecked(); 00070 go.reactive_place_ = reactive_place_box_->IsChecked(); 00071 go.lift_steps_ = lift_distance_spin_->GetValue(); 00072 go.retreat_steps_ = retreat_distance_spin_->GetValue(); 00073 go.lift_vertically_ = lift_direction_choice_->GetSelection(); 00074 return go; 00075 } 00076 00077 void AdvancedOptionsDialog::setOptions(AdvancedGraspOptions go) 00078 { 00079 reactive_grasping_box_->SetValue(go.reactive_grasping_); 00080 reactive_transport_box_->SetValue(go.reactive_force_); 00081 reactive_place_box_->SetValue(go.reactive_place_); 00082 lift_distance_spin_->SetValue(go.lift_steps_); 00083 retreat_distance_spin_->SetValue(go.retreat_steps_); 00084 lift_direction_choice_->SetSelection(go.lift_vertically_); 00085 } 00086 00087 void AdvancedOptionsDialog::acceptClicked( wxCommandEvent& event ) 00088 { 00089 if (parent_) parent_->setAdvancedGraspOptions(getOptions()); 00090 if (frontend_) frontend_->setAdvancedOptions(getOptionsMsg()); 00091 Close(); 00092 } 00093 00094 00095 IMGUIAdvancedOptions AdvancedOptionsDialog::getDefaultsMsg() 00096 { 00097 IMGUIAdvancedOptions go; 00098 go.reactive_grasping = false; 00099 go.reactive_force = false; 00100 go.reactive_place = true; 00101 go.lift_steps = 10; 00102 go.retreat_steps = 10; 00103 go.lift_vertically = 0; 00104 return go; 00105 } 00106 00107 IMGUIAdvancedOptions AdvancedOptionsDialog::getOptionsMsg() 00108 { 00109 IMGUIAdvancedOptions go; 00110 go.reactive_grasping = reactive_grasping_box_->IsChecked(); 00111 go.reactive_force = reactive_transport_box_->IsChecked(); 00112 go.reactive_place = reactive_place_box_->IsChecked(); 00113 go.lift_steps = lift_distance_spin_->GetValue(); 00114 go.retreat_steps = retreat_distance_spin_->GetValue(); 00115 go.lift_vertically = lift_direction_choice_->GetSelection(); 00116 return go; 00117 } 00118 00119 void AdvancedOptionsDialog::setOptionsMsg(IMGUIAdvancedOptions go) 00120 { 00121 reactive_grasping_box_->SetValue(go.reactive_grasping); 00122 reactive_transport_box_->SetValue(go.reactive_force); 00123 reactive_place_box_->SetValue(go.reactive_place); 00124 lift_distance_spin_->SetValue(go.lift_steps); 00125 retreat_distance_spin_->SetValue(go.retreat_steps); 00126 lift_direction_choice_->SetSelection(go.lift_vertically); 00127 } 00128 00129 void AdvancedOptionsDialog::reactiveGraspingClicked( wxCommandEvent& ) 00130 { 00131 //reactive gripper force is only allowed together with reactive grasping 00132 if (!reactive_grasping_box_->IsChecked()) reactive_transport_box_->SetValue(false); 00133 } 00134 00135 void AdvancedOptionsDialog::reactiveForceClicked( wxCommandEvent& ) 00136 { 00137 //reactive gripper force is only allowed together with reactive grasping 00138 if (!reactive_grasping_box_->IsChecked()) reactive_grasping_box_->SetValue(true); 00139 } 00140 00141 }