robot_poses_widget.h
Go to the documentation of this file.
00001 /*********************************************************************
00002  * Software License Agreement (BSD License)
00003  *
00004  *  Copyright (c) 2012, Willow Garage, Inc.
00005  *  All rights reserved.
00006  *
00007  *  Redistribution and use in source and binary forms, with or without
00008  *  modification, are permitted provided that the following conditions
00009  *  are met:
00010  *
00011  *   * Redistributions of source code must retain the above copyright
00012  *     notice, this list of conditions and the following disclaimer.
00013  *   * Redistributions in binary form must reproduce the above
00014  *     copyright notice, this list of conditions and the following
00015  *     disclaimer in the documentation and/or other materials provided
00016  *     with the distribution.
00017  *   * Neither the name of the Willow Garage nor the names of its
00018  *     contributors may be used to endorse or promote products derived
00019  *     from this software without specific prior written permission.
00020  *
00021  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00022  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00023  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00024  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00025  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00026  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00027  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00028  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00029  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00030  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00031  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00032  *  POSSIBILITY OF SUCH DAMAGE.
00033  *********************************************************************/
00034 
00035 /* Author: Dave Coleman */
00036 
00037 #ifndef MOVEIT_MOVEIT_SETUP_ASSISTANT_WIDGETS_ROBOT_POSES_WIDGET_
00038 #define MOVEIT_MOVEIT_SETUP_ASSISTANT_WIDGETS_ROBOT_POSES_WIDGET_
00039 
00040 // Qt
00041 #include <QWidget>
00042 #include <QVBoxLayout>
00043 #include <QHBoxLayout>
00044 #include <QScrollArea>
00045 #include <QGroupBox>
00046 #include <QLabel>
00047 #include <QPushButton>
00048 #include <QTableWidget>
00049 #include <QStackedLayout>
00050 #include <QString>
00051 #include <QComboBox>
00052 
00053 // SA
00054 #ifndef Q_MOC_RUN
00055 #include <moveit/setup_assistant/tools/moveit_config_data.h>
00056 #include <moveit/planning_scene/planning_scene.h> // for collision stuff
00057 #include <ros/ros.h>
00058 #endif
00059 
00060 #include "header_widget.h"
00061 #include "setup_screen_widget.h" // a base class for screens in the setup assistant
00062 
00063 namespace moveit_setup_assistant
00064 {
00065 
00066 class RobotPosesWidget : public SetupScreenWidget
00067 {
00068   Q_OBJECT
00069 
00070   public:
00071   // ******************************************************************************************
00072   // Public Functions
00073   // ******************************************************************************************
00074 
00075   RobotPosesWidget( QWidget *parent, moveit_setup_assistant::MoveItConfigDataPtr config_data );
00076 
00078   virtual void focusGiven();
00079 
00080   // ******************************************************************************************
00081   // Qt Components
00082   // ******************************************************************************************
00083   QTableWidget *data_table_;
00084   QPushButton *btn_edit_;
00085   QPushButton *btn_delete_;
00086   QPushButton *btn_save_;
00087   QPushButton *btn_cancel_;
00088   QStackedLayout *stacked_layout_;
00089   QScrollArea *scroll_area_;
00090   QVBoxLayout *column2_;
00091   QLineEdit *pose_name_field_;
00092   QComboBox *group_name_field_;
00093   QWidget *joint_list_widget_;
00094   QVBoxLayout *joint_list_layout_;
00095   QWidget *pose_list_widget_;
00096   QWidget *pose_edit_widget_;
00097   QLabel *collision_warning_;
00098 
00099 private Q_SLOTS:
00100 
00101   // ******************************************************************************************
00102   // Slot Event Functions
00103   // ******************************************************************************************
00104 
00106   void showNewScreen();
00107 
00109   void editSelected();
00110 
00112   void editDoubleClicked( int row, int column );
00113 
00115   void previewClicked( int row, int column );
00116 
00118   void deleteSelected();
00119 
00121   void doneEditing();
00122 
00124   void cancelEditing();
00125 
00127   void loadJointSliders( const QString &selected );
00128 
00130   void showDefaultPose();
00131 
00133   void playPoses();
00134 
00141   void updateRobotModel( const std::string &name, double value );
00142 
00144   void publishJoints();
00145 
00146 private:
00147 
00148   // ******************************************************************************************
00149   // Variables
00150   // ******************************************************************************************
00151 
00153   moveit_setup_assistant::MoveItConfigDataPtr config_data_;
00154 
00156   std::string current_edit_pose_;
00157 
00159   std::map<std::string, double> joint_state_map_;
00160 
00162   std::vector<const robot_model::JointModel*> joint_models_;
00163 
00165   ros::Publisher pub_robot_state_;
00166 
00167   // ******************************************************************************************
00168   // Collision Variables
00169   // ******************************************************************************************
00170   collision_detection::CollisionRequest request;
00171 
00172   // ******************************************************************************************
00173   // Private Functions
00174   // ******************************************************************************************
00175 
00182   srdf::Model::GroupState *findPoseByName( const std::string &name );
00183 
00189   QWidget* createContentsWidget();
00190 
00196   QWidget* createEditWidget();
00197 
00202   void loadDataTable();
00203 
00208   void loadGroupsComboBox();
00209 
00215   void edit( const std::string &name );
00216 
00220   void showPose( srdf::Model::GroupState *pose );
00221 };
00222 
00223 
00224 // ******************************************************************************************
00225 // ******************************************************************************************
00226 // Slider Widget
00227 // ******************************************************************************************
00228 // ******************************************************************************************
00229 class SliderWidget : public QWidget
00230 {
00231   Q_OBJECT
00232 
00233   public:
00234   // ******************************************************************************************
00235   // Public Functions
00236   // ******************************************************************************************
00237 
00244   SliderWidget( QWidget *parent, const robot_model::JointModel *joint_model,
00245                 double init_value );
00246 
00250   ~SliderWidget();
00251 
00252   // ******************************************************************************************
00253   // Qt Components
00254   // ******************************************************************************************
00255 
00256   QLabel *joint_label_;
00257   QSlider *joint_slider_;
00258   QLineEdit *joint_value_;
00259 
00260 private Q_SLOTS:
00261 
00262   // ******************************************************************************************
00263   // Slot Event Functions
00264   // ******************************************************************************************
00265 
00267   void changeJointValue( int value );
00268 
00270   void changeJointSlider();
00271 
00272 Q_SIGNALS:
00273 
00274   // ******************************************************************************************
00275   // Emitted Signal Functions
00276   // ******************************************************************************************
00277 
00279   void jointValueChanged( const std::string &name, double value );
00280 
00281 private:
00282 
00283   // ******************************************************************************************
00284   // Variables
00285   // ******************************************************************************************
00286 
00287   // Ptr to the joint's data
00288   const robot_model::JointModel *joint_model_;
00289 
00290   // Max & min position
00291   double max_position_;
00292   double min_position_;
00293 
00294   // ******************************************************************************************
00295   // Private Functions
00296   // ******************************************************************************************
00297 
00298 
00299 };
00300 
00301 
00302 } //namespace
00303 
00304 // Declare std::string as metatype so we can use it in a signal
00305 Q_DECLARE_METATYPE (std::string)
00306 
00307 
00308 #endif


moveit_setup_assistant
Author(s): Dave Coleman
autogenerated on Mon Oct 6 2014 02:32:27