00001 // -*- mode: c++ -*- 00002 /********************************************************************* 00003 * Software License Agreement (BSD License) 00004 * 00005 * Copyright (c) 2014, JSK Lab 00006 * All rights reserved. 00007 * 00008 * Redistribution and use in source and binary forms, with or without 00009 * modification, are permitted provided that the following conditions 00010 * are met: 00011 * 00012 * * Redistributions of source code must retain the above copyright 00013 * notice, this list of conditions and the following disclaimer. 00014 * * Redistributions in binary form must reproduce the above 00015 * copyright notice, this list of conditions and the following 00016 * disclaimer in the documentation and/o2r other materials provided 00017 * with the distribution. 00018 * * Neither the name of the JSK Lab nor the names of its 00019 * contributors may be used to endorse or promote products derived 00020 * from this software without specific prior written permission. 00021 * 00022 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00023 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00024 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 00025 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 00026 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00027 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00028 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00029 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00030 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00031 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 00032 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00033 * POSSIBILITY OF SUCH DAMAGE. 00034 *********************************************************************/ 00035 00036 00037 #ifndef JSK_RVIZ_PLUGINS_TABLET_CONTROLLER_PANEL_H_ 00038 #define JSK_RVIZ_PLUGINS_TABLET_CONTROLLER_PANEL_H_ 00039 00040 #include <ros/ros.h> 00041 #include <rviz/panel.h> 00042 #include <QtGui> 00043 #include <QPainter> 00044 #include <QLineEdit> 00045 #include <QPushButton> 00046 #include <QVBoxLayout> 00047 #include <QHBoxLayout> 00048 #include <QDialog> 00049 #include <QListWidget> 00050 #include <QListWidgetItem> 00051 #include <QLabel> 00052 #include <QTimer> 00053 #include <QRadioButton> 00054 #include <QPaintEvent> 00055 #include <QMouseEvent> 00056 #include <geometry_msgs/Twist.h> 00057 #include <roseus/StringStamped.h> 00058 #include <visualization_msgs/MarkerArray.h> 00059 #include <boost/thread.hpp> 00060 00061 namespace jsk_rviz_plugins 00062 { 00063 class TabletCmdVelArea: public QWidget 00064 { 00065 Q_OBJECT 00066 public: 00067 TabletCmdVelArea(QWidget* parent, ros::Publisher& pub_cmd_vel); 00068 virtual QSize minimumSizeHint() const; 00069 virtual QSize sizeHint() const; 00070 protected: 00071 virtual void paintEvent(QPaintEvent* event); 00072 virtual void mouseMoveEvent(QMouseEvent* event); 00073 virtual void mousePressEvent(QMouseEvent* event); 00074 virtual void mouseReleaseEvent(QMouseEvent* event); 00075 virtual void publishVelocity(int mouse_x, int mouse_y, int cx, int cy); 00076 virtual void publishCmdVel(double x, double y, double theta); 00077 int mouse_x_; 00078 int mouse_y_; 00079 ros::Publisher pub_cmd_vel_; 00080 }; 00081 00082 class TabletControllerPanel: public rviz::Panel 00083 { 00084 Q_OBJECT 00085 public: 00086 TabletControllerPanel(QWidget* parent = 0); 00087 virtual ~TabletControllerPanel(); 00088 virtual void load(const rviz::Config& config); 00089 virtual void save(rviz::Config config) const; 00090 00091 protected: 00093 // methods 00095 virtual void spotCallback( 00096 const visualization_msgs::MarkerArray::ConstPtr& marker); 00097 virtual QString defaultButtonStyleSheet(); 00098 virtual QString executeButtonStyleSheet(); 00099 virtual QString radioButtonStyleSheet(); 00100 virtual QString listStyleSheet(); 00102 // GUI variables 00104 00105 QVBoxLayout* layout_; 00106 QPushButton* task_button_; 00107 QPushButton* spot_button_; 00108 TabletCmdVelArea* cmd_vel_area_; 00109 00110 QDialog* task_dialog_; 00111 QVBoxLayout* task_dialog_layout_; 00112 QHBoxLayout* task_dialog_button_layout_; 00113 QPushButton* task_execute_button_; 00114 QPushButton* task_cancel_button_; 00115 std::vector<QRadioButton*> task_radio_buttons_; 00116 00117 std::vector<std::string> spots_; 00118 QDialog* spot_dialog_; 00119 QVBoxLayout* spot_dialog_layout_; 00120 QHBoxLayout* spot_dialog_button_layout_; 00121 QPushButton* spot_go_button_; 00122 QPushButton* spot_cancel_button_; 00123 QListWidget* spot_list_; 00125 // ROS variables 00127 ros::Publisher pub_cmd_vel_; 00128 ros::Publisher pub_spot_; 00129 ros::Publisher pub_start_demo_; 00130 ros::Subscriber sub_spots_; 00131 boost::mutex mutex_; 00132 00133 00134 protected Q_SLOTS: 00136 // callbacks 00138 void taskButtonClicked(); 00139 void taskCancelClicked(); 00140 void taskExecuteClicked(); 00141 void spotButtonClicked(); 00142 void spotGoClicked(); 00143 void spotCancelClicked(); 00144 private: 00145 00146 }; 00147 } 00148 00149 #endif