handeye_target_widget.h
Go to the documentation of this file.
1 /*********************************************************************
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2019, Intel Corporation.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above
14  * copyright notice, this list of conditions and the following
15  * disclaimer in the documentation and/or other materials provided
16  * with the distribution.
17  * * Neither the name of Willow Garage nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  *********************************************************************/
34 
35 /* Author: Yu Yan */
36 
37 #pragma once
38 
39 // qt
40 #include <QSet>
41 #include <QLabel>
42 #include <QString>
43 #include <QLineEdit>
44 #include <QGroupBox>
45 #include <QComboBox>
46 #include <QMetaType>
47 #include <QTabWidget>
48 #include <QPushButton>
49 #include <QHBoxLayout>
50 #include <QVBoxLayout>
51 #include <QFormLayout>
52 #include <QMessageBox>
53 #include <QFileDialog>
54 
55 // opencv
56 #include <opencv2/aruco.hpp>
57 #include <opencv2/opencv.hpp>
58 
59 // ros
60 #include <sensor_msgs/Image.h>
61 #include <sensor_msgs/CameraInfo.h>
62 #include <sensor_msgs/JointState.h>
63 
64 #include <cv_bridge/cv_bridge.h>
66 
71 
72 #ifndef Q_MOC_RUN
73 #include <ros/ros.h>
74 #include <rviz/panel.h>
75 #endif
76 
77 Q_DECLARE_METATYPE(sensor_msgs::CameraInfo);
78 Q_DECLARE_METATYPE(std::string);
79 
80 namespace moveit_rviz_plugin
81 {
82 class HandEyeCalibrationDisplay;
83 
84 // **************************************************
85 // Custom QComboBox for image and camera_info topic
86 // **************************************************
87 class RosTopicComboBox : public QComboBox
88 {
89  Q_OBJECT
90 public:
91  explicit RosTopicComboBox(QWidget* parent = Q_NULLPTR) : QComboBox(parent)
92  {
93  }
94  ~RosTopicComboBox() = default;
95 
96  void addMsgsFilterType(QString msgs_type);
97 
98  bool hasTopic(const QString& topic_name);
99 
100  bool getFilteredTopics();
101 
102 protected:
103  void mousePressEvent(QMouseEvent* event);
104 
105  QSet<QString> message_types_;
106  QSet<QString> image_topics_;
107 };
108 
109 class TargetTabWidget : public QWidget
110 {
111  Q_OBJECT
112 public:
113  explicit TargetTabWidget(HandEyeCalibrationDisplay* pdisplay, QWidget* parent = Q_NULLPTR);
115  {
116  target_.reset();
117  target_plugins_loader_.reset();
118  camera_info_.reset();
119  }
120 
121  void loadWidget(const rviz::Config& config);
122  void saveWidget(rviz::Config& config);
123 
125 
126  bool createTargetInstance();
127 
128  void fillDictionaryIds(std::string id = "");
129 
130  void imageCallback(const sensor_msgs::ImageConstPtr& msg);
131 
132  void cameraInfoCallback(const sensor_msgs::CameraInfoConstPtr& msg);
133 
134 private Q_SLOTS:
135 
136  // Called when the current item of target_type_ changed
137  void targetTypeComboboxChanged(const QString& text);
138 
139  // Called to update GUI inputs to match selected target type
140  bool loadInputWidgetsForTargetType(const std::string& plugin_name);
141 
142  // Called when the create_target_btn clicked
143  void createTargetImageBtnClicked(bool clicked);
144 
145  // Called when the save_target_btn clicked
146  void saveTargetImageBtnClicked(bool clicked);
147 
148  // Called when the item of image_topic_field_ combobox is selected
149  void imageTopicComboboxChanged(const QString& topic);
150 
151  // Called when the item of camera_info_topic_field_ combobox is selected
152  void cameraInfoComboBoxChanged(const QString& topic);
153 
154 Q_SIGNALS:
155 
156  void cameraInfoChanged(sensor_msgs::CameraInfo msg);
157 
158  void opticalFrameChanged(const std::string& frame_id);
159 
160 private:
162 
163  // **************************************************************
164  // Qt components
165  // **************************************************************
166 
167  // Target params
168  QFormLayout* target_param_layout_;
169  QComboBox* target_type_;
170  std::vector<moveit_handeye_calibration::HandEyeTargetBase::Parameter> target_plugin_params_;
171  std::map<std::string, QWidget*> target_param_inputs_;
172 
173  // Target 3D pose recognition
176  std::map<std::string, RosTopicComboBox*> ros_topics_;
177 
178  // Target Image display, create and save
180  QPushButton* create_target_btn_;
181  QPushButton* save_target_btn_;
182 
183  // **************************************************************
184  // Variables
185  // **************************************************************
186 
187  cv::Mat target_image_;
188 
189  std::string optical_frame_;
190 
191  sensor_msgs::CameraInfoConstPtr camera_info_;
192 
193  // **************************************************************
194  // Ros components
195  // **************************************************************
197  std::unique_ptr<pluginlib::ClassLoader<moveit_handeye_calibration::HandEyeTargetBase> > target_plugins_loader_;
198  pluginlib::UniquePtr<moveit_handeye_calibration::HandEyeTargetBase> target_;
203  // tf broadcaster
205 };
206 
207 } // namespace moveit_rviz_plugin
moveit_rviz_plugin::RosTopicComboBox::~RosTopicComboBox
~RosTopicComboBox()=default
panel.h
moveit_rviz_plugin::TargetTabWidget::image_pub_
image_transport::Publisher image_pub_
Definition: handeye_target_widget.h:201
moveit_rviz_plugin::TargetTabWidget::createTargetInstance
bool createTargetInstance()
Definition: handeye_target_widget.cpp:372
moveit_rviz_plugin::TargetTabWidget::saveWidget
void saveWidget(rviz::Config &config)
Definition: handeye_target_widget.cpp:263
moveit_rviz_plugin::TargetTabWidget::opticalFrameChanged
void opticalFrameChanged(const std::string &frame_id)
image_transport::ImageTransport
moveit_rviz_plugin::RosTopicComboBox
Definition: handeye_target_widget.h:87
moveit_rviz_plugin::TargetTabWidget::loadInputWidgetsForTargetType
bool loadInputWidgetsForTargetType(const std::string &plugin_name)
Definition: handeye_target_widget.cpp:321
moveit_rviz_plugin::TargetTabWidget::tf_pub_
tf2_ros::TransformBroadcaster tf_pub_
Definition: handeye_target_widget.h:204
moveit_rviz_plugin::TargetTabWidget::image_topic_
RosTopicComboBox * image_topic_
Definition: handeye_target_widget.h:174
ros.h
moveit_rviz_plugin::TargetTabWidget::ros_topics_
std::map< std::string, RosTopicComboBox * > ros_topics_
Definition: handeye_target_widget.h:176
moveit_rviz_plugin::TargetTabWidget::create_target_btn_
QPushButton * create_target_btn_
Definition: handeye_target_widget.h:180
moveit_rviz_plugin::TargetTabWidget::cameraInfoComboBoxChanged
void cameraInfoComboBoxChanged(const QString &topic)
Definition: handeye_target_widget.cpp:585
moveit_rviz_plugin::RosTopicComboBox::addMsgsFilterType
void addMsgsFilterType(QString msgs_type)
Definition: handeye_target_widget.cpp:75
moveit_rviz_plugin::TargetTabWidget::target_type_
QComboBox * target_type_
Definition: handeye_target_widget.h:169
moveit_rviz_plugin::TargetTabWidget::image_sub_
image_transport::Subscriber image_sub_
Definition: handeye_target_widget.h:200
moveit_rviz_plugin::TargetTabWidget::target_image_
cv::Mat target_image_
Definition: handeye_target_widget.h:187
moveit_rviz_plugin::TargetTabWidget::fillDictionaryIds
void fillDictionaryIds(std::string id="")
moveit_rviz_plugin::TargetTabWidget::target_param_inputs_
std::map< std::string, QWidget * > target_param_inputs_
Definition: handeye_target_widget.h:171
moveit_rviz_plugin::TargetTabWidget::target_plugin_params_
std::vector< moveit_handeye_calibration::HandEyeTargetBase::Parameter > target_plugin_params_
Definition: handeye_target_widget.h:170
moveit_rviz_plugin::TargetTabWidget::target_param_layout_
QFormLayout * target_param_layout_
Definition: handeye_target_widget.h:168
moveit_rviz_plugin::RosTopicComboBox::RosTopicComboBox
RosTopicComboBox(QWidget *parent=Q_NULLPTR)
Definition: handeye_target_widget.h:91
image_transport::Subscriber
moveit_rviz_plugin::HandEyeCalibrationDisplay
Definition: handeye_calibration_display.h:89
moveit_rviz_plugin::RosTopicComboBox::message_types_
QSet< QString > message_types_
Definition: handeye_target_widget.h:105
moveit_rviz_plugin::TargetTabWidget::camerainfo_sub_
ros::Subscriber camerainfo_sub_
Definition: handeye_target_widget.h:202
moveit_rviz_plugin::TargetTabWidget
Definition: handeye_target_widget.h:109
moveit_rviz_plugin::RosTopicComboBox::getFilteredTopics
bool getFilteredTopics()
Definition: handeye_target_widget.cpp:86
handeye_calibration_display.h
Q_DECLARE_METATYPE
Q_DECLARE_METATYPE(sensor_msgs::CameraInfo)
moveit_rviz_plugin::TargetTabWidget::TargetTabWidget
TargetTabWidget(HandEyeCalibrationDisplay *pdisplay, QWidget *parent=Q_NULLPTR)
Definition: handeye_target_widget.cpp:119
moveit_rviz_plugin::TargetTabWidget::saveTargetImageBtnClicked
void saveTargetImageBtnClicked(bool clicked)
Definition: handeye_target_widget.cpp:535
moveit_rviz_plugin::TargetTabWidget::nh_
ros::NodeHandle nh_
Definition: handeye_target_widget.h:196
moveit_rviz_plugin::TargetTabWidget::loadAvailableTargetPlugins
bool loadAvailableTargetPlugins()
Definition: handeye_target_widget.cpp:288
moveit_rviz_plugin::TargetTabWidget::it_
image_transport::ImageTransport it_
Definition: handeye_target_widget.h:199
tf_visual_tools.h
moveit_rviz_plugin::TargetTabWidget::imageCallback
void imageCallback(const sensor_msgs::ImageConstPtr &msg)
Definition: handeye_target_widget.cpp:409
moveit_rviz_plugin::TargetTabWidget::cameraInfoChanged
void cameraInfoChanged(sensor_msgs::CameraInfo msg)
moveit_rviz_plugin::TargetTabWidget::createTargetImageBtnClicked
void createTargetImageBtnClicked(bool clicked)
Definition: handeye_target_widget.cpp:513
class_loader.hpp
moveit_rviz_plugin::TargetTabWidget::~TargetTabWidget
~TargetTabWidget()
Definition: handeye_target_widget.h:114
moveit_rviz_plugin::RosTopicComboBox::image_topics_
QSet< QString > image_topics_
Definition: handeye_target_widget.h:106
moveit_rviz_plugin::TargetTabWidget::targetTypeComboboxChanged
void targetTypeComboboxChanged(const QString &text)
Definition: handeye_target_widget.cpp:501
image_transport.h
moveit_rviz_plugin::TargetTabWidget::optical_frame_
std::string optical_frame_
Definition: handeye_target_widget.h:189
moveit_rviz_plugin::TargetTabWidget::camera_info_topic_
RosTopicComboBox * camera_info_topic_
Definition: handeye_target_widget.h:175
moveit_rviz_plugin
moveit_rviz_plugin::TargetTabWidget::target_
pluginlib::UniquePtr< moveit_handeye_calibration::HandEyeTargetBase > target_
Definition: handeye_target_widget.h:198
image_transport::Publisher
moveit_rviz_plugin::TargetTabWidget::calibration_display_
HandEyeCalibrationDisplay * calibration_display_
Definition: handeye_target_widget.h:161
moveit_rviz_plugin::TargetTabWidget::camera_info_
sensor_msgs::CameraInfoConstPtr camera_info_
Definition: handeye_target_widget.h:191
cv_bridge.h
tf2_ros::TransformBroadcaster
moveit_rviz_plugin::RosTopicComboBox::hasTopic
bool hasTopic(const QString &topic_name)
Definition: handeye_target_widget.cpp:80
moveit_rviz_plugin::TargetTabWidget::cameraInfoCallback
void cameraInfoCallback(const sensor_msgs::CameraInfoConstPtr &msg)
Definition: handeye_target_widget.cpp:489
moveit_rviz_plugin::TargetTabWidget::loadWidget
void loadWidget(const rviz::Config &config)
Definition: handeye_target_widget.cpp:195
moveit_rviz_plugin::TargetTabWidget::imageTopicComboboxChanged
void imageTopicComboboxChanged(const QString &topic)
Definition: handeye_target_widget.cpp:565
moveit_rviz_plugin::RosTopicComboBox::mousePressEvent
void mousePressEvent(QMouseEvent *event)
Definition: handeye_target_widget.cpp:113
moveit_rviz_plugin::TargetTabWidget::save_target_btn_
QPushButton * save_target_btn_
Definition: handeye_target_widget.h:181
moveit_rviz_plugin::TargetTabWidget::target_display_label_
QLabel * target_display_label_
Definition: handeye_target_widget.h:179
rviz::Config
moveit_rviz_plugin::TargetTabWidget::target_plugins_loader_
std::unique_ptr< pluginlib::ClassLoader< moveit_handeye_calibration::HandEyeTargetBase > > target_plugins_loader_
Definition: handeye_target_widget.h:197
ros::NodeHandle
ros::Subscriber
handeye_target_base.h


moveit_calibration_gui
Author(s): Yu Yan
autogenerated on Fri Oct 18 2024 02:14:15