group_sync_write.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 
4 
19 
20 # Author: Ryu Woon Jung (Leon)
21 
22 from .robotis_def import *
23 
24 
26  def __init__(self, port, ph, start_address, data_length):
27  self.port = port
28  self.ph = ph
29  self.start_address = start_address
30  self.data_length = data_length
31 
32  self.is_param_changed = False
33  self.param = []
34  self.data_dict = {}
35 
36  self.clearParam()
37 
38  def makeParam(self):
39  if not self.data_dict:
40  return
41 
42  self.param = []
43 
44  for dxl_id in self.data_dict:
45  if not self.data_dict[dxl_id]:
46  return
47 
48  self.param.append(dxl_id)
49  self.param.extend(self.data_dict[dxl_id])
50 
51  def addParam(self, dxl_id, data):
52  if dxl_id in self.data_dict: # dxl_id already exist
53  return False
54 
55  if len(data) > self.data_length: # input data is longer than set
56  return False
57 
58  self.data_dict[dxl_id] = data
59 
60  self.is_param_changed = True
61  return True
62 
63  def removeParam(self, dxl_id):
64  if dxl_id not in self.data_dict: # NOT exist
65  return
66 
67  del self.data_dict[dxl_id]
68 
69  self.is_param_changed = True
70 
71  def changeParam(self, dxl_id, data):
72  if dxl_id not in self.data_dict: # NOT exist
73  return False
74 
75  if len(data) > self.data_length: # input data is longer than set
76  return False
77 
78  self.data_dict[dxl_id] = data
79 
80  self.is_param_changed = True
81  return True
82 
83  def clearParam(self):
84  self.data_dict.clear()
85 
86  def txPacket(self):
87  if len(self.data_dict.keys()) == 0:
88  return COMM_NOT_AVAILABLE
89 
90  if self.is_param_changed is True or not self.param:
91  self.makeParam()
92 
93  return self.ph.syncWriteTxOnly(self.port, self.start_address, self.data_length, self.param,
94  len(self.data_dict.keys()) * (1 + self.data_length))
dynamixel_sdk.group_sync_write.GroupSyncWrite.ph
ph
Definition: group_sync_write.py:28
dynamixel_sdk.group_sync_write.GroupSyncWrite.data_length
data_length
Definition: group_sync_write.py:30
dynamixel_sdk.group_sync_write.GroupSyncWrite.data_dict
data_dict
Definition: group_sync_write.py:34
dynamixel_sdk.group_sync_write.GroupSyncWrite.addParam
def addParam(self, dxl_id, data)
Definition: group_sync_write.py:51
dynamixel_sdk.group_sync_write.GroupSyncWrite.port
port
Definition: group_sync_write.py:27
dynamixel_sdk.group_sync_write.GroupSyncWrite.makeParam
def makeParam(self)
Definition: group_sync_write.py:38
dynamixel_sdk.group_sync_write.GroupSyncWrite.changeParam
def changeParam(self, dxl_id, data)
Definition: group_sync_write.py:71
dynamixel_sdk.group_sync_write.GroupSyncWrite.removeParam
def removeParam(self, dxl_id)
Definition: group_sync_write.py:63
dynamixel_sdk.group_sync_write.GroupSyncWrite.param
param
Definition: group_sync_write.py:33
dynamixel_sdk.group_sync_write.GroupSyncWrite.is_param_changed
is_param_changed
Definition: group_sync_write.py:32
dynamixel_sdk.group_sync_write.GroupSyncWrite.start_address
start_address
Definition: group_sync_write.py:29
dynamixel_sdk.group_sync_write.GroupSyncWrite
Definition: group_sync_write.py:25
dynamixel_sdk.group_sync_write.GroupSyncWrite.txPacket
def txPacket(self)
Definition: group_sync_write.py:86
dynamixel_sdk.group_sync_write.GroupSyncWrite.clearParam
def clearParam(self)
Definition: group_sync_write.py:83
dynamixel_sdk.group_sync_write.GroupSyncWrite.__init__
def __init__(self, port, ph, start_address, data_length)
Definition: group_sync_write.py:26


dynamixel_sdk
Author(s): Gilbert , Zerom , Darby Lim , Leon
autogenerated on Wed Mar 2 2022 00:13:50