moveit2
The MoveIt Motion Planning Framework for ROS 2.
robot_poses_widget.hpp
Go to the documentation of this file.
1 /*********************************************************************
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2012, Willow Garage, Inc.
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: Dave Coleman */
36 
37 #pragma once
38 
39 // Qt
40 #include <QComboBox>
41 #include <QLabel>
42 #include <QLineEdit>
43 #include <QPushButton>
44 #include <QScrollArea>
45 #include <QSlider>
46 #include <QStackedWidget>
47 #include <QTableWidget>
48 #include <QVBoxLayout>
49 
50 // SA
53 
54 namespace moveit_setup
55 {
56 namespace srdf_setup
57 {
59 {
60  Q_OBJECT
61 
62 public:
63  // ******************************************************************************************
64  // Public Functions
65  // ******************************************************************************************
66 
67  void onInit() override;
68 
70  void focusGiven() override;
71 
72  SetupStep& getSetupStep() override
73  {
74  return setup_step_;
75  }
76 
77  // ******************************************************************************************
78  // Qt Components
79  // ******************************************************************************************
80  QTableWidget* data_table_;
81  QPushButton* btn_edit_;
82  QPushButton* btn_delete_;
83  QPushButton* btn_save_;
84  QPushButton* btn_cancel_;
85  QStackedWidget* stacked_widget_;
86  QScrollArea* scroll_area_;
87  QVBoxLayout* column2_;
88  QLineEdit* pose_name_field_;
89  QComboBox* group_name_field_;
91  QVBoxLayout* joint_list_layout_;
95 
96 private Q_SLOTS:
97 
98  // ******************************************************************************************
99  // Slot Event Functions
100  // ******************************************************************************************
101 
103  void showNewScreen();
104 
106  void editSelected();
107 
109  void editDoubleClicked(int row, int column);
110 
112  void previewClicked(int row, int column, int previous_row, int previous_column);
113 
115  void deleteSelected();
116 
118  void doneEditing();
119 
121  void cancelEditing();
122 
124  void loadJointSliders(const QString& selected);
125 
127  void showDefaultPose();
128 
130  void playPoses();
131 
138  void updateRobotModel(const std::string& name, double value);
139 
140 private:
141  // ******************************************************************************************
142  // Variables
143  // ******************************************************************************************
144 
145  RobotPoses setup_step_;
146 
148  srdf::Model::GroupState* current_edit_pose_;
149 
150  // ******************************************************************************************
151  // Private Functions
152  // ******************************************************************************************
153 
159  QWidget* createContentsWidget();
160 
166  QWidget* createEditWidget();
167 
172  void loadDataTable();
173 
178  void loadGroupsComboBox();
179 
185  void edit(int row);
186 
190  void showPose(const srdf::Model::GroupState& pose);
191 
192  void updateStateAndCollision(const moveit::core::RobotState& robot_state);
193 };
194 
195 // ******************************************************************************************
196 // ******************************************************************************************
197 // Slider Widget
198 // ******************************************************************************************
199 // ******************************************************************************************
200 class SliderWidget : public QWidget
201 {
202  Q_OBJECT
203 
204 public:
205  // ******************************************************************************************
206  // Public Functions
207  // ******************************************************************************************
208 
215  SliderWidget(QWidget* parent, const moveit::core::JointModel* joint_model, double init_value);
216 
220  ~SliderWidget() override;
221 
222  // ******************************************************************************************
223  // Qt Components
224  // ******************************************************************************************
225 
226  QLabel* joint_label_;
227  QSlider* joint_slider_;
228  QLineEdit* joint_value_;
229 
230 private Q_SLOTS:
231 
232  // ******************************************************************************************
233  // Slot Event Functions
234  // ******************************************************************************************
235 
237  void changeJointValue(int value);
238 
240  void changeJointSlider();
241 
242 Q_SIGNALS:
243 
244  // ******************************************************************************************
245  // Emitted Signal Functions
246  // ******************************************************************************************
247 
249  void jointValueChanged(const std::string& name, double value);
250 
251 private:
252  // ******************************************************************************************
253  // Variables
254  // ******************************************************************************************
255 
256  // Ptr to the joint's data
257  const moveit::core::JointModel* joint_model_;
258 
259  // Max & min position
260  double max_position_;
261  double min_position_;
262 
263  // ******************************************************************************************
264  // Private Functions
265  // ******************************************************************************************
266 };
267 
268 } // namespace srdf_setup
269 } // namespace moveit_setup
270 
271 // Declare std::string as metatype so we can use it in a signal
272 Q_DECLARE_METATYPE(std::string)
A joint from the robot. Models the transform that this joint applies in the kinematic chain....
Definition: joint_model.h:117
Representation of a robot's state. This includes position, velocity, acceleration and effort.
Definition: robot_state.h:90
The GUI code for one SetupStep.
Contains all of the non-GUI code necessary for doing one "screen" worth of setup.
Definition: setup_step.hpp:47
void focusGiven() override
Received when this widget is chosen from the navigation menu.
SetupStep & getSetupStep() override
Return a reference to the SetupStep object.
SliderWidget(QWidget *parent, const moveit::core::JointModel *joint_model, double init_value)
void jointValueChanged(const std::string &name, double value)
Indicate joint name and value when slider widget changed.
name
Definition: setup.py:7
Q_DECLARE_METATYPE(moveit_setup::srdf_setup::PlanGroupType)