arm_navigation_controls.h
Go to the documentation of this file.
00001 /******************************************************************************
00002  * \file
00003  * \brief RVIZ plugin which provides simplified GUI based on Warehouse Viewer.
00004  *
00005  * $Id:$
00006  *
00007  * Copyright (C) Brno University of Technology
00008  *
00009  * This file is part of software developed by dcgm-robotics@FIT group.
00010  *
00011  * Author: Zdenek Materna (imaterna@fit.vutbr.cz)
00012  * Supervised by: Michal Spanel (spanel@fit.vutbr.cz)
00013  * Date: 5/4/2012
00014  * 
00015  * This file is free software: you can redistribute it and/or modify
00016  * it under the terms of the GNU Lesser General Public License as published by
00017  * the Free Software Foundation, either version 3 of the License, or
00018  * (at your option) any later version.
00019  * 
00020  * This file is distributed in the hope that it will be useful,
00021  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00022  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023  * GNU Lesser General Public License for more details.
00024  * 
00025  * You should have received a copy of the GNU Lesser General Public License
00026  * along with this file.  If not, see <http://www.gnu.org/licenses/>.
00027  */
00028 
00029 #pragma once
00030 #ifndef BUT_ARMNAVIGATION_H
00031 #define BUT_ARMNAVIGATION_H
00032 
00033 #include <wx/wx.h>
00034 #include <wx/menu.h>
00035 #include <wx/panel.h>
00036 #include <wx/dialog.h>
00037 #include <wx/msgdlg.h>
00038 #include <wx/sizer.h>
00039 #include <wx/tglbtn.h>
00040 #include <wx/checkbox.h>
00041 #include <wx/choice.h>
00042 
00043 #include <ros/ros.h>
00044 #include <string.h>
00045 
00046 #include "srs_assisted_arm_navigation_msgs/ArmNavExecute.h"
00047 #include "srs_assisted_arm_navigation_msgs/ArmNavNew.h"
00048 #include "srs_assisted_arm_navigation_msgs/ArmNavPlan.h"
00049 #include "srs_assisted_arm_navigation_msgs/ArmNavPlay.h"
00050 #include "srs_assisted_arm_navigation_msgs/ArmNavReset.h"
00051 #include "srs_assisted_arm_navigation_msgs/ArmNavStart.h"
00052 #include "srs_assisted_arm_navigation_msgs/ArmNavSuccess.h"
00053 #include "srs_assisted_arm_navigation_msgs/ArmNavFailed.h"
00054 #include "srs_assisted_arm_navigation_msgs/ArmNavRefresh.h"
00055 #include "srs_assisted_arm_navigation_msgs/ArmNavSwitchAttCO.h"
00056 #include "srs_assisted_arm_navigation_msgs/ArmNavRepeat.h"
00057 #include "srs_assisted_arm_navigation_msgs/ArmNavStep.h"
00058 #include "srs_assisted_arm_navigation_msgs/ArmNavStop.h"
00059 #include "srs_assisted_arm_navigation_msgs/ArmNavMovePalmLinkRel.h"
00060 #include "srs_assisted_arm_navigation_msgs/ArmNavMovePalmLink.h"
00061 #include "srs_assisted_arm_navigation_msgs/AssistedArmNavigationState.h"
00062 
00063 //#include "srs_env_model/LockCollisionMap.h"
00064 
00065 //#include "cob_script_server/ScriptAction.h"
00066 #include <actionlib/client/simple_action_client.h>
00067 #include <boost/thread.hpp>
00068 #include <boost/date_time/posix_time/posix_time.hpp>
00069 #include <map>
00070 
00071 #include "srs_assisted_arm_navigation/services_list.h"
00072 #include "srs_env_model/services_list.h"
00073 #include <tf/transform_broadcaster.h>
00074 #include <wx/textctrl.h>
00075 
00076 namespace rviz
00077 {
00078     class WindowManagerInterface;
00079 }
00080 
00081 namespace srs_assisted_arm_navigation_ui {
00082 
00087 static const bool WAIT_FOR_START = true;
00088 
00092 //typedef actionlib::SimpleActionClient<cob_script_server::ScriptAction> cob_client;
00093 
00094 
00095 struct Preset {
00096 
00097         std::string name;
00098         geometry_msgs::Pose pose;
00099         bool relative;
00100 
00101 };
00102 
00103 class CArmManipulationControls : public wxPanel
00104 {
00105 public:
00107     CArmManipulationControls(wxWindow *parent, const wxString& title, rviz::WindowManagerInterface * wmi );
00108     ~CArmManipulationControls();
00109 
00111     virtual void OnNew(wxCommandEvent& event);
00112     virtual void OnPlan(wxCommandEvent& event);
00113 
00114     virtual void OnExecute(wxCommandEvent& event);
00115 
00116     //virtual void OnFinish(wxCommandEvent& event);
00117     virtual void OnSuccess(wxCommandEvent& event);
00118     virtual void OnFailed(wxCommandEvent& event);
00119     virtual void OnRepeat(wxCommandEvent& event);
00120 
00121     virtual void OnSwitch(wxCommandEvent& event);
00122 
00123 
00124 
00125     void OnStepBack(wxCommandEvent& event);
00126 
00127     void OnChoice(wxCommandEvent& event);
00128 
00129     void MoveAbs();
00130     void MoveRel();
00131 
00132     void OnMoveRel(wxCommandEvent& event);
00133 
00134     void OnGrasp(wxCommandEvent& event);
00135     void OnStopGrasp(wxCommandEvent& event);
00136 
00137     void OnLift(wxCommandEvent& event);
00138     void OnHold(wxCommandEvent& event);
00139 
00140     void OnStopTraj(wxCommandEvent& event);
00141 
00142     void OnRoll(wxCommandEvent& event);
00143     void OnPitch(wxCommandEvent& event);
00144     void OnYaw(wxCommandEvent& event);
00145 
00146     void setControlsToDefaultState();
00147     void disableControls();
00148 
00149     bool refresh();
00150 
00151 
00152     void OnSetText(wxCommandEvent & event);
00153 
00155     bool nav_start(srs_assisted_arm_navigation_msgs::ArmNavStart::Request &req, srs_assisted_arm_navigation_msgs::ArmNavStart::Response &res);
00156 
00157 protected:
00159     rviz::WindowManagerInterface * m_wmi;
00160 
00161     typedef std::map<std::string, wxButton *> ButtonsMap;
00162 
00163     ButtonsMap buttons_;
00164 
00165     /*wxSlider * m_slider_roll;
00166     wxSlider * m_slider_pitch;
00167     wxSlider * m_slider_yaw;*/
00168 
00169 
00170     wxChoice *presets_choice_;
00171 
00172     wxButton * m_button_switch;
00173 
00174     wxStaticText *m_text_status;
00175     wxStaticText *m_text_action_;
00176     wxTextCtrl *m_text_task_;
00177 
00178     void setTask(std::string text);
00179 
00180     wxStaticText *m_text_predef_pos_;
00181     //wxStaticText *m_text_object;
00182     //wxStaticText *m_text_timeout;
00183     //wxStaticText *m_text_dist; // distance to closest pregrasp position
00184 
00185     //wxToggleButton *m_lock_cmap_;
00186 
00187     ros::ServiceServer service_start_;
00188     ros::ServiceServer service_timeout_;
00189 
00190     wxWindow *parent_;
00191 
00192     /*bool goal_away;
00193     bool goal_pregrasp;*/
00194 
00195     bool wait_for_start_;
00196 
00197     uint8_t traj_executed_;
00198 
00199     bool allow_repeat_;
00200     //bool cmap_locked_;
00201 
00202     std::string object_name_;
00203     std::string action_;
00204 
00205     //cob_client * cob_script;
00206 
00207     //bool gripper_initialized;
00208 
00209     void setButton(std::string but, bool state);
00210 
00211     void stateCallback(const srs_assisted_arm_navigation_msgs::AssistedArmNavigationState::ConstPtr& msg);
00212 
00213     std::vector<Preset> presets_;
00214 
00215 
00216 private:
00217 
00218     DECLARE_EVENT_TABLE();
00219 
00220     enum {G_OPEN,G_CLOSE};
00221 
00222     //enum {S_INIT, S_NEW, S_PLAN, S_EXECUTE, S_PLAY, S_ADJUST, S_RESET, S_SUCCESS, S_FAILED, S_GOPEN, S_GCLOSE, S_LOOKAROUND, S_REFRESH};
00223 
00228     //void GripperThread(unsigned char action);
00229     void NewThread();
00230     void PlanThread();
00231     void ExecuteThread();
00232     //void LookThread();
00233 
00234     //boost::thread t_gripper;
00235     boost::thread t_new;
00236     boost::thread t_plan;
00237     boost::thread t_execute;
00238     //boost::thread t_look;
00239 
00240     boost::thread t_move_rel;
00241     boost::thread t_move_abs;
00242 
00243     bool checkService(std::string srv);
00244 
00245     //bool cob_script_inited;
00246 
00247     bool aco_;
00248 
00249     bool initialized_;
00250 
00251     bool state_received_;
00252 
00253     bool spacenav_pos_lock_;
00254     bool spacenav_or_lock_;
00255 
00256     ros::Subscriber arm_nav_state_sub_;
00257 
00258     wxCheckBox *m_pos_lock_;
00259     wxCheckBox *m_or_lock_;
00260 
00261     wxCheckBox *m_aco_;
00262 
00263     //wxToggleButton *b_switch_;
00264 
00265     boost::thread t_gui_update;
00266     void GuiUpdateThread();
00267     bool stop_gui_thread_;
00268 
00269     bool planning_started_;
00270     bool trajectory_planned_;
00271 
00272     bool arm_nav_called_;
00273 
00274 };
00275 
00276 } // namespace
00277 
00278 #endif // BUT_ARMNAVIGATION_H


srs_assisted_arm_navigation_ui
Author(s): Zdenek Materna
autogenerated on Mon Oct 6 2014 08:18:44