dynamixel_workbench_controllers.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 /* Authors: Taehun Lim (Darby) */
18 
19 #ifndef DYNAMIXEL_WORKBENCH_CONTROLLERS_H
20 #define DYNAMIXEL_WORKBENCH_CONTROLLERS_H
21 
22 #include <ros/ros.h>
23 
24 #include <yaml-cpp/yaml.h>
25 
26 #include <sensor_msgs/JointState.h>
27 #include <geometry_msgs/Twist.h>
28 #include <trajectory_msgs/JointTrajectory.h>
29 #include <trajectory_msgs/JointTrajectoryPoint.h>
30 
32 #include <dynamixel_workbench_msgs/DynamixelStateList.h>
33 #include <dynamixel_workbench_msgs/DynamixelCommand.h>
34 
36 
37 // SYNC_WRITE_HANDLER
38 #define SYNC_WRITE_HANDLER_FOR_GOAL_POSITION 0
39 #define SYNC_WRITE_HANDLER_FOR_GOAL_VELOCITY 1
40 
41 // SYNC_READ_HANDLER(Only for Protocol 2.0)
42 #define SYNC_READ_HANDLER_FOR_PRESENT_POSITION_VELOCITY_CURRENT 0
43 
44 // #define DEBUG
45 
46 typedef struct
47 {
48  std::string item_name;
49  int32_t value;
50 } ItemValue;
51 
53 {
54  private:
55  // ROS NodeHandle
58 
59  // ROS Parameters
60 
61  // ROS Topic Publisher
64 
65  // ROS Topic Subscriber
68 
69  // ROS Service Server
71 
72  // ROS Service Client
73 
74  // Dynamixel Workbench Parameters
76 
77  std::map<std::string, uint32_t> dynamixel_;
78  std::map<std::string, const ControlItem*> control_items_;
79  std::vector<std::pair<std::string, ItemValue>> dynamixel_info_;
80  dynamixel_workbench_msgs::DynamixelStateList dynamixel_state_list_;
81  sensor_msgs::JointState joint_state_msg_;
82  std::vector<WayPoint> pre_goal_;
83 
87 
89  double wheel_radius_;
90 
92  trajectory_msgs::JointTrajectory *jnt_tra_msg_;
93 
94  double read_period_;
95  double write_period_;
96  double pub_period_;
97 
98  bool is_moving_;
99 
100  public:
103 
104  bool initWorkbench(const std::string port_name, const uint32_t baud_rate);
105  bool getDynamixelsInfo(const std::string yaml_file);
106  bool loadDynamixels(void);
107  bool initDynamixels(void);
108  bool initControlItems(void);
109  bool initSDKHandlers(void);
110  bool getPresentPosition(std::vector<std::string> dxl_name);
111 
112  double getReadPeriod(){return read_period_;}
113  double getWritePeriod(){return write_period_;}
114  double getPublishPeriod(){return pub_period_;}
115 
116  void initPublisher(void);
117  void initSubscriber(void);
118 
119  void initServer();
120 
121  void readCallback(const ros::TimerEvent&);
122  void writeCallback(const ros::TimerEvent&);
123  void publishCallback(const ros::TimerEvent&);
124 
125  void commandVelocityCallback(const geometry_msgs::Twist::ConstPtr &msg);
126  void trajectoryMsgCallback(const trajectory_msgs::JointTrajectory::ConstPtr &msg);
127  bool dynamixelCommandMsgCallback(dynamixel_workbench_msgs::DynamixelCommand::Request &req,
128  dynamixel_workbench_msgs::DynamixelCommand::Response &res);
129 };
130 
131 #endif //DYNAMIXEL_WORKBENCH_CONTROLLERS_H
void writeCallback(const ros::TimerEvent &)
void commandVelocityCallback(const geometry_msgs::Twist::ConstPtr &msg)
bool getDynamixelsInfo(const std::string yaml_file)
std::vector< std::pair< std::string, ItemValue > > dynamixel_info_
trajectory_msgs::JointTrajectory * jnt_tra_msg_
bool dynamixelCommandMsgCallback(dynamixel_workbench_msgs::DynamixelCommand::Request &req, dynamixel_workbench_msgs::DynamixelCommand::Response &res)
std::map< std::string, const ControlItem * > control_items_
bool initWorkbench(const std::string port_name, const uint32_t baud_rate)
sensor_msgs::JointState joint_state_msg_
void readCallback(const ros::TimerEvent &)
bool getPresentPosition(std::vector< std::string > dxl_name)
void publishCallback(const ros::TimerEvent &)
std::map< std::string, uint32_t > dynamixel_
std::vector< WayPoint > pre_goal_
dynamixel_workbench_msgs::DynamixelStateList dynamixel_state_list_
ros::ServiceServer dynamixel_command_server_
void trajectoryMsgCallback(const trajectory_msgs::JointTrajectory::ConstPtr &msg)


dynamixel_workbench_controllers
Author(s): Darby Lim , Ryan Shim
autogenerated on Mon Sep 28 2020 03:37:06