00001 #ifndef CONTINUALPLANNINGMONITOR_WINDOW_H 00002 #define CONTINUALPLANNINGMONITOR_WINDOW_H 00003 00004 #include <QMainWindow> 00005 #include <QThread> 00006 #include <QSignalMapper> 00007 #include <QSettings> 00008 #include "ui_ContinualPlanningMonitorWindow.h" 00009 #include "continual_planning_executive/ContinualPlanningStatus.h" 00010 #include "continual_planning_executive/SetContinualPlanningControl.h" 00011 #include "continual_planning_executive/ExecuteActionDirectly.h" 00012 #include <ros/ros.h> 00013 00014 class ExecuteActionThread : public QThread 00015 { 00016 Q_OBJECT 00017 00018 public: 00019 ExecuteActionThread(); 00020 00022 void executeAction(QString actionTxt); 00023 00024 Q_SIGNALS: 00025 void actionExecutionFailed(bool success, QString title, QString message); 00026 00027 protected: 00028 void run(); 00029 00030 QString _actionTxt; 00031 continual_planning_executive::ExecuteActionDirectly _srv; 00032 ros::ServiceClient _serviceExecuteActionDirectly; 00033 }; 00034 00035 class ContinualPlanningControlThread : public QThread 00036 { 00037 Q_OBJECT 00038 00039 public: 00040 ContinualPlanningControlThread(); 00041 00043 void setContinualPlanningControl(int command); 00044 00045 Q_SIGNALS: 00046 void controlCommandSet(bool success, QString title, QString message); 00047 00048 protected: 00049 void run(); 00050 00051 continual_planning_executive::SetContinualPlanningControl _srv; 00052 ros::ServiceClient _serviceContinualPlanningControl; 00053 }; 00054 00055 class ContinualPlanningMonitorWindow : public QMainWindow, protected Ui::ContinualPlanningMonitorWindow 00056 { 00057 Q_OBJECT 00058 00059 public: 00060 ContinualPlanningMonitorWindow(); 00061 ~ContinualPlanningMonitorWindow(); 00062 00063 private Q_SLOTS: 00064 void on_actionExit_activated(); 00065 void on_actionReset_activated(); 00066 void on_actionRun_activated(); 00067 void on_actionPause_activated(); 00068 void on_actionStep_activated(); 00069 void on_actionExecute_Action_activated(); 00070 void on_actionAdd_Action_activated(); 00071 void on_actionForce_Replanning_activated(); 00072 void on_actionReestimate_State_activated(); 00073 00074 void executeAction(QString actionTxt); 00075 00076 void currentPlanList_contextMenu(const QPoint & pos); 00077 void lastPlanList_contextMenu(const QPoint & pos); 00078 00079 void notifyUser(bool success, QString title, QString message); 00080 00081 protected: 00083 void restyle(); 00084 00085 void statusCallback(const continual_planning_executive::ContinualPlanningStatus & status); 00086 00088 QString getActionDescription(QString action); 00089 00091 00095 void executeActionDirectly_contextMenu(QListWidgetItem* item, const QPoint & globalPos); 00096 00098 QString queryActionText(QString actionTxt); 00099 00100 private: 00101 continual_planning_executive::ContinualPlanningStatus st; 00102 ros::Subscriber _subStatus; 00103 00104 ContinualPlanningControlThread _continualPlanningControlThread; 00105 ExecuteActionThread _executeActionThread; 00106 00107 unsigned int _nCustomActions; 00108 QSettings* _settings; 00109 QSignalMapper* _signalMapper; 00110 }; 00111 00112 #endif 00113