main_window.hpp
Go to the documentation of this file.
1 /*******************************************************************************
2 * Copyright 2018 ROBOTIS CO., LTD.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *******************************************************************************/
16 
17 /* Author: Kayman Jung */
18 
19 #ifndef thormang3_demo_MAIN_WINDOW_H
20 #define thormang3_demo_MAIN_WINDOW_H
21 
22 /*****************************************************************************
23  ** Includes
24  *****************************************************************************/
25 
26 #include <QtGui/QMainWindow>
27 #include "ui_main_window.h"
28 #include "qnode.hpp"
29 
30 /*****************************************************************************
31  ** Namespace
32  *****************************************************************************/
33 
34 namespace thormang3_demo
35 {
36 
37 /*****************************************************************************
38  ** Interface [MainWindow]
39  *****************************************************************************/
43 class MainWindow : public QMainWindow
44 {
45 Q_OBJECT
46 
47  public:
48  MainWindow(int argc, char** argv, QWidget *parent = 0);
49  ~MainWindow();
50 
51  void readSettings(); // Load up qt program settings at startup
52  void writeSettings(); // Save qt program settings when closing
53 
54  void closeEvent(QCloseEvent *event); // Overloaded function
55 
56  public Q_SLOTS:
57  /******************************************
58  ** Auto-connections (connectSlotsByName())
59  *******************************************/
62  void on_button_clear_log_clicked(bool check);
63 
64  void on_button_init_pose_clicked(bool check);
65  void on_button_ft_air_clicked(bool check);
66  void on_button_ft_gnd_clicked(bool check);
67  void on_button_ft_calc_clicked(bool check);
68  void on_button_ft_save_clicked(bool check);
69 
71 
72  // Manipulation
73  void on_inipose_button_clicked(bool check);
74  void on_currjoint_button_clicked(bool check);
75  void on_desjoint_button_clicked(bool check);
76  void on_get_despos_button_clicked(bool check);
77  void on_currpos_button_clicked(bool check);
78  void on_despos_button_clicked(bool check);
79  void on_button_grip_on_clicked(bool check);
80  void on_button_grip_off_clicked(bool check);
81 
82  // Walking
83  void on_A0_button_fl_clicked(bool check);
84  void on_A1_button_f_clicked(bool check);
85  void on_A2_button_fr_clicked(bool check);
86 
87  void on_B0_button_l_clicked(bool check);
88  void on_B1_button_stop_clicked(bool check);
89  void on_B2_button_r_clicked(bool check);
90 
91  void on_C0_button_bl_clicked(bool check);
92  void on_C1_button_b_clicked(bool check);
93  void on_C2_button_br_clicked(bool check);
94 
95  void on_button_balance_on_clicked(bool check);
96  void on_button_balance_off_clicked(bool check);
98 
99  void on_A0_button_get_step_clicked(bool check);
100  void on_A1_button_clear_step_clicked(bool check);
101  void on_A2_button_go_walking_clicked(bool check);
102 
103  // Head Control
104  void on_head_center_button_clicked(bool check);
105 
106  // Interactive Marker
107  void on_dSpinBox_marker_pos_x_valueChanged(double value);
108  void on_dSpinBox_marker_pos_y_valueChanged(double value);
109  void on_dSpinBox_marker_pos_z_valueChanged(double value);
110 
111  void on_dSpinBox_marker_ori_r_valueChanged(double value);
112  void on_dSpinBox_marker_ori_p_valueChanged(double value);
113  void on_dSpinBox_marker_ori_y_valueChanged(double value);
114 
117 
118  // Demo
119  void on_button_manipulation_demo_0_clicked(bool check);
120  void on_button_manipulation_demo_1_clicked(bool check);
121  void on_button_manipulation_demo_2_clicked(bool check);
122  void on_button_manipulation_demo_3_clicked(bool check);
123  void on_button_manipulation_demo_4_clicked(bool check);
124  void on_button_manipulation_demo_5_clicked(bool check);
125  void on_button_manipulation_demo_6_clicked(bool check);
126  void on_button_manipulation_demo_7_clicked(bool check);
127 
128  void on_button_walking_demo_0_clicked(bool check);
129  void on_button_walking_demo_1_clicked(bool check);
130  void on_button_walking_demo_2_clicked(bool check);
131  void on_button_walking_demo_3_clicked(bool check);
132  void on_button_walking_demo_4_clicked(bool check);
133  void on_button_walking_demo_5_clicked(bool check);
134  void on_button_walking_demo_6_clicked(bool check);
135  void on_button_walking_demo_7_clicked(bool check);
136 
137  void on_button_motion_demo_0_clicked(bool check);
138  void on_button_motion_demo_1_clicked(bool check);
139 
140  /******************************************
141  ** Manual connections
142  *******************************************/
143  void updateLoggingView(); // no idea why this can't connect automatically
144  void updatePresentJointModule(std::vector<int> mode);
145  void enableModule(QString mode_name);
146  void updateHeadJointsAngle(double pan, double tilt);
147 
148  // Manipulation
149  void updateCurrJointSpinbox(double value);
150  void updateCurrPosSpinbox(double x, double y, double z);
151  void updateCurrOriSpinbox(double x, double y, double z, double w);
152  void updateCurrOriSpinbox(double r, double p, double y);
153 
154  // demo
155  void updatePointPanel(const geometry_msgs::Point point);
156  void updatePosePanel(const geometry_msgs::Pose pose);
157 
158  protected Q_SLOTS:
159  void setHeadJointsAngle();
160  void playMotion(int motion_index);
161 
162  private:
163  static const double GRIPPER_ON_ANGLE = 60;
164  static const double GRIPPER_OFF_ANGLE = 5;
165  static const double GRIPPER_TORQUE_LIMIT = 250;
166 
167  void setUserShortcut();
168  void initModeUnit();
169  void initMotionUnit();
170  void updateModuleUI();
171  void setHeadJointsAngle(double pan, double tilt);
172  void sendWalkingCommand(const std::string &command);
173  void setGripper(const double angle_deg, const double torque_limit, const std::string &arm_type);
174 
175  void makeInteractiveMarker();
177  void clearMarkerPanel();
178  void getPoseFromMarkerPanel(geometry_msgs::Pose &current);
179  void setPoseToMarkerPanel(const geometry_msgs::Pose &current);
180  void getPointFromMarkerPanel(geometry_msgs::Point &current);
181  void setPointToMarkerPanel(const geometry_msgs::Point &current);
182 
183  /******************************************
184  ** Transformation
185  *******************************************/
186  Eigen::Vector3d rotation2rpy(const Eigen::MatrixXd &rotation);
187  Eigen::MatrixXd rpy2rotation(const double &roll, const double &pitch, const double &yaw);
188  Eigen::Quaterniond rpy2quaternion(const Eigen::Vector3d &euler);
189  Eigen::Quaterniond rpy2quaternion(const double &roll, const double &pitch, const double &yaw);
190  Eigen::Quaterniond rotation2quaternion(const Eigen::MatrixXd &rotation);
191  Eigen::Vector3d quaternion2rpy(const Eigen::Quaterniond &quaternion);
192  Eigen::Vector3d quaternion2rpy(const geometry_msgs::Quaternion &quaternion);
193  Eigen::MatrixXd quaternion2rotation(const Eigen::Quaterniond &quaternion);
194  Eigen::MatrixXd rotationX(const double &angle);
195  Eigen::MatrixXd rotationY(const double &angle);
196  Eigen::MatrixXd rotationZ(const double &angle);
197 
198  Ui::MainWindowDesign ui_;
203  std::map<std::string, QList<QWidget *> > module_ui_table_;
204 };
205 
206 template<typename T>
207 T deg2rad(T deg)
208 {
209  return deg * M_PI / 180;
210 }
211 
212 template<typename T>
213 T rad2deg(T rad)
214 {
215  return rad * 180 / M_PI;
216 }
217 
218 } // namespace thormang3_demo
219 
220 #endif // thormang3_demo_MAIN_WINDOW_H
void on_button_walking_demo_1_clicked(bool check)
void on_C2_button_br_clicked(bool check)
Eigen::Vector3d quaternion2rpy(const Eigen::Quaterniond &quaternion)
void on_dSpinBox_marker_ori_y_valueChanged(double value)
void on_dSpinBox_marker_ori_p_valueChanged(double value)
void on_button_balance_off_clicked(bool check)
void on_button_grip_on_clicked(bool check)
ROSCPP_DECL bool check()
void on_button_ft_calc_clicked(bool check)
Eigen::MatrixXd rpy2rotation(const double &roll, const double &pitch, const double &yaw)
void on_despos_button_clicked(bool check)
Eigen::MatrixXd rotationX(const double &angle)
void on_button_manipulation_demo_7_clicked(bool check)
void setGripper(const double angle_deg, const double torque_limit, const std::string &arm_type)
Eigen::Quaterniond rotation2quaternion(const Eigen::MatrixXd &rotation)
std::map< std::string, QList< QWidget * > > module_ui_table_
void updatePointPanel(const geometry_msgs::Point point)
void on_A1_button_f_clicked(bool check)
void on_button_feedback_gain_apply_clicked(bool check)
void on_button_manipulation_demo_6_clicked(bool check)
void updatePresentJointModule(std::vector< int > mode)
void on_A2_button_go_walking_clicked(bool check)
void on_A2_button_fr_clicked(bool check)
void on_button_clear_log_clicked(bool check)
static const double GRIPPER_TORQUE_LIMIT
void updateCurrOriSpinbox(double x, double y, double z, double w)
void on_button_assemble_lidar_clicked(bool check)
#define M_PI
void on_B2_button_r_clicked(bool check)
Eigen::MatrixXd rotationY(const double &angle)
void closeEvent(QCloseEvent *event)
void on_button_walking_demo_6_clicked(bool check)
void on_button_ft_save_clicked(bool check)
void on_dSpinBox_marker_ori_r_valueChanged(double value)
void on_A0_button_fl_clicked(bool check)
void updateCurrJointSpinbox(double value)
void on_currpos_button_clicked(bool check)
Ui::MainWindowDesign ui_
void on_button_manipulation_demo_2_clicked(bool check)
void on_button_motion_demo_1_clicked(bool check)
T deg2rad(T deg)
void on_dSpinBox_marker_pos_y_valueChanged(double value)
void on_currjoint_button_clicked(bool check)
void enableModule(QString mode_name)
void sendWalkingCommand(const std::string &command)
void on_button_manipulation_demo_0_clicked(bool check)
static const double GRIPPER_OFF_ANGLE
void on_button_walking_demo_0_clicked(bool check)
void getPointFromMarkerPanel(geometry_msgs::Point &current)
void on_button_manipulation_demo_5_clicked(bool check)
void on_B1_button_stop_clicked(bool check)
void on_button_manipulation_demo_3_clicked(bool check)
void on_C1_button_b_clicked(bool check)
void on_A1_button_clear_step_clicked(bool check)
Qt central, all operations relating to the view part here.
Definition: main_window.hpp:43
void on_button_walking_demo_2_clicked(bool check)
x
void on_button_walking_demo_3_clicked(bool check)
void on_button_init_pose_clicked(bool check)
void playMotion(int motion_index)
void on_get_despos_button_clicked(bool check)
void setPointToMarkerPanel(const geometry_msgs::Point &current)
void getPoseFromMarkerPanel(geometry_msgs::Pose &current)
void on_button_walking_demo_4_clicked(bool check)
void updatePosePanel(const geometry_msgs::Pose pose)
void on_button_manipulation_demo_1_clicked(bool check)
Eigen::Vector3d rotation2rpy(const Eigen::MatrixXd &rotation)
void on_B0_button_l_clicked(bool check)
void on_inipose_button_clicked(bool check)
TFSIMD_FORCE_INLINE const tfScalar & z() const
y
MainWindow(int argc, char **argv, QWidget *parent=0)
Definition: main_window.cpp:41
void on_button_ft_air_clicked(bool check)
TFSIMD_FORCE_INLINE const tfScalar & w() const
void on_dSpinBox_marker_pos_x_valueChanged(double value)
void on_A0_button_get_step_clicked(bool check)
static const double GRIPPER_ON_ANGLE
void on_button_balance_on_clicked(bool check)
void on_button_walking_demo_7_clicked(bool check)
T rad2deg(T rad)
void on_button_walking_demo_5_clicked(bool check)
void on_button_grip_off_clicked(bool check)
void updateHeadJointsAngle(double pan, double tilt)
void on_head_center_button_clicked(bool check)
void on_desjoint_button_clicked(bool check)
void on_C0_button_bl_clicked(bool check)
void on_button_manipulation_demo_4_clicked(bool check)
void updateCurrPosSpinbox(double x, double y, double z)
void on_button_ft_gnd_clicked(bool check)
void on_tabWidget_control_currentChanged(int index)
Eigen::Quaterniond rpy2quaternion(const Eigen::Vector3d &euler)
Eigen::MatrixXd rotationZ(const double &angle)
Eigen::MatrixXd quaternion2rotation(const Eigen::Quaterniond &quaternion)
void on_dSpinBox_marker_pos_z_valueChanged(double value)
void on_button_motion_demo_0_clicked(bool check)
void setPoseToMarkerPanel(const geometry_msgs::Pose &current)


thormang3_demo
Author(s): Kayman
autogenerated on Mon Jun 10 2019 15:38:34