head_control_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  * HeadControlModule.h
19  *
20  * Created on: 2016. 1. 27.
21  * Author: Kayman
22  */
23 
24 #ifndef THORMANG3_HEAD_CONTROL_MODULE_HEAD_CONTROL_MODULE_H_
25 #define THORMANG3_HEAD_CONTROL_MODULE_HEAD_CONTROL_MODULE_H_
26 
27 #include <ros/ros.h>
28 #include <ros/callback_queue.h>
29 #include <std_msgs/Empty.h>
30 #include <std_msgs/Float64.h>
31 #include <std_msgs/String.h>
32 #include <sensor_msgs/JointState.h>
33 #include <boost/thread.hpp>
34 #include <eigen3/Eigen/Eigen>
35 
36 #include "robotis_controller_msgs/StatusMsg.h"
37 
40 #include "thormang3_head_control_module_msgs/HeadJointPose.h"
41 
42 namespace thormang3
43 {
44 
46 {
47  public:
49  virtual ~HeadControlModule();
50 
51  void initialize(const int control_cycle_msec, robotis_framework::Robot *robot);
52  void process(std::map<std::string, robotis_framework::Dynamixel *> dxls, std::map<std::string, double> sensors);
53 
54  void stop();
55  bool isRunning();
56 
57  private:
58  const double SCAN_START_ANGLE = -10 * M_PI / 180;
59  const double SCAN_END_ANGLE = 85 * M_PI / 180;
60 
61  /* ROS Topic Callback Functions */
62  void get3DLidarCallback(const std_msgs::String::ConstPtr &msg);
63  void get3DLidarRangeCallback(const std_msgs::Float64::ConstPtr &msg);
64  void setHeadJointCallback(const sensor_msgs::JointState::ConstPtr &msg);
65  void setHeadJointTimeCallback(const thormang3_head_control_module_msgs::HeadJointPose::ConstPtr &msg);
66 
67  void queueThread();
68  void jointTraGeneThread();
70 
71  void beforeMoveLidar(double start_angle);
72  void startMoveLidar(double target_angle);
73  void afterMoveLidar();
74  void publishLidarMoveMsg(std::string msg_data);
75  void publishDoneMsg(const std::string done_msg);
76 
77  void startMoving();
78  void finishMoving();
79  void stopMoving();
80 
81  void publishStatusMsg(unsigned int type, std::string msg);
82 
83  Eigen::MatrixXd calcMinimumJerkTraPVA(double pos_start, double vel_start, double accel_start, double pos_end,
84  double vel_end, double accel_end, double smp_time, double mov_time);
85 
86  Eigen::MatrixXd calcLinearInterpolationTra(double pos_start, double pos_end, double smp_time, double mov_time);
87 
89  boost::thread queue_thread_;
90  boost::thread *tra_gene_thread_;
91  boost::mutex tra_lock_;
95  const bool DEBUG;
97  bool is_moving_;
100  double moving_time_;
103  double scan_range_;
104 
105  Eigen::MatrixXd target_position_;
106  Eigen::MatrixXd current_position_;
107  Eigen::MatrixXd goal_position_;
108  Eigen::MatrixXd goal_velocity_;
109  Eigen::MatrixXd goal_acceleration_;
110  Eigen::MatrixXd calc_joint_tra_;
111  Eigen::MatrixXd calc_joint_vel_tra_;
112  Eigen::MatrixXd calc_joint_accel_tra_;
113 
114  std::map<std::string, int> using_joint_name_;
115 
117  {
124  };
125 };
126 }
127 
128 #endif /* THORMANG3_HEAD_CONTROL_MODULE_HEAD_CONTROL_MODULE_H_ */
void setHeadJointTimeCallback(const thormang3_head_control_module_msgs::HeadJointPose::ConstPtr &msg)
std::map< std::string, int > using_joint_name_
Eigen::MatrixXd calcLinearInterpolationTra(double pos_start, double pos_end, double smp_time, double mov_time)
void publishDoneMsg(const std::string done_msg)
void startMoveLidar(double target_angle)
void get3DLidarCallback(const std_msgs::String::ConstPtr &msg)
Eigen::MatrixXd calcMinimumJerkTraPVA(double pos_start, double vel_start, double accel_start, double pos_end, double vel_end, double accel_end, double smp_time, double mov_time)
void setHeadJointCallback(const sensor_msgs::JointState::ConstPtr &msg)
void publishStatusMsg(unsigned int type, std::string msg)
void initialize(const int control_cycle_msec, robotis_framework::Robot *robot)
void process(std::map< std::string, robotis_framework::Dynamixel * > dxls, std::map< std::string, double > sensors)
void publishLidarMoveMsg(std::string msg_data)
void get3DLidarRangeCallback(const std_msgs::Float64::ConstPtr &msg)
void beforeMoveLidar(double start_angle)


thormang3_head_control_module
Author(s): Zerom , SCH , Kayman
autogenerated on Mon Jun 10 2019 15:37:48