qnode.hpp
Go to the documentation of this file.
1 /*******************************************************************************
2 * Copyright 2019 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 /* Authors: Darby Lim, Hye-Jong KIM, Ryan Shim, Yong-Ho Na */
18 
19 /*****************************************************************************
20 ** Ifdefs
21 *****************************************************************************/
22 
23 #ifndef OPEN_MANIPULATOR_P_CONTROL_GUI_QNODE_HPP_
24 #define OPEN_MANIPULATOR_P_CONTROL_GUI_QNODE_HPP_
25 
26 /*****************************************************************************
27 ** Includes
28 *****************************************************************************/
29 
30 // To workaround boost/qt4 problems that won't be bugfixed. Refer to
31 // https://bugreports.qt.io/browse/QTBUG-22829
32 #ifndef Q_MOC_RUN
33 #include <ros/ros.h>
34 #endif
35 #include <string>
36 #include <QThread>
37 #include <QStringListModel>
38 
39 #include <sensor_msgs/JointState.h>
40 #include <std_msgs/String.h>
41 
42 #include <eigen3/Eigen/Eigen>
43 
45 
46 #include "open_manipulator_msgs/OpenManipulatorState.h"
47 #include "open_manipulator_msgs/SetJointPosition.h"
48 #include "open_manipulator_msgs/SetKinematicsPose.h"
49 #include "open_manipulator_msgs/SetDrawingTrajectory.h"
50 #include "open_manipulator_msgs/SetActuatorState.h"
51 
52 #define NUM_OF_JOINT_AND_TOOL 7
53 
54 /*****************************************************************************
55 ** Namespaces
56 *****************************************************************************/
57 
59 
60 /*****************************************************************************
61 ** Class
62 *****************************************************************************/
63 
64 class QNode : public QThread {
65  Q_OBJECT
66 public:
67  QNode(int argc, char** argv );
68  virtual ~QNode();
69  bool init();
70  void run();
71 
72  /*********************
73  ** Logging
74  **********************/
75  enum LogLevel {
81  };
82 
83  QStringListModel* loggingModel() { return &logging_model; }
84  void log( const LogLevel &level, const std::string &msg);
85 
86  void manipulatorStatesCallback(const open_manipulator_msgs::OpenManipulatorState::ConstPtr &msg);
87  void jointStatesCallback(const sensor_msgs::JointState::ConstPtr &msg);
88  void kinematicsPoseCallback(const open_manipulator_msgs::KinematicsPose::ConstPtr &msg);
89 
90  std::vector<double> getPresentJointAngle();
91  std::vector<double> getPresentKinematicsPosition();
92  Eigen::Quaterniond getPresentKinematicsOrientation();
93  Eigen::Vector3d getPresentKinematicsOrientationRPY();
96  bool getWithGripperState();
97 
98  void setOption(std::string opt);
99  bool setJointSpacePath(std::vector<std::string> joint_name, std::vector<double> joint_angle, double path_time);
100  bool setTaskSpacePath(std::vector<double> kinematics_pose, double path_time);
101  bool setDrawingTrajectory(std::string name, std::vector<double> arg, double path_time);
102  bool setToolControl(std::vector<double> joint_angle);
103  bool setActuatorState(bool actuator_state);
104 
105 Q_SIGNALS:
106  void rosShutdown();
107 
108 private:
110  char** init_argv;
111  QStringListModel logging_model;
112 
113  // ROS Parameters
115 
116  // ROS Publishers
118 
119  // ROS Subscribers
123 
124  // ROS Service Clients
131 
132  std::vector<double> present_joint_angle_;
133  std::vector<double> present_kinematics_position_;
136  open_manipulator_msgs::KinematicsPose kinematics_pose_;
137 
140 };
141 
142 } // namespace open_manipulator_p_control_gui
143 
144 #endif /* OPEN_MANIPULATOR_P_CONTROL_GUI_QNODE_HPP_ */
std::vector< double > getPresentJointAngle()
Definition: qnode.cpp:146
ros::ServiceClient goal_tool_control_client_
Definition: qnode.hpp:128
void log(const LogLevel &level, const std::string &msg)
bool setActuatorState(bool actuator_state)
Definition: qnode.cpp:251
ros::ServiceClient goal_drawing_trajectory_client_
Definition: qnode.hpp:130
void setOption(std::string opt)
Definition: qnode.cpp:177
ros::Subscriber open_manipulator_joint_states_sub_
Definition: qnode.hpp:121
Eigen::Quaterniond present_kinematics_orientation_
Definition: qnode.hpp:134
std::vector< double > present_kinematics_position_
Definition: qnode.hpp:133
void manipulatorStatesCallback(const open_manipulator_msgs::OpenManipulatorState::ConstPtr &msg)
Definition: qnode.cpp:96
Eigen::Quaterniond getPresentKinematicsOrientation()
Definition: qnode.cpp:154
void jointStatesCallback(const sensor_msgs::JointState::ConstPtr &msg)
Definition: qnode.cpp:108
ros::Subscriber open_manipulator_kinematics_pose_sub_
Definition: qnode.hpp:122
Eigen::Vector3d present_kinematics_orientation_rpy_
Definition: qnode.hpp:135
QStringListModel * loggingModel()
Definition: qnode.hpp:83
std::vector< double > getPresentKinematicsPosition()
Definition: qnode.cpp:150
bool setJointSpacePath(std::vector< std::string > joint_name, std::vector< double > joint_angle, double path_time)
Definition: qnode.cpp:184
ros::Publisher open_manipulator_option_pub_
Definition: qnode.hpp:117
std::vector< double > present_joint_angle_
Definition: qnode.hpp:132
QNode(int argc, char **argv)
Definition: qnode.cpp:40
open_manipulator_msgs::KinematicsPose kinematics_pose_
Definition: qnode.hpp:136
bool setDrawingTrajectory(std::string name, std::vector< double > arg, double path_time)
Definition: qnode.cpp:222
bool setTaskSpacePath(std::vector< double > kinematics_pose, double path_time)
Definition: qnode.cpp:198
ros::ServiceClient goal_joint_space_path_client_
Definition: qnode.hpp:125
Eigen::Vector3d getPresentKinematicsOrientationRPY()
Definition: qnode.cpp:158
ros::ServiceClient goal_task_space_path_position_only_client_
Definition: qnode.hpp:126
void kinematicsPoseCallback(const open_manipulator_msgs::KinematicsPose::ConstPtr &msg)
Definition: qnode.cpp:131
ros::Subscriber open_manipulator_states_sub_
Definition: qnode.hpp:120
ros::ServiceClient goal_task_space_path_client_
Definition: qnode.hpp:127
ros::ServiceClient set_actuator_state_client_
Definition: qnode.hpp:129
bool setToolControl(std::vector< double > joint_angle)
Definition: qnode.cpp:238


open_manipulator_p_control_gui
Author(s): Ryan Shim , Yong-Ho Na , Hye-Jong KIM
autogenerated on Thu Oct 22 2020 03:16:32