base_module.h
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 /*
18  * DemoModule.h
19  *
20  * Created on: 2016. 3. 9.
21  * Author: SCH
22  */
23 
24 #ifndef MANIPULATOR_BASE_MODULE_BASE_MODULE_H_
25 #define MANIPULATOR_BASE_MODULE_BASE_MODULE_H_
26 
27 #include <map>
28 #include <ros/ros.h>
29 #include <ros/callback_queue.h>
30 #include <ros/package.h>
31 #include <std_msgs/Int16.h>
32 #include <std_msgs/Float64.h>
33 #include <std_msgs/String.h>
34 #include <geometry_msgs/Pose.h>
35 #include <boost/thread.hpp>
36 #include <yaml-cpp/yaml.h>
37 
40 
41 #include "robotis_controller_msgs/JointCtrlModule.h"
42 #include "robotis_controller_msgs/StatusMsg.h"
43 
44 #include "manipulator_h_base_module_msgs/JointPose.h"
45 #include "manipulator_h_base_module_msgs/KinematicsPose.h"
46 
47 #include "manipulator_h_base_module_msgs/GetJointPose.h"
48 #include "manipulator_h_base_module_msgs/GetKinematicsPose.h"
49 
51 #include "robotis_state.h"
52 
53 namespace robotis_manipulator_h
54 {
55 
56 //using namespace ROBOTIS_DEMO;
57 
59 {
60 public:
61  double position_;
62  double velocity_;
63  double effort_;
64 
65  int p_gain_;
66  int i_gain_;
67  int d_gain_;
68 };
69 
71 {
72 public:
73  BaseJointData curr_joint_state_[ MAX_JOINT_ID + 1];
74  BaseJointData goal_joint_state_[ MAX_JOINT_ID + 1];
75  BaseJointData fake_joint_state_[ MAX_JOINT_ID + 1];
76 };
77 
80  public robotis_framework::Singleton<BaseModule>
81 {
82 private:
84  boost::thread queue_thread_;
85  boost::thread *tra_gene_thread_;
86 
89 
90  std::map<std::string, int> joint_name_to_id_;
91 
92  void queueThread();
93 
94  void parseIniPoseData(const std::string &path);
95  void publishStatusMsg(unsigned int type, std::string msg);
96 
97 public:
98  BaseModule();
99  virtual ~BaseModule();
100 
101  /* ROS Topic Callback Functions */
102  void initPoseMsgCallback(const std_msgs::String::ConstPtr& msg);
103  void setModeMsgCallback(const std_msgs::String::ConstPtr& msg);
104 
105  void jointPoseMsgCallback(const manipulator_h_base_module_msgs::JointPose::ConstPtr& msg);
106  void kinematicsPoseMsgCallback(const manipulator_h_base_module_msgs::KinematicsPose::ConstPtr& msg);
107 
108  bool getJointPoseCallback(manipulator_h_base_module_msgs::GetJointPose::Request &req,
109  manipulator_h_base_module_msgs::GetJointPose::Response &res);
110  bool getKinematicsPoseCallback(manipulator_h_base_module_msgs::GetKinematicsPose::Request &req,
111  manipulator_h_base_module_msgs::GetKinematicsPose::Response &res);
112 
113  /* ROS Calculation Functions */
114  void generateInitPoseTrajProcess();
115  void generateJointTrajProcess();
116  void generateTaskTrajProcess();
117 
118  /* ROS Framework Functions */
119  void initialize(const int control_cycle_msec, robotis_framework::Robot *robot);
120  void process(std::map<std::string, robotis_framework::Dynamixel *> dxls, std::map<std::string, double> sensors);
121 
122  void stop();
123  bool isRunning();
124 
125  /* Parameter */
129 };
130 
131 }
132 
133 #endif /* MANIPULATOR_BASE_MODULE_BASE_MODULE_H_ */
ROSCONSOLE_DECL void initialize()
#define MAX_JOINT_ID
std::map< std::string, int > joint_name_to_id_
Definition: base_module.h:90
ManipulatorKinematicsDynamics * manipulator_
Definition: base_module.h:128


manipulator_h_base_module
Author(s): SCH
autogenerated on Mon Jun 10 2019 14:02:58