dynamixel_driver.cpp
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 #include "../../include/dynamixel_workbench_toolbox/dynamixel_driver.h"
20 
22  sync_write_handler_cnt_(0),
23  sync_read_handler_cnt_(0),
24  bulk_read_parameter_cnt_(0)
25 {
26 
27 }
28 
30 {
31  for (int i = 0; i < tools_cnt_; i++)
32  {
33  for (int j = 0; j < tools_[i].getDynamixelCount(); j++)
34  {
35  writeRegister(tools_[i].getID()[j], "Torque_Enable", (uint8_t)0);
36  }
37  }
38 
40 }
41 
43 {
44  for (uint8_t num = 0; num < MAX_DXL_SERIES_NUM; num++)
45  tools_[num].initTool();
46 
47  tools_cnt_ = 0;
48 }
49 
50 bool DynamixelDriver::setTool(uint16_t model_number, uint8_t id, const char **log)
51 {
52  bool result = false;
53 
54  // See if we have a matching tool?
55  for (uint8_t num = 0; num < tools_cnt_; num++)
56  {
57  if (tools_[num].getModelNumber() == model_number)
58  {
59  if (tools_[num].getDynamixelCount() < tools_[num].getDynamixelBuffer())
60  {
61  // Found one with the right model number and it is not full
62  tools_[num].addDXL(id);
63  return true;
64  }
65  else
66  {
67  if (log != NULL) *log = "[DynamixelDriver] Too many Dynamixels are connected (default buffer size is 16, the same series of Dynamixels)";
68  return false;
69  }
70  }
71  }
72  // We did not find one so lets allocate a new one
73  if (tools_cnt_ < MAX_DXL_SERIES_NUM)
74  {
75  // only do it if we still have some room...
76  result = tools_[tools_cnt_++].addTool(model_number, id, log);
77  return result;
78  }
79  else
80  {
81  if (log != NULL) *log = "[DynamixelDriver] Too many series are connected (MAX = 5 different series)";
82  return false;
83  }
84 
85  if (log != NULL) *log = "[DynamixelDriver] Failed to set the Tool";
86  return false;
87 }
88 
89 uint8_t DynamixelDriver::getTool(uint8_t id, const char **log)
90 {
91  for (int i = 0; i < tools_cnt_; i++)
92  {
93  for (int j = 0; j < tools_[i].getDynamixelCount(); j++)
94  {
95  if (tools_[i].getID()[j] == id)
96  {
97  return i;
98  }
99  }
100  }
101 
102  if (log != NULL) *log = "[DynamixelDriver] Failed to get the Tool";
103  return 0xff;
104 }
105 
106 bool DynamixelDriver::init(const char *device_name, uint32_t baud_rate, const char **log)
107 {
108  bool result = false;
109 
110  result = setPortHandler(device_name, log);
111  if (result == false) return false;
112 
113  result = setBaudrate(baud_rate, log);
114  if (result == false) return false;
115 
116  result = setPacketHandler(2.0f, log);
117  if (result == false) return false;
118 
119  return result;
120 }
121 
122 bool DynamixelDriver::begin(const char *device_name, uint32_t baud_rate, const char **log)
123 {
124  return init(device_name, baud_rate, log);
125 }
126 
127 bool DynamixelDriver::setPortHandler(const char *device_name, const char **log)
128 {
130 
131  if (portHandler_->openPort())
132  {
133  if (log != NULL) *log = "[DynamixelDriver] Succeeded to open the port!";
134  return true;
135  }
136 
137  if (log != NULL) *log = "[DynamixelDriver] Failed to open the port!";
138  return false;
139 }
140 
141 bool DynamixelDriver::setBaudrate(uint32_t baud_rate, const char **log)
142 {
143  if (portHandler_->setBaudRate((int)baud_rate))
144  {
145  if (log != NULL) *log = "[DynamixelDriver] Succeeded to change the baudrate!";
146  return true;
147  }
148 
149  if (log != NULL) *log = "[DynamixelDriver] Failed to change the baudrate!";
150  return false;
151 }
152 
153 bool DynamixelDriver::setPacketHandler(float protocol_version, const char **log)
154 {
156 
157  if (packetHandler_->getProtocolVersion() == protocol_version)
158  {
159  if (log != NULL) *log = "[DynamixelDriver] Succeeded to set the protocol!";
160  return true;
161  }
162 
163  if (log != NULL) *log = "[DynamixelDriver] Failed to set the protocol!";
164  return false;
165 }
166 
168 {
170 }
171 
173 {
174  return portHandler_->getBaudRate();
175 }
176 
177 const char* DynamixelDriver::getModelName(uint8_t id, const char **log)
178 {
179  uint8_t factor = getTool(id, log);
180  if (factor == 0xff)
181  return NULL;
182  else
183  return tools_[factor].getModelName();
184 
185  return NULL;
186 }
187 
188 uint16_t DynamixelDriver::getModelNumber(uint8_t id, const char **log)
189 {
190  uint8_t factor = getTool(id, log);
191  if (factor == 0xff) return false;
192 
193  for (int i = 0; i < tools_[factor].getDynamixelCount(); i++)
194  {
195  if (tools_[factor].getID()[i] == id)
196  return tools_[factor].getModelNumber();
197  }
198 
199  return false;
200 }
201 
202 const ControlItem* DynamixelDriver::getControlTable(uint8_t id, const char **log)
203 {
204  uint8_t factor = getTool(id, log);
205  if (factor == 0xff) return NULL;
206 
207  return tools_[factor].getControlTable();
208 }
209 
210 const ControlItem* DynamixelDriver::getItemInfo(uint8_t id, const char *item_name, const char **log)
211 {
212  const ControlItem *control_item;
213 
214  uint8_t factor = getTool(id, log);
215  if (factor == 0xff) return NULL;
216 
217  control_item = tools_[factor].getControlItem(item_name, log);
218  if (control_item == NULL) return NULL;
219  else return control_item;
220 
221  return NULL;
222 }
223 
224 uint8_t DynamixelDriver::getTheNumberOfControlItem(uint8_t id, const char **log)
225 {
226  uint8_t factor = getTool(id, log);
227  if (factor == 0xff) return false;
228 
229  return tools_[factor].getTheNumberOfControlItem();
230 }
231 
232 const ModelInfo* DynamixelDriver::getModelInfo(uint8_t id, const char **log)
233 {
234  uint8_t factor = getTool(id, log);
235  if (factor == 0xff) return NULL;
236 
237  return tools_[factor].getModelInfo();
238 }
239 
241 {
243 }
244 
246 {
247  return sync_read_handler_cnt_;
248 }
249 
251 {
253 }
254 
255 bool DynamixelDriver::scan(uint8_t *get_id, uint8_t *get_the_number_of_id, uint8_t start_num, uint8_t end_num, const char **log)
256 {
257  ErrorFromSDK sdk_error = {0, false, false, 0};
258  bool result = false;
259 
260  uint8_t id = 0;
261  uint8_t id_cnt = 0;
262 
263  uint16_t model_number = 0;
264 
265  uint8_t get_end_num = end_num;
266 
267  if (get_end_num > 253) get_end_num = 253;
268 
269  initTools();
270 
271  result = setPacketHandler(1.0f, log);
272  if (result == false) return false;
273 
274  for (id = start_num; id <= get_end_num; id++)
275  {
276  sdk_error.dxl_comm_result = packetHandler_->ping(portHandler_, id, &model_number, &sdk_error.dxl_error);
277  if (sdk_error.dxl_comm_result != COMM_SUCCESS)
278  {
279  if (log != NULL) *log = packetHandler_->getTxRxResult(sdk_error.dxl_comm_result);
280  }
281  else if (sdk_error.dxl_error != 0)
282  {
283  if (log != NULL) *log = packetHandler_->getRxPacketError(sdk_error.dxl_error);
284  }
285  else
286  {
287  get_id[id_cnt++] = id;
288  setTool(model_number, id);
289  }
290  }
291 
292  if (id_cnt > 0)
293  {
294  *get_the_number_of_id = id_cnt;
295  return result;
296  }
297 
298  result = setPacketHandler(2.0f, log);
299  if (result == false) return false;
300 
301  for (id = start_num; id <= get_end_num; id++)
302  {
303  sdk_error.dxl_comm_result = packetHandler_->ping(portHandler_, id, &model_number, &sdk_error.dxl_error);
304 
305  if (sdk_error.dxl_comm_result != COMM_SUCCESS)
306  {
307  if (log != NULL) *log = packetHandler_->getTxRxResult(sdk_error.dxl_comm_result);
308  }
309  else if (sdk_error.dxl_error != 0)
310  {
311  if (log != NULL) *log = packetHandler_->getRxPacketError(sdk_error.dxl_error);
312  }
313  else
314  {
315  get_id[id_cnt++] = id;
316  setTool(model_number, id);
317  }
318  }
319 
320  if (id_cnt > 0)
321  {
322  *get_the_number_of_id = id_cnt;
323  return result;
324  }
325 
326  return result;
327 }
328 
329 bool DynamixelDriver::scan(uint8_t *get_id, uint8_t *get_the_number_of_id, uint8_t range, const char **log)
330 {
331  return scan(get_id, get_the_number_of_id, 0, range, log);
332 }
333 
334 bool DynamixelDriver::ping(uint8_t id, uint16_t *get_model_number, const char **log)
335 {
336  ErrorFromSDK sdk_error = {0, false, false, 0};
337  bool result = false;
338 
339  uint16_t model_number = 0;
340 
341  result = setPacketHandler(1.0f, log);
342  if (result == false) return false;
343 
344  sdk_error.dxl_comm_result = packetHandler_->ping(portHandler_, id, &model_number, &sdk_error.dxl_error);
345  if (sdk_error.dxl_comm_result != COMM_SUCCESS)
346  {
347  if (log != NULL) *log = packetHandler_->getTxRxResult(sdk_error.dxl_comm_result);
348  }
349  else if (sdk_error.dxl_error != 0)
350  {
351  if (log != NULL) *log = packetHandler_->getRxPacketError(sdk_error.dxl_error);
352  }
353  else
354  {
355  setTool(model_number, id);
356  if (get_model_number != NULL) *get_model_number = model_number;
357  return true;
358  }
359 
360  result = setPacketHandler(2.0f, log);
361  if (result == false) return false;
362 
363  sdk_error.dxl_comm_result = packetHandler_->ping(portHandler_, id, &model_number, &sdk_error.dxl_error);
364  if (sdk_error.dxl_comm_result != COMM_SUCCESS)
365  {
366  if (log != NULL) *log = packetHandler_->getTxRxResult(sdk_error.dxl_comm_result);
367  }
368  else if (sdk_error.dxl_error != 0)
369  {
370  if (log != NULL) *log = packetHandler_->getRxPacketError(sdk_error.dxl_error);
371  }
372  else
373  {
374  setTool(model_number, id);
375  if (get_model_number != NULL) *get_model_number = model_number;
376  return true;
377  }
378 
379  return false;
380 }
381 
382 bool DynamixelDriver::ping(uint8_t id, const char **log)
383 {
384  return ping(id, NULL, log);
385 }
386 
387 bool DynamixelDriver::clearMultiTurn(uint8_t id, const char **log)
388 {
389  ErrorFromSDK sdk_error = {0, false, false, 0};
390 
392  if (sdk_error.dxl_comm_result != COMM_SUCCESS)
393  {
394  if (log != NULL) *log = packetHandler_->getTxRxResult(sdk_error.dxl_comm_result);
395  return false;
396  }
397  else if (sdk_error.dxl_error != 0)
398  {
399  if (log != NULL) *log = packetHandler_->getRxPacketError(sdk_error.dxl_error);
400  return false;
401  }
402  else
403  {
404  if (log != NULL) *log = "[DynamixelDriver] Succeeded to clear!";
405  return true;
406  }
407 
408  return false;
409 }
410 
411 bool DynamixelDriver::reboot(uint8_t id, const char **log)
412 {
413  ErrorFromSDK sdk_error = {0, false, false, 0};
414 
415  if (getProtocolVersion() == 1.0)
416  {
417  if (log != NULL) *log = "[DynamixelDriver] reboot functions is not available with the Dynamixel Protocol 1.0.";
418  return false;
419  }
420  else
421  {
422  sdk_error.dxl_comm_result = packetHandler_->reboot(portHandler_, id, &sdk_error.dxl_error);
423 #if defined(__OPENCR__) || defined(__OPENCM904__)
424  delay(1000);
425 #else
426  usleep(1000*1000);
427 #endif
428 
429  if (sdk_error.dxl_comm_result != COMM_SUCCESS)
430  {
431  if (log != NULL) *log = packetHandler_->getTxRxResult(sdk_error.dxl_comm_result);
432  return false;
433  }
434  else if (sdk_error.dxl_error != 0)
435  {
436  if (log != NULL) *log = packetHandler_->getRxPacketError(sdk_error.dxl_error);
437  return false;
438  }
439  else
440  {
441  if (log != NULL) *log = "[DynamixelDriver] Succeeded to reboot!";
442  return true;
443  }
444  }
445 
446  return false;
447 }
448 
449 bool DynamixelDriver::reset(uint8_t id, const char **log)
450 {
451  ErrorFromSDK sdk_error = {0, false, false, 0};
452  bool result = false;
453 
454  uint32_t new_baud_rate = 0;
455  uint8_t new_id = 1;
456 
457  const char* model_name = getModelName(id, log);
458  if (model_name == NULL) return false;
459 
460  uint16_t model_number = getModelNumber(id, log);
461  if (model_number == 0) return false;
462 
463  if (getProtocolVersion() == 1.0)
464  {
465  sdk_error.dxl_comm_result = packetHandler_->factoryReset(portHandler_, id, 0x00, &sdk_error.dxl_error);
466 #if defined(__OPENCR__) || defined(__OPENCM904__)
467  delay(2000);
468 #else
469  usleep(1000*2000);
470 #endif
471 
472  if (sdk_error.dxl_comm_result != COMM_SUCCESS)
473  {
474  if (log != NULL) *log = packetHandler_->getTxRxResult(sdk_error.dxl_comm_result);
475  return false;
476  }
477  else if (sdk_error.dxl_error != 0)
478  {
479  if (log != NULL) *log = packetHandler_->getRxPacketError(sdk_error.dxl_error);
480  return false;
481  }
482  else
483  {
484  if (!strncmp(model_name, "AX", strlen("AX")) ||
485  !strncmp(model_name, "MX-12W", strlen("MX-12W")))
486  new_baud_rate = 1000000;
487  else
488  new_baud_rate = 57600;
489 
490  result = setBaudrate(new_baud_rate, log);
491  if (result == false)
492  return false;
493  else
494  {
495  if (!strncmp(model_name, "MX-28-2", strlen("MX-28-2")) ||
496  !strncmp(model_name, "MX-64-2", strlen("MX-64-2")) ||
497  !strncmp(model_name, "MX-106-2", strlen("MX-106-2")) ||
498  !strncmp(model_name, "XL", strlen("XL")) ||
499  !strncmp(model_name, "XM", strlen("XM")) ||
500  !strncmp(model_name, "XH", strlen("XH")) ||
501  !strncmp(model_name, "PRO", strlen("PRO"))||
502  !strncmp(model_name, "RH", strlen("RH")))
503  {
504  result = setPacketHandler(2.0f, log);
505  if (result == false) return false;
506  }
507  else
508  {
509  result = setPacketHandler(1.0f, log);
510  if (result == false) return false;
511  }
512  }
513  }
514 
515  initTools();
516  result = setTool(model_number, new_id, log);
517  if (result == false) return false;
518 
519  if (log != NULL) *log = "[DynamixelDriver] Succeeded to reset!";
520  return true;
521  }
522  else if (getProtocolVersion() == 2.0)
523  {
524  sdk_error.dxl_comm_result = packetHandler_->factoryReset(portHandler_, id, 0xff, &sdk_error.dxl_error);
525 #if defined(__OPENCR__) || defined(__OPENCM904__)
526  delay(2000);
527 #else
528  usleep(1000*2000);
529 #endif
530 
531  if (sdk_error.dxl_comm_result != COMM_SUCCESS)
532  {
533  if (log != NULL) *log = packetHandler_->getTxRxResult(sdk_error.dxl_comm_result);
534  return false;
535  }
536  else if (sdk_error.dxl_error != 0)
537  {
538  if (log != NULL) *log = packetHandler_->getRxPacketError(sdk_error.dxl_error);
539  return false;
540  }
541  else
542  {
543  if (!strncmp(model_name, "XL-320", strlen("XL-320")))
544  new_baud_rate = 1000000;
545  else
546  new_baud_rate = 57600;
547 
548  result = setBaudrate(new_baud_rate, log);
549  if (result == false)
550  return false;
551  else
552  {
553  result = setPacketHandler(2.0f, log);
554  if (result == false) return false;
555  }
556  }
557 
558  initTools();
559  result = setTool(model_number, new_id, log);
560  if (result == false) return false;
561 
562  if (log != NULL) *log = "[DynamixelDriver] Succeeded to reset!";
563  return true;
564  }
565 
566  return result;
567 }
568 
569 bool DynamixelDriver::writeRegister(uint8_t id, uint16_t address, uint16_t length, uint8_t* data, const char **log)
570 {
571  ErrorFromSDK sdk_error = {0, false, false, 0};
572 
573 #if defined(__OPENCR__) || defined(__OPENCM904__)
574  delay(10);
575 #else
576  usleep(1000*10);
577 #endif
578 
580  id,
581  address,
582  length,
583  data,
584  &sdk_error.dxl_error);
585  if (sdk_error.dxl_comm_result != COMM_SUCCESS)
586  {
587  if (log != NULL) *log = packetHandler_->getTxRxResult(sdk_error.dxl_comm_result);
588  return false;
589  }
590  else if (sdk_error.dxl_error != 0)
591  {
592  if (log != NULL) *log = packetHandler_->getRxPacketError(sdk_error.dxl_error);
593  return false;
594  }
595  else
596  {
597  if (log != NULL) *log = "[DynamixelDriver] Succeeded to write!";
598  return true;
599  }
600 
601  return false;
602 }
603 
604 bool DynamixelDriver::writeRegister(uint8_t id, const char *item_name, int32_t data, const char **log)
605 {
606  ErrorFromSDK sdk_error = {0, false, false, 0};
607 
608  const ControlItem *control_item;
609 
610  uint8_t factor = getTool(id, log);
611  if (factor == 0xff) return false;
612 
613  control_item = tools_[factor].getControlItem(item_name, log);
614  if (control_item == NULL) return false;
615 
616  uint8_t data_1_byte = (uint8_t)data;
617  uint16_t data_2_byte = (uint16_t)data;
618  uint32_t data_4_byte = (uint32_t)data;
619 
620 #if defined(__OPENCR__) || defined(__OPENCM904__)
621  delay(10);
622 #else
623  usleep(1000*10);
624 #endif
625 
626  switch (control_item->data_length)
627  {
628  case BYTE:
630  id,
631  control_item->address,
632  data_1_byte,
633  &sdk_error.dxl_error);
634  break;
635 
636  case WORD:
638  id,
639  control_item->address,
640  data_2_byte,
641  &sdk_error.dxl_error);
642  break;
643 
644  case DWORD:
646  id,
647  control_item->address,
648  data_4_byte,
649  &sdk_error.dxl_error);
650  break;
651 
652  default:
654  id,
655  control_item->address,
656  data_1_byte,
657  &sdk_error.dxl_error);
658  break;
659  }
660 
661  if (sdk_error.dxl_comm_result != COMM_SUCCESS)
662  {
663  if (log != NULL) *log = packetHandler_->getTxRxResult(sdk_error.dxl_comm_result);
664  return false;
665  }
666  else if (sdk_error.dxl_error != 0)
667  {
668  if (log != NULL) *log = packetHandler_->getRxPacketError(sdk_error.dxl_error);
669  return false;
670  }
671  else
672  {
673  if (log != NULL) *log = "[DynamixelDriver] Succeeded to write!";
674  return true;
675  }
676 
677  return false;
678 }
679 
680 bool DynamixelDriver::writeOnlyRegister(uint8_t id, uint16_t address, uint16_t length, uint8_t *data, const char **log)
681 {
682  ErrorFromSDK sdk_error = {0, false, false, 0};
683 
684 #if defined(__OPENCR__) || defined(__OPENCM904__)
685  delay(10);
686 #else
687  usleep(1000*10);
688 #endif
689 
691  id,
692  address,
693  length,
694  data);
695  if (sdk_error.dxl_comm_result != COMM_SUCCESS)
696  {
697  if (log != NULL) *log = packetHandler_->getTxRxResult(sdk_error.dxl_comm_result);
698  return false;
699  }
700  else
701  {
702  if (log != NULL) *log = "[DynamixelDriver] Succeeded to write!";
703  return true;
704  }
705 
706  return false;
707 }
708 
709 bool DynamixelDriver::writeOnlyRegister(uint8_t id, const char *item_name, int32_t data, const char **log)
710 {
711  ErrorFromSDK sdk_error = {0, false, false, 0};
712 
713  const ControlItem *control_item;
714 
715  uint8_t factor = getTool(id, log);
716  if (factor == 0xff) return false;
717 
718  control_item = tools_[factor].getControlItem(item_name, log);
719  if (control_item == NULL) return false;
720 
721 #if defined(__OPENCR__) || defined(__OPENCM904__)
722  delay(10);
723 #else
724  usleep(1000*10);
725 #endif
726 
727  switch (control_item->data_length)
728  {
729  case BYTE:
731  id,
732  control_item->address,
733  (uint8_t)data);
734  break;
735 
736  case WORD:
738  id,
739  control_item->address,
740  (uint16_t)data);
741  break;
742 
743  case DWORD:
745  id,
746  control_item->address,
747  (uint32_t)data);
748  break;
749 
750  default:
752  id,
753  control_item->address,
754  (uint8_t)data);
755  break;
756  }
757 
758  if (sdk_error.dxl_comm_result != COMM_SUCCESS)
759  {
760  if (log != NULL) *log = packetHandler_->getTxRxResult(sdk_error.dxl_comm_result);
761  return false;
762  }
763  else
764  {
765  if (log != NULL) *log = "[DynamixelDriver] Succeeded to write!";
766  return true;
767  }
768 
769  return false;
770 }
771 
772 bool DynamixelDriver::readRegister(uint8_t id, uint16_t address, uint16_t length, uint32_t *data, const char **log)
773 {
774  ErrorFromSDK sdk_error = {0, false, false, 0};
775 
776  uint8_t data_read[length];
777 
779  id,
780  address,
781  length,
782  (uint8_t *)&data_read,
783  &sdk_error.dxl_error);
784  if (sdk_error.dxl_comm_result != COMM_SUCCESS)
785  {
786  if (log != NULL) *log = packetHandler_->getTxRxResult(sdk_error.dxl_comm_result);
787  return false;
788  }
789  else if (sdk_error.dxl_error != 0)
790  {
791  if (log != NULL) *log = packetHandler_->getRxPacketError(sdk_error.dxl_error);
792  return false;
793  }
794  else
795  {
796  switch (length)
797  {
798  case BYTE:
799  *data = data_read[0];
800  break;
801 
802  case WORD:
803  *data = DXL_MAKEWORD(data_read[0], data_read[1]);
804  break;
805 
806  case DWORD:
807  *data = DXL_MAKEDWORD(DXL_MAKEWORD(data_read[0], data_read[1]), DXL_MAKEWORD(data_read[2], data_read[3]));
808  break;
809 
810  default:
811  for (uint16_t index = 0; index < length; index++)
812  {
813  data[index] = (uint32_t)data_read[index];
814  }
815  break;
816  }
817  if (log != NULL) *log = "[DynamixelDriver] Succeeded to read!";
818  return true;
819  }
820 
821  return false;
822 }
823 
824 bool DynamixelDriver::readRegister(uint8_t id, const char *item_name, int32_t *data, const char **log)
825 {
826  ErrorFromSDK sdk_error = {0, false, false, 0};
827 
828  const ControlItem *control_item;
829 
830  uint8_t factor = getTool(id, log);
831  if (factor == 0xff) return false;
832 
833  control_item = tools_[factor].getControlItem(item_name, log);
834  if (control_item == NULL) return false;
835 
836  uint8_t data_1_byte = 0;
837  uint16_t data_2_byte = 0;
838  uint32_t data_4_byte = 0;
839 
840  switch (control_item->data_length)
841  {
842  case BYTE:
844  id,
845  control_item->address,
846  &data_1_byte,
847  &sdk_error.dxl_error);
848  break;
849 
850  case WORD:
852  id,
853  control_item->address,
854  &data_2_byte,
855  &sdk_error.dxl_error);
856  break;
857 
858  case DWORD:
860  id,
861  control_item->address,
862  &data_4_byte,
863  &sdk_error.dxl_error);
864  break;
865 
866  default:
868  id,
869  control_item->address,
870  &data_1_byte,
871  &sdk_error.dxl_error);
872  break;
873  }
874 
875  if (sdk_error.dxl_comm_result != COMM_SUCCESS)
876  {
877  if (log != NULL) *log = packetHandler_->getTxRxResult(sdk_error.dxl_comm_result);
878  return false;
879  }
880  else if (sdk_error.dxl_error != 0)
881  {
882  if (log != NULL) *log = packetHandler_->getRxPacketError(sdk_error.dxl_error);
883  return false;
884  }
885  else
886  {
887  switch (control_item->data_length)
888  {
889  case BYTE:
890  *data = data_1_byte;
891  break;
892 
893  case WORD:
894  *data = data_2_byte;
895  break;
896 
897  case DWORD:
898  *data = data_4_byte;
899  break;
900 
901  default:
902  *data = data_1_byte;
903  break;
904  }
905 
906  if (log != NULL) *log = "[DynamixelDriver] Succeeded to read!";
907  return true;
908  }
909 
910  return false;
911 }
912 
913 void DynamixelDriver::getParam(int32_t data, uint8_t *param)
914 {
915  param[0] = DXL_LOBYTE(DXL_LOWORD(data));
916  param[1] = DXL_HIBYTE(DXL_LOWORD(data));
917  param[2] = DXL_LOBYTE(DXL_HIWORD(data));
918  param[3] = DXL_HIBYTE(DXL_HIWORD(data));
919 }
920 
921 bool DynamixelDriver::addSyncWriteHandler(uint16_t address, uint16_t length, const char **log)
922 {
924  {
925  if (log != NULL) *log = "[DynamixelDriver] Too many sync write handler are added (MAX = 5)";
926  return false;
927  }
928 
930 
933  address,
934  length);
935 
937 
938  if (log != NULL) *log = "[DynamixelDriver] Succeeded to add sync write handler";
939  return true;
940 }
941 
942 bool DynamixelDriver::addSyncWriteHandler(uint8_t id, const char *item_name, const char **log)
943 {
944  const ControlItem *control_item;
945 
946  uint8_t factor = getTool(id, log);
947  if (factor == 0xff) return false;
948 
949  control_item = tools_[factor].getControlItem(item_name, log);
950  if (control_item == NULL) return false;
951 
953  {
954  if (log != NULL) *log = "[DynamixelDriver] Too many sync write handler are added (MAX = 5)";
955  return false;
956  }
957 
959 
962  control_item->address,
963  control_item->data_length);
964 
966 
967  if (log != NULL) *log = "[DynamixelDriver] Succeeded to add sync write handler";
968  return true;
969 }
970 
971 bool DynamixelDriver::syncWrite(uint8_t index, int32_t *data, const char **log)
972 {
973  ErrorFromSDK sdk_error = {0, false, false, 0};
974 
975  uint8_t dxl_cnt = 0;
976  uint8_t parameter[4] = {0, 0, 0, 0};
977 
978  for (int i = 0; i < tools_cnt_; i++)
979  {
980  for (int j = 0; j < tools_[i].getDynamixelCount(); j++)
981  {
982  getParam(data[dxl_cnt], parameter);
983  sdk_error.dxl_addparam_result = syncWriteHandler_[index].groupSyncWrite->addParam(tools_[i].getID()[j], (uint8_t *)&parameter);
984  if (sdk_error.dxl_addparam_result != true)
985  {
986  if (log != NULL) *log = "groupSyncWrite addparam failed";
987  return false;
988  }
989  else
990  dxl_cnt++;
991  }
992  }
993 
995  if (sdk_error.dxl_comm_result != COMM_SUCCESS)
996  {
997  if (log != NULL) *log = packetHandler_->getTxRxResult(sdk_error.dxl_comm_result);
998  return false;
999  }
1000 
1002 
1003  if (log != NULL) *log = "[DynamixelDriver] Succeeded to sync write!";
1004  return true;
1005 }
1006 
1007 bool DynamixelDriver::syncWrite(uint8_t index, uint8_t *id, uint8_t id_num, int32_t *data, uint8_t data_num_for_each_id, const char **log)
1008 {
1009  ErrorFromSDK sdk_error = {0, false, false, 0};
1010 
1011  uint8_t parameter[4] = {0, 0, 0, 0};
1012  uint8_t multi_parameter[4*data_num_for_each_id];
1013  uint8_t cnt = 0;
1014 
1015  for (int i = 0; i < id_num; i++)
1016  {
1017  for (int j = 0; j < data_num_for_each_id; j++)
1018  {
1019  getParam(data[cnt++], parameter);
1020  for (int k = 0; k < 4; k++)
1021  {
1022  multi_parameter[4*j+k] = parameter[k];
1023  }
1024  }
1025 
1026  sdk_error.dxl_addparam_result = syncWriteHandler_[index].groupSyncWrite->addParam(id[i], (uint8_t *)&multi_parameter);
1027  if (sdk_error.dxl_addparam_result != true)
1028  {
1029  if (log != NULL) *log = "groupSyncWrite addparam failed";
1030  return false;
1031  }
1032  }
1033 
1035  if (sdk_error.dxl_comm_result != COMM_SUCCESS)
1036  {
1037  if (log != NULL) *log = packetHandler_->getTxRxResult(sdk_error.dxl_comm_result);
1038  return false;
1039  }
1040 
1042 
1043  if (log != NULL) *log = "[DynamixelDriver] Succeeded to sync write!";
1044  return true;
1045 }
1046 
1047 bool DynamixelDriver::addSyncReadHandler(uint16_t address, uint16_t length, const char **log)
1048 {
1050  {
1051  if (log != NULL) *log = "[DynamixelDriver] Too many sync read handler are added (MAX = 5)";
1052  return false;
1053  }
1054 
1056 
1059  address,
1060  length);
1061 
1063 
1064  if (log != NULL) *log = "[DynamixelDriver] Succeeded to add sync read handler";
1065  return true;
1066 }
1067 
1068 bool DynamixelDriver::addSyncReadHandler(uint8_t id, const char *item_name, const char **log)
1069 {
1070  const ControlItem *control_item;
1071 
1072  uint8_t factor = getTool(id, log);
1073  if (factor == 0xff) return false;
1074 
1075  control_item = tools_[factor].getControlItem(item_name, log);
1076  if (control_item == NULL) return false;
1077 
1079  {
1080  if (log != NULL) *log = "[DynamixelDriver] Too many sync read handler are added (MAX = 5)";
1081  return false;
1082  }
1083 
1085 
1088  control_item->address,
1089  control_item->data_length);
1090 
1092 
1093  if (log != NULL) *log = "[DynamixelDriver] Succeeded to add sync read handler";
1094  return true;
1095 }
1096 
1097 bool DynamixelDriver::syncRead(uint8_t index, const char **log)
1098 {
1099  ErrorFromSDK sdk_error = {0, false, false, 0};
1100 
1102  for (int i = 0; i < tools_cnt_; i++)
1103  {
1104  for (int j = 0; j < tools_[i].getDynamixelCount(); j++)
1105  {
1106  sdk_error.dxl_addparam_result = syncReadHandler_[index].groupSyncRead->addParam(tools_[i].getID()[j]);
1107  if (sdk_error.dxl_addparam_result != true)
1108  {
1109  if (log != NULL) *log = "groupSyncWrite addparam failed";
1110  return false;
1111  }
1112  }
1113  }
1114 
1116  if (sdk_error.dxl_comm_result != COMM_SUCCESS)
1117  {
1118  if (log != NULL) *log = packetHandler_->getTxRxResult(sdk_error.dxl_comm_result);
1119  return false;
1120  }
1121 
1122  if (log != NULL) *log = "[DynamixelDriver] Succeeded to sync read!";
1123  return true;
1124 }
1125 
1126 bool DynamixelDriver::syncRead(uint8_t index, uint8_t *id, uint8_t id_num, const char **log)
1127 {
1128  ErrorFromSDK sdk_error = {0, false, false, 0};
1129 
1131  for (int i = 0; i < id_num; i++)
1132  {
1133  sdk_error.dxl_addparam_result = syncReadHandler_[index].groupSyncRead->addParam(id[i]);
1134  if (sdk_error.dxl_addparam_result != true)
1135  {
1136  if (log != NULL) *log = "groupSyncWrite addparam failed";
1137  return false;
1138  }
1139  }
1140 
1142  if (sdk_error.dxl_comm_result != COMM_SUCCESS)
1143  {
1144  if (log != NULL) *log = packetHandler_->getTxRxResult(sdk_error.dxl_comm_result);
1145  return false;
1146  }
1147 
1148  if (log != NULL) *log = "[DynamixelDriver] Succeeded to sync read!";
1149  return true;
1150 }
1151 
1152 bool DynamixelDriver::getSyncReadData(uint8_t index, int32_t *data, const char **log)
1153 {
1154  ErrorFromSDK sdk_error = {0, false, false, 0};
1155 
1156  for (int i = 0; i < tools_cnt_; i++)
1157  {
1158  for (int j = 0; j < tools_[i].getDynamixelCount(); j++)
1159  {
1160  sdk_error.dxl_getdata_result = syncReadHandler_[index].groupSyncRead->isAvailable(tools_[i].getID()[j],
1161  syncReadHandler_[index].control_item->address,
1163  if (sdk_error.dxl_getdata_result != true)
1164  {
1165  if (log != NULL) *log = "groupSyncRead getdata failed";
1166  return false;
1167  }
1168  else
1169  {
1170  data[i+j] = syncReadHandler_[index].groupSyncRead->getData(tools_[i].getID()[j],
1171  syncReadHandler_[index].control_item->address,
1173  }
1174  }
1175  }
1176 
1177  if (log != NULL) *log = "[DynamixelDriver] Succeeded to get sync read data!";
1178  return true;
1179 }
1180 
1181 bool DynamixelDriver::getSyncReadData(uint8_t index, uint8_t *id, uint8_t id_num, int32_t *data, const char **log)
1182 {
1183  ErrorFromSDK sdk_error = {0, false, false, 0};
1184 
1185  for (int i = 0; i < id_num; i++)
1186  {
1187  sdk_error.dxl_getdata_result = syncReadHandler_[index].groupSyncRead->isAvailable(id[i],
1188  syncReadHandler_[index].control_item->address,
1190  if (sdk_error.dxl_getdata_result != true)
1191  {
1192  if (log != NULL) *log = "groupSyncRead getdata failed";
1193  return false;
1194  }
1195  else
1196  {
1197  data[i] = syncReadHandler_[index].groupSyncRead->getData(id[i],
1198  syncReadHandler_[index].control_item->address,
1200  }
1201  }
1202 
1203  if (log != NULL) *log = "[DynamixelDriver] Succeeded to get sync read data!";
1204  return true;
1205 }
1206 
1207 bool DynamixelDriver::getSyncReadData(uint8_t index, uint8_t *id, uint8_t id_num, uint16_t address, uint16_t length, int32_t *data, const char **log)
1208 {
1209  ErrorFromSDK sdk_error = {0, false, false, 0};
1210 
1211  for (int i = 0; i < id_num; i++)
1212  {
1213  sdk_error.dxl_getdata_result = syncReadHandler_[index].groupSyncRead->isAvailable(id[i],
1214  address,
1215  length);
1216  if (sdk_error.dxl_getdata_result != true)
1217  {
1218  if (log != NULL) *log = "groupSyncRead getdata failed";
1219  return false;
1220  }
1221  else
1222  {
1223  data[i] = syncReadHandler_[index].groupSyncRead->getData(id[i],
1224  address,
1225  length);
1226  }
1227  }
1228 
1229  if (log != NULL) *log = "[DynamixelDriver] Succeeded to get sync read data!";
1230  return true;
1231 }
1232 
1233 bool DynamixelDriver::initBulkWrite(const char **log)
1234 {
1235  if (portHandler_ == NULL)
1236  {
1237  if (log != NULL) *log = "[DynamixelDriver] Failed to load portHandler!";
1238  }
1239  else if (packetHandler_ == NULL)
1240  {
1241  if (log != NULL) *log = "[DynamixelDriver] Failed to load packetHandler!";
1242  }
1243  else
1244  {
1246 
1247  if (log != NULL) *log = "[DynamixelDriver] Succeeded to init groupBulkWrite!";
1248  return true;
1249  }
1250 
1251  return false;
1252 }
1253 
1254 bool DynamixelDriver::addBulkWriteParam(uint8_t id, uint16_t address, uint16_t length, int32_t data, const char **log)
1255 {
1256  ErrorFromSDK sdk_error = {0, false, false, 0};
1257 
1258  uint8_t parameter[4] = {0, 0, 0, 0};
1259 
1260  getParam(data, parameter);
1261  sdk_error.dxl_addparam_result = groupBulkWrite_->addParam(id,
1262  address,
1263  length,
1264  parameter);
1265  if (sdk_error.dxl_addparam_result != true)
1266  {
1267  if (log != NULL) *log = "groupBulkWrite addparam failed";
1268  return false;
1269  }
1270 
1271  if (log != NULL) *log = "[DynamixelDriver] Succeeded to add param for bulk write!";
1272  return true;
1273 }
1274 
1275 bool DynamixelDriver::addBulkWriteParam(uint8_t id, const char *item_name, int32_t data, const char **log)
1276 {
1277  ErrorFromSDK sdk_error = {0, false, false, 0};
1278 
1279  uint8_t parameter[4] = {0, 0, 0, 0};
1280 
1281  const ControlItem *control_item;
1282 
1283  uint8_t factor = getTool(id, log);
1284  if (factor == 0xff) return false;
1285 
1286  control_item = tools_[factor].getControlItem(item_name, log);
1287  if (control_item == NULL) return false;
1288 
1289  getParam(data, parameter);
1290  sdk_error.dxl_addparam_result = groupBulkWrite_->addParam(id,
1291  control_item->address,
1292  control_item->data_length,
1293  parameter);
1294  if (sdk_error.dxl_addparam_result != true)
1295  {
1296  if (log != NULL) *log = "groupBulkWrite addparam failed";
1297  return false;
1298  }
1299 
1300  if (log != NULL) *log = "[DynamixelDriver] Succeeded to add param for bulk write!";
1301  return true;
1302 }
1303 
1304 bool DynamixelDriver::bulkWrite(const char **log)
1305 {
1306  ErrorFromSDK sdk_error = {0, false, false, 0};
1307 
1308  sdk_error.dxl_comm_result = groupBulkWrite_->txPacket();
1309  if (sdk_error.dxl_comm_result != COMM_SUCCESS)
1310  {
1311  if (log != NULL) *log = packetHandler_->getTxRxResult(sdk_error.dxl_comm_result);
1312  return false;
1313  }
1314 
1316  if (log != NULL) *log = "[DynamixelDriver] Succeeded to bulk write!";
1317 
1318  return true;
1319 }
1320 
1321 bool DynamixelDriver::initBulkRead(const char **log)
1322 {
1323  if (portHandler_ == NULL)
1324  {
1325  if (log != NULL) *log = "[DynamixelDriver] Failed to load portHandler!";
1326  }
1327  else if (packetHandler_ == NULL)
1328  {
1329  if (log != NULL) *log = "[DynamixelDriver] Failed to load packetHandler!";
1330  }
1331  else
1332  {
1334 
1335  if (log != NULL) *log = "[DynamixelDriver] Succeeded to init groupBulkRead!";
1336 
1337  return true;
1338  }
1339 
1340  return false;
1341 }
1342 
1343 bool DynamixelDriver::addBulkReadParam(uint8_t id, uint16_t address, uint16_t length, const char **log)
1344 {
1345  ErrorFromSDK sdk_error = {0, false, false, 0};
1346 
1347  sdk_error.dxl_addparam_result = groupBulkRead_->addParam(id,
1348  address,
1349  length);
1350  if (sdk_error.dxl_addparam_result != true)
1351  {
1352  if (log != NULL) *log = "grouBulkRead addparam failed";
1353  return false;
1354  }
1355 
1357  {
1362  }
1363  else
1364  {
1365  if (log != NULL) *log = "[DynamixelDriver] Too many bulk parameter are added (default buffer size is 10)";
1366  return false;
1367  }
1368 
1369  if (log != NULL) *log = "[DynamixelDriver] Succeeded to add param for bulk read!";
1370  return true;
1371 }
1372 
1373 bool DynamixelDriver::addBulkReadParam(uint8_t id, const char *item_name, const char **log)
1374 {
1375  ErrorFromSDK sdk_error = {0, false, false, 0};
1376 
1377  const ControlItem *control_item;
1378 
1379  uint8_t factor = getTool(id, log);
1380  if (factor == 0xff) return false;
1381 
1382  control_item = tools_[factor].getControlItem(item_name, log);
1383  if (control_item == NULL) return false;
1384 
1385  sdk_error.dxl_addparam_result = groupBulkRead_->addParam(id,
1386  control_item->address,
1387  control_item->data_length);
1388  if (sdk_error.dxl_addparam_result != true)
1389  {
1390  if (log != NULL) *log = "grouBulkRead addparam failed";
1391  return false;
1392  }
1393 
1395  {
1400  }
1401  else
1402  {
1403  if (log != NULL) *log = "[DynamixelDriver] Too many bulk parameter are added (default buffer size is 10)";
1404  return false;
1405  }
1406 
1407  if (log != NULL) *log = "[DynamixelDriver] Succeeded to add param for bulk read!";
1408  return true;
1409 }
1410 
1411 bool DynamixelDriver::bulkRead(const char **log)
1412 {
1413  ErrorFromSDK sdk_error = {0, false, false, 0};
1414 
1415  sdk_error.dxl_comm_result = groupBulkRead_->txRxPacket();
1416  if (sdk_error.dxl_comm_result != COMM_SUCCESS)
1417  {
1418  if (log != NULL) *log = packetHandler_->getTxRxResult(sdk_error.dxl_comm_result);
1419  return false;
1420  }
1421 
1422  if (log != NULL) *log = "[DynamixelDriver] Succeeded to bulk read!";
1423  return true;
1424 }
1425 
1426 bool DynamixelDriver::getBulkReadData(int32_t *data, const char **log)
1427 {
1428  ErrorFromSDK sdk_error = {0, false, false, 0};
1429 
1430  for (int i = 0; i < bulk_read_parameter_cnt_; i++)
1431  {
1433  bulk_read_param_[i].address,
1434  bulk_read_param_[i].data_length);
1435  if (sdk_error.dxl_getdata_result != true)
1436  {
1437  if (log != NULL) *log = "groupBulkRead getdata failed";
1438  return false;
1439  }
1440  else
1441  {
1442  data[i] = groupBulkRead_->getData(bulk_read_param_[i].id,
1443  bulk_read_param_[i].address,
1444  bulk_read_param_[i].data_length);
1445  }
1446  }
1447 
1448  if (log != NULL) *log = "[DynamixelDriver] Succeeded to get bulk read data!";
1449  return true;
1450 }
1451 
1452 bool DynamixelDriver::getBulkReadData(uint8_t *id, uint8_t id_num, uint16_t *address, uint16_t *length, int32_t *data, const char **log)
1453 {
1454  ErrorFromSDK sdk_error = {0, false, false, 0};
1455 
1456  for (int i = 0; i < id_num; i++)
1457  {
1458  sdk_error.dxl_getdata_result = groupBulkRead_->isAvailable(id[i],
1459  address[i],
1460  length[i]);
1461  if (sdk_error.dxl_getdata_result != true)
1462  {
1463  if (log != NULL) *log = "groupBulkRead getdata failed";
1464  return false;
1465  }
1466  else
1467  {
1468  data[i] = groupBulkRead_->getData(id[i],
1469  address[i],
1470  length[i]);
1471  }
1472  }
1473 
1474  if (log != NULL) *log = "[DynamixelDriver] Succeeded to get bulk read data!";
1475  return true;
1476 }
1477 
1479 {
1482 
1483  return true;
1484 }
SyncWriteHandler syncWriteHandler_[MAX_HANDLER_NUM]
virtual int read1ByteTxRx(PortHandler *port, uint8_t id, uint16_t address, uint8_t *data, uint8_t *error=0)=0
bool isAvailable(uint8_t id, uint16_t address, uint16_t data_length)
static PortHandler * getPortHandler(const char *port_name)
const ControlItem * getControlItem(const char *item_name, const char **log=NULL)
uint32_t getBaudrate(void)
bool addBulkWriteParam(uint8_t id, uint16_t address, uint16_t length, int32_t data, const char **log=NULL)
bool addBulkReadParam(uint8_t id, uint16_t address, uint16_t length, const char **log=NULL)
const ModelInfo * getModelInfo(void)
dynamixel::GroupBulkRead * groupBulkRead_
bool isAvailable(uint8_t id, uint16_t address, uint16_t data_length)
virtual bool openPort()=0
const ControlItem * control_item
f
bool getBulkReadData(int32_t *data, const char **log=NULL)
uint16_t address
virtual int write2ByteTxOnly(PortHandler *port, uint8_t id, uint16_t address, uint16_t data)=0
uint8_t getTheNumberOfSyncWriteHandler(void)
bool addParam(uint8_t id, uint8_t *data)
virtual int writeTxRx(PortHandler *port, uint8_t id, uint16_t address, uint16_t length, uint8_t *data, uint8_t *error=0)=0
#define MAX_BULK_PARAMETER
dynamixel::GroupSyncWrite * groupSyncWrite
bool setPacketHandler(float protocol_version, const char **log=NULL)
bool addParam(uint8_t id, uint16_t start_address, uint16_t data_length)
bool init(const char *device_name="/dev/ttyUSB0", uint32_t baud_rate=57600, const char **log=NULL)
bool addParam(uint8_t id)
dynamixel::PacketHandler * packetHandler_
uint32_t getData(uint8_t id, uint16_t address, uint16_t data_length)
const ControlItem * control_item
virtual int read2ByteTxRx(PortHandler *port, uint8_t id, uint16_t address, uint16_t *data, uint8_t *error=0)=0
bool syncWrite(uint8_t index, int32_t *data, const char **log=NULL)
virtual int write1ByteTxOnly(PortHandler *port, uint8_t id, uint16_t address, uint8_t data)=0
bool readRegister(uint8_t id, uint16_t address, uint16_t length, uint32_t *data, const char **log=NULL)
const char * getModelName(uint8_t id, const char **log=NULL)
bool writeRegister(uint8_t id, uint16_t address, uint16_t length, uint8_t *data, const char **log=NULL)
static const char * model_name
virtual int reboot(PortHandler *port, uint8_t id, uint8_t *error=0)=0
int COMM_SUCCESS
bool clearMultiTurn(uint8_t id, const char **log=NULL)
bool reset(uint8_t id, const char **log=NULL)
def DXL_MAKEWORD(a, b)
SyncReadHandler syncReadHandler_[MAX_HANDLER_NUM]
virtual void closePort()=0
virtual int readTxRx(PortHandler *port, uint8_t id, uint16_t address, uint16_t length, uint8_t *data, uint8_t *error=0)=0
virtual const char * getRxPacketError(uint8_t error)=0
bool writeOnlyRegister(uint8_t id, uint16_t address, uint16_t length, uint8_t *data, const char **log=NULL)
bool addSyncWriteHandler(uint16_t address, uint16_t length, const char **log=NULL)
bool addSyncReadHandler(uint16_t address, uint16_t length, const char **log=NULL)
uint8_t getDynamixelCount(void)
bool begin(const char *device_name="/dev/ttyUSB0", uint32_t baud_rate=57600, const char **log=NULL)
uint8_t sync_write_handler_cnt_
const ControlItem * getItemInfo(uint8_t id, const char *item_name, const char **log=NULL)
bool ping(uint8_t id, uint16_t *get_model_number, const char **log=NULL)
const ControlItem * getControlTable(void)
uint8_t getTheNumberOfControlItem(void)
bool scan(uint8_t *get_id, uint8_t *get_the_number_of_id, uint8_t range=253, const char **log=NULL)
bool getSyncReadData(uint8_t index, int32_t *data, const char **log=NULL)
DynamixelTool tools_[MAX_DXL_SERIES_NUM]
virtual int write1ByteTxRx(PortHandler *port, uint8_t id, uint16_t address, uint8_t data, uint8_t *error=0)=0
uint8_t bulk_read_parameter_cnt_
virtual int writeTxOnly(PortHandler *port, uint8_t id, uint16_t address, uint16_t length, uint8_t *data)=0
#define DWORD
#define BYTE
virtual float getProtocolVersion()=0
static PacketHandler * getPacketHandler(float protocol_version=2.0)
uint8_t getTheNumberOfSyncReadHandler(void)
def DXL_HIBYTE(w)
const char * getModelName(void)
dynamixel::PortHandler * portHandler_
bool initBulkWrite(const char **log=NULL)
bool clearBulkReadParam(void)
uint16_t data_length
virtual int write4ByteTxOnly(PortHandler *port, uint8_t id, uint16_t address, uint32_t data)=0
const ModelInfo * getModelInfo(uint8_t id, const char **log=NULL)
def DXL_LOWORD(l)
dynamixel::GroupBulkWrite * groupBulkWrite_
void addDXL(uint8_t id)
#define WORD
uint32_t getData(uint8_t id, uint16_t address, uint16_t data_length)
bool setPortHandler(const char *device_name, const char **log=NULL)
virtual int write4ByteTxRx(PortHandler *port, uint8_t id, uint16_t address, uint32_t data, uint8_t *error=0)=0
bool initBulkRead(const char **log=NULL)
uint8_t getTheNumberOfBulkReadParam(void)
dynamixel::GroupSyncRead * groupSyncRead
def DXL_HIWORD(l)
virtual int write2ByteTxRx(PortHandler *port, uint8_t id, uint16_t address, uint16_t data, uint8_t *error=0)=0
bool addTool(const char *model_name, uint8_t id, const char **log=NULL)
#define MAX_DXL_SERIES_NUM
bool bulkWrite(const char **log=NULL)
const ControlItem * getControlTable(uint8_t id, const char **log=NULL)
bool reboot(uint8_t id, const char **log=NULL)
uint8_t getTheNumberOfControlItem(uint8_t id, const char **log=NULL)
bool bulkRead(const char **log=NULL)
virtual int read4ByteTxRx(PortHandler *port, uint8_t id, uint16_t address, uint32_t *data, uint8_t *error=0)=0
void getParam(int32_t data, uint8_t *param)
virtual int getBaudRate()=0
bool setTool(uint16_t model_number, uint8_t id, const char **log=NULL)
virtual int ping(PortHandler *port, uint8_t id, uint8_t *error=0)=0
uint16_t data_length
uint8_t getTool(uint8_t id, const char **log=NULL)
bool syncRead(uint8_t index, const char **log=NULL)
virtual int factoryReset(PortHandler *port, uint8_t id, uint8_t option=0, uint8_t *error=0)=0
def DXL_MAKEDWORD(a, b)
virtual bool setBaudRate(const int baudrate)=0
virtual const char * getTxRxResult(int result)=0
uint8_t get_id[16]
Definition: p_Monitor.cpp:30
uint16_t getModelNumber(uint8_t id, const char **log=NULL)
uint8_t sync_read_handler_cnt_
float getProtocolVersion(void)
def DXL_LOBYTE(w)
virtual int clearMultiTurn(PortHandler *port, uint8_t id, uint8_t *error=0)=0
#define MAX_HANDLER_NUM
bool setBaudrate(uint32_t baud_rate, const char **log=NULL)
BulkParameter bulk_read_param_[MAX_BULK_PARAMETER]
bool dxl_addparam_result
bool addParam(uint8_t id, uint16_t start_address, uint16_t data_length, uint8_t *data)


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