walking_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  * online_walking_module.h
19  *
20  * Created on: 2016. 9. 30.
21  * Author: Jay Song
22  */
23 
24 #ifndef THORMANG3_ONLINE_WALKING_MODULE_ONLINE_WALKING_MODULE_H_
25 #define THORMANG3_ONLINE_WALKING_MODULE_ONLINE_WALKING_MODULE_H_
26 
27 #include <ros/ros.h>
28 #include <ros/callback_queue.h>
29 #include <std_msgs/String.h>
30 #include <sensor_msgs/Imu.h>
31 #include <geometry_msgs/PoseStamped.h>
32 #include <boost/thread.hpp>
33 #include <eigen3/Eigen/Eigen>
34 
36 
37 #include "robotis_controller_msgs/StatusMsg.h"
38 #include "thormang3_walking_module_msgs/RobotPose.h"
39 #include "thormang3_walking_module_msgs/GetReferenceStepData.h"
40 #include "thormang3_walking_module_msgs/AddStepDataArray.h"
41 #include "thormang3_walking_module_msgs/StartWalking.h"
42 #include "thormang3_walking_module_msgs/IsRunning.h"
43 #include "thormang3_walking_module_msgs/RemoveExistingStepData.h"
44 #include "thormang3_walking_module_msgs/SetBalanceParam.h"
45 #include "thormang3_walking_module_msgs/SetJointFeedBackGain.h"
46 
48 
49 #define WALKING_TUNE
50 #ifdef WALKING_TUNE
51 #include "thormang3_walking_module_msgs/WalkingJointStatesStamped.h"
52 #endif
53 
54 namespace thormang3
55 {
56 
58 {
59 public:
61  virtual ~OnlineWalkingModule();
62 
63  void initialize(const int control_cycle_msec, robotis_framework::Robot *robot);
64  void process(std::map<std::string, robotis_framework::Dynamixel *> dxls, std::map<std::string, double> sensors);
65 
66  void onModuleEnable();
67  void onModuleDisable();
68 
69  void stop();
70  bool isRunning();
71 
78 
79 private:
80  void publishRobotPose(void);
81  void publishStatusMsg(unsigned int type, std::string msg);
82  void publishDoneMsg(std::string msg);
83 #ifdef WALKING_TUNE
85 #endif
86 
87  /* ROS Topic Callback Functions */
88  void imuDataOutputCallback(const sensor_msgs::Imu::ConstPtr &msg);
89 
90  /* ROS Service Callback Functions */
91  bool setBalanceParamServiceCallback(thormang3_walking_module_msgs::SetBalanceParam::Request &req,
92  thormang3_walking_module_msgs::SetBalanceParam::Response &res);
93 
94  bool setJointFeedBackGainServiceCallback(thormang3_walking_module_msgs::SetJointFeedBackGain::Request &req,
95  thormang3_walking_module_msgs::SetJointFeedBackGain::Response &res);
96 
97  bool getReferenceStepDataServiceCallback(thormang3_walking_module_msgs::GetReferenceStepData::Request &req,
98  thormang3_walking_module_msgs::GetReferenceStepData::Response &res);
99  bool addStepDataServiceCallback(thormang3_walking_module_msgs::AddStepDataArray::Request &req,
100  thormang3_walking_module_msgs::AddStepDataArray::Response &res);
101  bool startWalkingServiceCallback(thormang3_walking_module_msgs::StartWalking::Request &req,
102  thormang3_walking_module_msgs::StartWalking::Response &res);
103  bool IsRunningServiceCallback(thormang3_walking_module_msgs::IsRunning::Request &req,
104  thormang3_walking_module_msgs::IsRunning::Response &res);
105  bool removeExistingStepDataServiceCallback(thormang3_walking_module_msgs::RemoveExistingStepData::Request &req,
106  thormang3_walking_module_msgs::RemoveExistingStepData::Response &res);
107 
108  int convertStepDataMsgToStepData(thormang3_walking_module_msgs::StepData& src, robotis_framework::StepData& des);
109  int convertStepDataToStepDataMsg(robotis_framework::StepData& src, thormang3_walking_module_msgs::StepData& des);
110 
111  void setBalanceParam(thormang3_walking_module_msgs::BalanceParam& balance_param_msg);
112 
113  void updateBalanceParam();
114 
115  bool checkBalanceOnOff();
116 
117  void queueThread();
118 
119  void setJointFeedBackGain(thormang3_walking_module_msgs::JointFeedBackGain& msg);
121 
122  std::map<std::string, int> joint_name_to_index_;
123 
124  bool gazebo_;
126  boost::thread queue_thread_;
127  boost::mutex process_mutex_;
128 
129  Eigen::MatrixXd rot_x_pi_3d_, rot_z_pi_3d_;
130  Eigen::MatrixXd desired_matrix_g_to_cob_;
131  Eigen::MatrixXd desired_matrix_g_to_rfoot_;
132  Eigen::MatrixXd desired_matrix_g_to_lfoot_;
133 
135 
136  /* ROS Topic Publish Functions */
143 #ifdef WALKING_TUNE
147  thormang3_walking_module_msgs::WalkingJointStatesStamped walking_joint_states_msg_;
148 #endif
149 
150  thormang3_walking_module_msgs::RobotPose robot_pose_msg_;
155 
156 
161 
162  thormang3_walking_module_msgs::JointFeedBackGain previous_joint_feedback_gain_;
163  thormang3_walking_module_msgs::JointFeedBackGain current_joint_feedback_gain_;
164  thormang3_walking_module_msgs::JointFeedBackGain desired_joint_feedback_gain_;
165 
166  thormang3_walking_module_msgs::BalanceParam previous_balance_param_;
167  thormang3_walking_module_msgs::BalanceParam current_balance_param_;
168  thormang3_walking_module_msgs::BalanceParam desired_balance_param_;
169 
170 };
171 
172 }
173 
174 #endif /* THORMANG3_ONLINE_WALKING_MODULE_ONLINE_WALKING_MODULE_H_ */
ros::Publisher walking_joint_states_pub_
void setBalanceParam(thormang3_walking_module_msgs::BalanceParam &balance_param_msg)
void process(std::map< std::string, robotis_framework::Dynamixel * > dxls, std::map< std::string, double > sensors)
bool addStepDataServiceCallback(thormang3_walking_module_msgs::AddStepDataArray::Request &req, thormang3_walking_module_msgs::AddStepDataArray::Response &res)
thormang3_walking_module_msgs::BalanceParam current_balance_param_
thormang3_walking_module_msgs::BalanceParam desired_balance_param_
void initialize(const int control_cycle_msec, robotis_framework::Robot *robot)
thormang3_walking_module_msgs::JointFeedBackGain desired_joint_feedback_gain_
thormang3_walking_module_msgs::BalanceParam previous_balance_param_
void setJointFeedBackGain(thormang3_walking_module_msgs::JointFeedBackGain &msg)
int convertStepDataToStepDataMsg(robotis_framework::StepData &src, thormang3_walking_module_msgs::StepData &des)
thormang3_walking_module_msgs::JointFeedBackGain current_joint_feedback_gain_
thormang3_walking_module_msgs::WalkingJointStatesStamped walking_joint_states_msg_
void publishStatusMsg(unsigned int type, std::string msg)
bool startWalkingServiceCallback(thormang3_walking_module_msgs::StartWalking::Request &req, thormang3_walking_module_msgs::StartWalking::Response &res)
bool removeExistingStepDataServiceCallback(thormang3_walking_module_msgs::RemoveExistingStepData::Request &req, thormang3_walking_module_msgs::RemoveExistingStepData::Response &res)
std::map< std::string, int > joint_name_to_index_
ros::Publisher imu_orientation_states_pub_
bool getReferenceStepDataServiceCallback(thormang3_walking_module_msgs::GetReferenceStepData::Request &req, thormang3_walking_module_msgs::GetReferenceStepData::Response &res)
Eigen::MatrixXd balance_update_polynomial_coeff_
thormang3_walking_module_msgs::JointFeedBackGain previous_joint_feedback_gain_
Eigen::MatrixXd desired_matrix_g_to_rfoot_
bool setBalanceParamServiceCallback(thormang3_walking_module_msgs::SetBalanceParam::Request &req, thormang3_walking_module_msgs::SetBalanceParam::Response &res)
int convertStepDataMsgToStepData(thormang3_walking_module_msgs::StepData &src, robotis_framework::StepData &des)
void publishDoneMsg(std::string msg)
bool IsRunningServiceCallback(thormang3_walking_module_msgs::IsRunning::Request &req, thormang3_walking_module_msgs::IsRunning::Response &res)
Eigen::MatrixXd desired_matrix_g_to_cob_
thormang3_walking_module_msgs::RobotPose robot_pose_msg_
void imuDataOutputCallback(const sensor_msgs::Imu::ConstPtr &msg)
Eigen::MatrixXd joint_feedback_update_polynomial_coeff_
bool setJointFeedBackGainServiceCallback(thormang3_walking_module_msgs::SetJointFeedBackGain::Request &req, thormang3_walking_module_msgs::SetJointFeedBackGain::Response &res)
Eigen::MatrixXd desired_matrix_g_to_lfoot_


thormang3_walking_module
Author(s): Zerom , SCH , Kayman , Jay Song
autogenerated on Mon Jun 10 2019 15:37:56