24
24
#include " message_header.h"
25
25
26
26
#include < sensor_msgs/JointState.h>
27
+ // #include <std_msgs/Bool.h>
28
+ #include < std_msgs/Empty.h>
29
+ #include < std_msgs/Float64.h>
27
30
28
31
#include < dynamixel_workbench_toolbox/dynamixel_workbench.h>
29
32
#include < dynamixel_workbench_msgs/DynamixelStateList.h>
30
33
#include < dynamixel_workbench_msgs/JointCommand.h>
31
34
35
+ // Probably should make these constexpr
36
+ #define GRIPPER_OPEN_MOTOR_POS -1.147412
37
+ #define GRIPPER_CLOSE_MOTOR_POS 0.84368409
38
+ #define GRIPPER_OPEN_MOVEIT -0.025
39
+ #define GRIPPER_CLOSE_MOVEIT -0.002
40
+ #define GRIPPER_OPEN_VALUE 2800
41
+ #define GRIPPER_CLOSE_VALUE 1800
42
+ #define GRIPPER_MAX_LOAD 500
43
+ #define GRIPPER_PWM 500
44
+
32
45
class PositionControl
33
46
{
34
47
private:
@@ -37,40 +50,89 @@ class PositionControl
37
50
38
51
// ROS Parameters
39
52
40
- // ROS Topic Publisher
53
+ // ROS Topic Publishers
41
54
ros::Publisher dynamixel_state_list_pub_;
42
55
ros::Publisher joint_states_pub_;
56
+ // ros::Publisher status_pub_;
57
+ ros::Publisher pan_state_pub_;
58
+ ros::Publisher tilt_state_pub_;
43
59
44
60
// ROS Topic Subscriber
45
61
ros::Subscriber joint_command_sub_;
62
+ ros::Subscriber gripper_open_sub_;
63
+ ros::Subscriber gripper_close_sub_;
64
+ ros::Subscriber pan_command_sub_;
65
+ ros::Subscriber tilt_command_sub_;
46
66
47
67
// ROS Service Server
48
68
ros::ServiceServer joint_command_server_;
49
69
50
70
// ROS Service Client
51
71
52
- // Dynamixel Workbench Parameters
53
- DynamixelWorkbench *dxl_wb_;
54
- uint8_t dxl_id_[16 ];
55
- uint8_t dxl_cnt_;
72
+ // Dynamixel Workbench (old)
73
+ // DynamixelWorkbench *dxl_wb_;
74
+ // uint8_t dxl_id_[16];
75
+ // uint8_t dxl_cnt_;
76
+
77
+ // Dynamixel Workbench for arm
78
+ DynamixelWorkbench *dxl_wb_arm_;
79
+ uint8_t dxl_id_arm_[6 ];
80
+ uint8_t dxl_cnt_arm_;
81
+
82
+ // Dynamixel Workbench for gripper
83
+ DynamixelWorkbench *dxl_wb_gripper_;
84
+ uint8_t dxl_id_gripper_[1 ];
85
+ uint8_t dxl_cnt_gripper_;
86
+ uint8_t gripper_state_;
87
+ uint8_t prev_gripper_state_;
88
+ uint8_t prev_gripper_load_;
89
+
90
+ // Dynamixel Workbench for camera
91
+ DynamixelWorkbench *dxl_wb_camera_;
92
+ uint8_t dxl_id_camera_[2 ];
93
+ uint8_t dxl_cnt_camera_;
94
+
95
+ // Platforn configuration
96
+ bool use_arm_;
97
+ bool use_camera_;
98
+
99
+ // Controller parameters
100
+ std::string device_name_;
101
+ uint32_t dxl_baud_rate_;
102
+ uint32_t profile_velocity_;
103
+ uint32_t profile_acceleration_;
56
104
57
105
public:
58
106
PositionControl ();
59
107
~PositionControl ();
60
108
void controlLoop (void );
109
+ bool initLoCoBot ();
61
110
62
111
private:
63
- void initMsg ();
112
+ bool initArm ();
113
+ bool initGripper ();
114
+ bool initCamera ();
64
115
65
116
void initPublisher ();
66
117
void initSubscriber ();
67
118
void dynamixelStatePublish ();
68
119
void jointStatePublish ();
120
+ sensor_msgs::JointState getCurrentJointStates ();
121
+ float getCurrentMotorPosition (DynamixelWorkbench *dxl_wb, uint8_t id);
122
+ float getCurrentMotorVelocity (DynamixelWorkbench *dxl_wb, uint8_t id);
123
+ void getCurrentPV (std::vector<std::string>& jntNames,
124
+ std::vector<float >& jntPos, std::vector<float >& jntVel, int index);
125
+ void cameraStatePublish ();
126
+ void gripperController ();
69
127
70
128
void initServer ();
71
- bool jointCommandMsgCallback (dynamixel_workbench_msgs::JointCommand::Request &req,
72
- dynamixel_workbench_msgs::JointCommand::Response &res);
129
+ // bool jointCommandMsgCallback(dynamixel_workbench_msgs::JointCommand::Request &req,
130
+ // dynamixel_workbench_msgs::JointCommand::Response &res);
73
131
void goalJointPositionCallback (const sensor_msgs::JointState::ConstPtr &msg);
132
+ void gripperCloseCallback (const std_msgs::Empty::ConstPtr &msg);
133
+ void gripperOpenCallback (const std_msgs::Empty::ConstPtr &msg);
134
+ void panCommandCallback (const std_msgs::Float64::ConstPtr &msg);
135
+ void tiltCommandCallback (const std_msgs::Float64::ConstPtr &msg);
74
136
};
75
137
76
138
#endif // DYNAMIXEL_WORKBENCH_POSITION_CONTROL_H
0 commit comments