dynamixel.h
Go to the documentation of this file.
1 /*******************************************************************************
2 * Copyright 2019 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: Darby Lim, Hye-Jong KIM, Ryan Shim, Yong-Ho Na */
18 
19 #ifndef DYNAMIXEL_H_
20 #define DYNAMIXEL_H_
21 
22 #if defined(__OPENCR__)
23  #include <RobotisManipulator.h>
24  #include <DynamixelWorkbench.h>
25 #else
28 #endif
29 
30 namespace dynamixel
31 {
32 
33 #define SYNC_WRITE_HANDLER 0
34 #define SYNC_READ_HANDLER_FOR_PRESENT_POSITION_VELOCITY_CURRENT 0
35 
36 //#define CONTROL_LOOP_TIME 10; //ms
37 
38 // Protocol 2.0
39 #define ADDR_PRESENT_CURRENT_2 574 //126
40 #define ADDR_PRESENT_VELOCITY_2 576 //128
41 #define ADDR_PRESENT_POSITION_2 580 //132
42 #define ADDR_VELOCITY_TRAJECTORY_2 584 //136
43 #define ADDR_POSITION_TRAJECTORY_2 588 //140
44 #define ADDR_PROFILE_ACCELERATION_2 556 //108
45 #define ADDR_PROFILE_VELOCITY_2 560 //112
46 #define ADDR_GOAL_POSITION_2 564 //116
47 
48 
49 #define LENGTH_PRESENT_CURRENT_2 2
50 #define LENGTH_PRESENT_VELOCITY_2 4
51 #define LENGTH_PRESENT_POSITION_2 4
52 #define LENGTH_VELOCITY_TRAJECTORY_2 4
53 #define LENGTH_POSITION_TRAJECTORY_2 4
54 #define LENGTH_PROFILE_ACCELERATION_2 4
55 #define LENGTH_PROFILE_VELOCITY_2 4
56 #define LENGTH_GOAL_POSITION_2 4
57 
58 // DO not support anymore
59 // Protocol 1.0
60 // #define ADDR_PRESENT_CURRENT_1 = 40;
61 // #define ADDR_PRESENT_VELOCITY_1 = 38;
62 // #define ADDR_PRESENT_POSITION_1 = 36;
63 
64 // #define LENGTH_PRESENT_CURRENT_1 = 2;
65 // #define LENGTH_PRESENT_VELOCITY_1 = 2;
66 // #define LENGTH_PRESENT_POSITION_1 = 2;
67 
68 typedef struct
69 {
70  std::vector<uint8_t> id;
71  uint8_t num;
72 } Joint;
73 
75 {
76 private:
79 
80 public:
82  virtual ~JointDynamixel(){}
83 
84 
85  /*****************************************************************************
86  ** Joint Dynamixel Control Functions
87  *****************************************************************************/
88  virtual void init(std::vector<uint8_t> actuator_id, const void *arg);
89  virtual void setMode(std::vector<uint8_t> actuator_id, const void *arg);
90  virtual std::vector<uint8_t> getId();
91 
92  virtual void enable();
93  virtual void disable();
94 
95  virtual bool sendJointActuatorValue(std::vector<uint8_t> actuator_id, std::vector<robotis_manipulator::ActuatorValue> value_vector);
96  virtual std::vector<robotis_manipulator::ActuatorValue> receiveJointActuatorValue(std::vector<uint8_t> actuator_id);
97 
98 
99  /*****************************************************************************
100  ** Functions called in Joint Dynamixel Control Functions
101  *****************************************************************************/
102  bool initialize(std::vector<uint8_t> actuator_id, STRING dxl_device_name, STRING dxl_baud_rate);
103  bool setOperatingMode(std::vector<uint8_t> actuator_id, STRING dynamixel_mode = "position_mode");
104  bool setSDKHandler(uint8_t actuator_id);
105  bool writeProfileValue(std::vector<uint8_t> actuator_id, STRING profile_mode, uint32_t value);
106  bool writeGoalPosition(std::vector<uint8_t> actuator_id, std::vector<double> radian_vector);
107  std::vector<robotis_manipulator::ActuatorValue> receiveAllDynamixelValue(std::vector<uint8_t> actuator_id);
108 };
109 
111 {
112 private:
115  float control_loop_time_; // unit: ms
116  std::map<uint8_t, robotis_manipulator::ActuatorValue> previous_goal_value_;
117 
118 public:
119  JointDynamixelProfileControl(float control_loop_time = 0.010);
121 
122 
123  /*****************************************************************************
124  ** Joint Dynamixel Profile Control Functions
125  *****************************************************************************/
126  virtual void init(std::vector<uint8_t> actuator_id, const void *arg);
127  virtual void setMode(std::vector<uint8_t> actuator_id, const void *arg);
128  virtual std::vector<uint8_t> getId();
129 
130  virtual void enable();
131  virtual void disable();
132 
133  virtual bool sendJointActuatorValue(std::vector<uint8_t> actuator_id, std::vector<robotis_manipulator::ActuatorValue> value_vector);
134  virtual std::vector<robotis_manipulator::ActuatorValue> receiveJointActuatorValue(std::vector<uint8_t> actuator_id);
135 
136 
137  /*****************************************************************************
138  ** Functions called in Joint Dynamixel Profile Control Functions
139  *****************************************************************************/
140  bool initialize(std::vector<uint8_t> actuator_id, STRING dxl_device_name, STRING dxl_baud_rate);
141  bool setOperatingMode(std::vector<uint8_t> actuator_id, STRING dynamixel_mode = "position_mode");
142  bool setSDKHandler(uint8_t actuator_id);
143  bool writeProfileValue(std::vector<uint8_t> actuator_id, STRING profile_mode, uint32_t value);
144  bool writeGoalProfilingControlValue(std::vector<uint8_t> actuator_id, std::vector<robotis_manipulator::ActuatorValue> value_vector);
145  std::vector<robotis_manipulator::ActuatorValue> receiveAllDynamixelValue(std::vector<uint8_t> actuator_id);
146 };
147 
149 {
150  private:
153 
154  public:
156  virtual ~GripperDynamixel() {}
157 
158 
159  /*****************************************************************************
160  ** Tool Dynamixel Control Functions
161  *****************************************************************************/
162  virtual void init(uint8_t actuator_id, const void *arg);
163  virtual void setMode(const void *arg);
164  virtual uint8_t getId();
165 
166  virtual void enable();
167  virtual void disable();
168 
169  virtual bool sendToolActuatorValue(robotis_manipulator::ActuatorValue value);
170  virtual robotis_manipulator::ActuatorValue receiveToolActuatorValue();
171 
172 
173  /*****************************************************************************
174  ** Functions called in Tool Dynamixel Profile Control Functions
175  *****************************************************************************/
176  bool initialize(uint8_t actuator_id, STRING dxl_device_name, STRING dxl_baud_rate);
177  bool setOperatingMode(STRING dynamixel_mode = "position_mode");
178  bool writeProfileValue(STRING profile_mode, uint32_t value);
179  bool setSDKHandler();
180  bool writeGoalPosition(double radian);
181  double receiveDynamixelValue();
182 };
183 
184 } // namespace DYNAMIXEL
185 #endif // DYNAMIXEL_H_
186 
187 
188 
189 
bool writeGoalPosition(std::vector< uint8_t > actuator_id, std::vector< double > radian_vector)
Definition: dynamixel.cpp:267
DynamixelWorkbench * dynamixel_workbench_
Definition: dynamixel.h:151
DynamixelWorkbench * dynamixel_workbench_
Definition: dynamixel.h:113
bool initialize(std::vector< uint8_t > actuator_id, STRING dxl_device_name, STRING dxl_baud_rate)
Definition: dynamixel.cpp:125
virtual std::vector< uint8_t > getId()
Definition: dynamixel.cpp:63
std::map< uint8_t, robotis_manipulator::ActuatorValue > previous_goal_value_
Definition: dynamixel.h:116
virtual void disable()
Definition: dynamixel.cpp:84
virtual bool sendJointActuatorValue(std::vector< uint8_t > actuator_id, std::vector< robotis_manipulator::ActuatorValue > value_vector)
Definition: dynamixel.cpp:100
std::vector< uint8_t > id
Definition: dynamixel.h:70
virtual void setMode(std::vector< uint8_t > actuator_id, const void *arg)
Definition: dynamixel.cpp:37
virtual void init(std::vector< uint8_t > actuator_id, const void *arg)
Definition: dynamixel.cpp:27
DynamixelWorkbench * dynamixel_workbench_
Definition: dynamixel.h:77
bool writeProfileValue(std::vector< uint8_t > actuator_id, STRING profile_mode, uint32_t value)
Definition: dynamixel.cpp:248
bool setSDKHandler(uint8_t actuator_id)
Definition: dynamixel.cpp:226
bool setOperatingMode(std::vector< uint8_t > actuator_id, STRING dynamixel_mode="position_mode")
Definition: dynamixel.cpp:180
std::vector< robotis_manipulator::ActuatorValue > receiveAllDynamixelValue(std::vector< uint8_t > actuator_id)
Definition: dynamixel.cpp:290
virtual std::vector< robotis_manipulator::ActuatorValue > receiveJointActuatorValue(std::vector< uint8_t > actuator_id)
Definition: dynamixel.cpp:116
virtual void enable()
Definition: dynamixel.cpp:68
std::string STRING


open_manipulator_p_libs
Author(s): Ryan Shim , Yong-Ho Na , Hye-Jong KIM
autogenerated on Thu Oct 22 2020 03:16:37