gripper_click_display.h
Go to the documentation of this file.
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 GRIPPER_CLICK_DISPLAY_H
00031 #define GRIPPER_CLICK_DISPLAY_H
00032 
00033 #include "rviz/display.h"
00034 
00035 #include <actionlib/server/simple_action_server.h>
00036 
00037 #include "pr2_gripper_click/GripperClickPickupAction.h"
00038 #include "pr2_gripper_click/gripper_click_3d_gripper.h"
00039 #include "pr2_gripper_click/gripper_click_grasp_adjust.h"
00040 #include "pr2_gripper_click/gripper_click_line.h"
00041 #include "pr2_gripper_click/gripper_click_dot.h"
00042 #include "pr2_gripper_click/gripper_click_place_cartesian.h"
00043 #include "pr2_gripper_click/gripper_click_pickup_cartesian.h"
00044 
00045 
00046 namespace pr2_gripper_click
00047 {
00048 
00049 // will start an action server, instatiate a gripper click ui
00050 // which can hold plugins for the specific action
00051 template<class ActionClass>
00052 class GripperClickDisplay : public rviz::Display
00053 {
00054 public:
00055 
00056   typedef typename ActionClass::_action_result_type::_result_type ResultType;
00057   typedef typename ActionClass::_action_goal_type::_goal_type GoalType;
00058 
00059   GripperClickDisplay( std::string action_topic, const std::string& name, rviz::VisualizationManager* manager );
00060   
00061   virtual ~GripperClickDisplay();
00062 
00063   virtual void targetFrameChanged() {}
00064   virtual void fixedFrameChanged() {}
00065 
00066   virtual void update(float wall_dt, float ros_dt);
00067 
00068   virtual void onEnable();
00069 
00070   virtual void onDisable();
00071 
00072   //start listening to action goals
00073   void startActionServer();
00074 
00075   //stop action server, cancel current goal & hide if necessary
00076   void stopActionServer();
00077 
00078   // callback for new action server goals
00079   virtual void acceptNewGoal();
00080 
00081   virtual void preemptAction();
00082   virtual void abortAction();
00083 
00084 protected:
00085 
00086   GripperClickRvizUI<ActionClass> *gripper_click_rviz_ui_;
00087 
00088   actionlib::SimpleActionServer<ActionClass> *action_server_;
00089 
00090   std::string action_topic_;
00091 };
00092 
00093 //specialized displays for pickup / place
00094 //note: GripperClickDisplay<GripperClickPickupAction> etc. are instantiated in the cpp
00095 
00096 class GripperClickPickupDisplay : public GripperClickDisplay<GripperClickPickupAction>
00097 {
00098 public:
00099   GripperClickPickupDisplay( const std::string& name, rviz::VisualizationManager* manager ) :
00100     GripperClickDisplay<GripperClickPickupAction>( "gripper_click_pickup_ui", name, manager ) {};
00101 
00102   virtual void onEnable()
00103   {
00104     GripperClickDisplay<GripperClickPickupAction>::onEnable();
00105     gripper_click_rviz_ui_->addPlugin( new GripperClickPickupCartesian() );
00106     gripper_click_rviz_ui_->addPlugin( new GripperClick3DGripper() );
00107     gripper_click_rviz_ui_->addPlugin( new GripperClickGraspAdjust() );
00108     gripper_click_rviz_ui_->addPlugin( new GripperClickLine() );
00109     gripper_click_rviz_ui_->SetTitle( wxString::FromAscii("Pick up object") );
00110   }
00111 };
00112 
00113 class GripperClickPlaceDisplay : public GripperClickDisplay<GripperClickPlaceAction>
00114 {
00115 public:
00116   GripperClickPlaceDisplay( const std::string& name, rviz::VisualizationManager* manager ) :
00117     GripperClickDisplay<GripperClickPlaceAction>( "gripper_click_place_ui", name, manager ) {};
00118 
00119   virtual void onEnable()
00120   {
00121     GripperClickDisplay<GripperClickPlaceAction>::onEnable();
00122     gripper_click_rviz_ui_->addPlugin( new GripperClickPlaceCartesian() );
00123     gripper_click_rviz_ui_->addPlugin( new GripperClickDot() );
00124     gripper_click_rviz_ui_->SetTitle( wxString::FromAscii("Place object") );
00125   }
00126 };
00127 
00128 }
00129 
00130 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends


pr2_gripper_click
Author(s): Matei Ciocarlie
autogenerated on Tue Oct 30 2012 07:55:20