ArtusAPI 1.1.0__tar.gz → 1.1.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. {ArtusAPI-1.1.0 → ArtusAPI-1.1.1}/ArtusAPI/artus_api.py +22 -16
  2. {ArtusAPI-1.1.0 → ArtusAPI-1.1.1}/ArtusAPI/communication/UART/uart.py +6 -5
  3. {ArtusAPI-1.1.0 → ArtusAPI-1.1.1}/ArtusAPI/communication/communication.py +7 -6
  4. {ArtusAPI-1.1.0 → ArtusAPI-1.1.1}/ArtusAPI/robot/artus_lite/artus_lite.py +14 -7
  5. {ArtusAPI-1.1.0 → ArtusAPI-1.1.1}/ArtusAPI.egg-info/PKG-INFO +1 -1
  6. {ArtusAPI-1.1.0 → ArtusAPI-1.1.1}/PKG-INFO +1 -1
  7. {ArtusAPI-1.1.0 → ArtusAPI-1.1.1}/setup.py +1 -1
  8. {ArtusAPI-1.1.0 → ArtusAPI-1.1.1}/ArtusAPI/__init__.py +0 -0
  9. {ArtusAPI-1.1.0 → ArtusAPI-1.1.1}/ArtusAPI/commands/__init__.py +0 -0
  10. {ArtusAPI-1.1.0 → ArtusAPI-1.1.1}/ArtusAPI/commands/commands.py +0 -0
  11. {ArtusAPI-1.1.0 → ArtusAPI-1.1.1}/ArtusAPI/communication/UART/__init__.py +0 -0
  12. {ArtusAPI-1.1.0 → ArtusAPI-1.1.1}/ArtusAPI/communication/WiFi/__init__.py +0 -0
  13. {ArtusAPI-1.1.0 → ArtusAPI-1.1.1}/ArtusAPI/communication/WiFi/wifi_server.py +0 -0
  14. {ArtusAPI-1.1.0 → ArtusAPI-1.1.1}/ArtusAPI/communication/__init__.py +0 -0
  15. {ArtusAPI-1.1.0 → ArtusAPI-1.1.1}/ArtusAPI/firmware_update/__init__.py +0 -0
  16. {ArtusAPI-1.1.0 → ArtusAPI-1.1.1}/ArtusAPI/firmware_update/firmware_updater.py +0 -0
  17. {ArtusAPI-1.1.0 → ArtusAPI-1.1.1}/ArtusAPI/firmware_update/run_full_firmware_update.py +0 -0
  18. {ArtusAPI-1.1.0 → ArtusAPI-1.1.1}/ArtusAPI/robot/__init__.py +0 -0
  19. {ArtusAPI-1.1.0 → ArtusAPI-1.1.1}/ArtusAPI/robot/artus_lite/__init__.py +0 -0
  20. {ArtusAPI-1.1.0 → ArtusAPI-1.1.1}/ArtusAPI/robot/artus_lite/artus_lite_left.py +0 -0
  21. {ArtusAPI-1.1.0 → ArtusAPI-1.1.1}/ArtusAPI/robot/artus_lite/artus_lite_right.py +0 -0
  22. {ArtusAPI-1.1.0 → ArtusAPI-1.1.1}/ArtusAPI/robot/robot.py +0 -0
  23. {ArtusAPI-1.1.0 → ArtusAPI-1.1.1}/ArtusAPI.egg-info/SOURCES.txt +0 -0
  24. {ArtusAPI-1.1.0 → ArtusAPI-1.1.1}/ArtusAPI.egg-info/dependency_links.txt +0 -0
  25. {ArtusAPI-1.1.0 → ArtusAPI-1.1.1}/ArtusAPI.egg-info/top_level.txt +0 -0
  26. {ArtusAPI-1.1.0 → ArtusAPI-1.1.1}/README.md +0 -0
  27. {ArtusAPI-1.1.0 → ArtusAPI-1.1.1}/setup.cfg +0 -0
@@ -54,11 +54,15 @@ class ArtusAPI:
54
54
  hand_type = hand_type)
55
55
 
56
56
  self._last_command_sent_time = time.perf_counter()
57
- self._communication_frequency = 1 / communication_frequency
58
- self._communication_frequency_us = int(self._communication_frequency * 1000000)
57
+ self._communication_frequency = communication_frequency
58
+ self._communication_period = 1 / self._communication_frequency
59
+ self._communication_period_ms = self._communication_period * 1000
59
60
  self.stream = stream
60
61
  self.awake = awake
61
62
 
63
+ # only used during streaming
64
+ self.last_command_recv_time = time.perf_counter()
65
+
62
66
  if not logger:
63
67
  self.logger = logging.getLogger(__name__)
64
68
  else:
@@ -89,8 +93,8 @@ class ArtusAPI:
89
93
  """
90
94
  Wake-up the Artus Hand
91
95
  """
92
- print(f"communication frequency in useconds = {self._communication_frequency_us}")
93
- robot_wake_up_command = self._command_handler.get_robot_start_command(self.stream,self._communication_frequency_us) # to ms for masterboard
96
+ print(f"communication period = {self._communication_period_ms} ms")
97
+ robot_wake_up_command = self._command_handler.get_robot_start_command(self.stream,int(self._communication_period_ms)) # to ms for masterboard
94
98
  self._communication_handler.send_data(robot_wake_up_command)
95
99
 
96
100
  # wait for data back
@@ -134,7 +138,7 @@ class ArtusAPI:
134
138
  self._robot_handler.set_joint_angles(joint_angles=joint_angles,name=False)
135
139
  robot_set_joint_angles_command = self._command_handler.get_target_position_command(self._robot_handler.robot.hand_joints)
136
140
  # check communication frequency
137
- if not self._check_communication_frequency():
141
+ if not self._check_communication_frequency(self._last_command_sent_time):
138
142
  return False
139
143
  return self._communication_handler.send_data(robot_set_joint_angles_command)
140
144
 
@@ -149,19 +153,19 @@ class ArtusAPI:
149
153
  self._robot_handler.set_home_position()
150
154
  robot_set_home_position_command = self._command_handler.get_target_position_command(hand_joints=self._robot_handler.robot.hand_joints)
151
155
  # check communication frequency
152
- if not self._check_communication_frequency():
156
+ if not self._check_communication_frequency(self._last_command_sent_time):
153
157
  return False
154
158
  return self._communication_handler.send_data(robot_set_home_position_command)
155
159
 
156
- def _check_communication_frequency(self):
160
+ def _check_communication_frequency(self,last_command_time):
157
161
  """
158
162
  check if the communication frequency is too high
159
163
  """
160
164
  current_time = time.perf_counter()
161
- if current_time - self._last_command_sent_time < self._communication_frequency:
165
+ if current_time - last_command_time < self._communication_period:
162
166
  self.logger.warning("Command not sent. Communication frequency is too high.")
163
167
  return False
164
- self._last_command_sent_time = current_time
168
+ last_command_time = current_time
165
169
  return True
166
170
 
167
171
  # robot feedback
@@ -176,7 +180,7 @@ class ArtusAPI:
176
180
  feedback_command = self._command_handler.get_states_command()
177
181
  self._communication_handler.send_data(feedback_command)
178
182
  # test
179
- time.sleep(0.005)
183
+ time.sleep(0.001)
180
184
  return self._communication_handler.receive_data()
181
185
 
182
186
  def get_joint_angles(self):
@@ -189,7 +193,7 @@ class ArtusAPI:
189
193
 
190
194
  feedback_command = self._receive_feedback()
191
195
  joint_angles = self._robot_handler.get_joint_angles(feedback_command)
192
- print(joint_angles)
196
+ # print(joint_angles)
193
197
  return joint_angles
194
198
 
195
199
  # robot feedback stream
@@ -201,12 +205,14 @@ class ArtusAPI:
201
205
  self.logger.warning(f'Hand not ready, send `wake_up` command')
202
206
  return
203
207
 
204
- if not self._check_communication_frequency():
205
- return False
206
- feedback_command = self._communication_handler.receive_data()
207
- if not feedback_command:
208
+ if not self._check_communication_frequency(self.last_command_recv_time):
208
209
  return None
209
- joint_angles = self._robot_handler.get_joint_angles(feedback_command)
210
+ else:
211
+ feedback_command = self._communication_handler.receive_data()
212
+ if not feedback_command:
213
+ print(f'feedback is none')
214
+ return None
215
+ joint_angles = self._robot_handler.get_joint_angles(feedback_command)
210
216
  return joint_angles
211
217
 
212
218
  def update_firmware(self,upload_flag='y',file_location=None,drivers_to_flash=0):
@@ -60,22 +60,23 @@ class UART:
60
60
  # pass
61
61
  try:
62
62
  x = time.perf_counter()
63
- # print(f'time start: {x}')
63
+ # # print(f'time start: {x}')
64
64
  while self.esp32.in_waiting < 65:
65
- if time.perf_counter() - x > 0.02:
65
+ if time.perf_counter() - x > 0.001:
66
66
  break
67
67
  # print(f'elapsed time: {time.perf_counter() - x}')
68
68
  # time.sleep(0.03)
69
69
  # check data
70
70
  if self.esp32.in_waiting >= 65: # get data if greater or equal to 65
71
71
  msg_bytes = self.esp32.read(65)
72
- print(msg_bytes)
72
+ # print(msg_bytes)
73
73
  return msg_bytes
74
- elif self.esp32.in_waiting > 0: # clear buffer if not correct amount of data
74
+ elif self.esp32.in_waiting > 0:
75
75
  # msg_bytes = self.esp32.read_all()
76
- self.logger.warning(f"Incomplete data received - package size = {(self.esp32.in_waiting)}")
76
+ # self.logger.warning(f"Incomplete data received - package size = {(self.esp32.in_waiting)}")
77
77
  return None
78
78
  else: # non blocking
79
+ # self.logger.warning(f"No data available to receive")
79
80
  return None
80
81
  except Exception as e:
81
82
  self.logger.warning(f"No data available to receive {e}")
@@ -113,7 +113,7 @@ class Communication:
113
113
  self.logger.error("unable to connect to Robot")
114
114
  print(e)
115
115
 
116
- def send_data(self, message:list,no_debug=None):
116
+ def send_data(self, message:list,no_debug=1):
117
117
  """
118
118
  send message
119
119
  """
@@ -137,11 +137,10 @@ class Communication:
137
137
  """
138
138
  byte_msg_recv = None
139
139
  try:
140
- while byte_msg_recv is None:
141
- byte_msg_recv = self.communicator.receive()
142
- if not byte_msg_recv:
143
- # self.logger.warning("No data received")
144
- return None,None
140
+ byte_msg_recv = self.communicator.receive()
141
+ if not byte_msg_recv:
142
+ # self.logger.warning("No data received")
143
+ return None,None
145
144
  ack,message_received = self._byte_to_list_decode(byte_msg_recv)
146
145
  if ack == 9:
147
146
  self.logger.warning("[E] error ack")
@@ -157,9 +156,11 @@ class Communication:
157
156
 
158
157
 
159
158
  def wait_for_ack(self):
159
+ start_time = time.perf_counter()
160
160
  while 1:
161
161
  tmp,rc_csum = self.receive_data()
162
162
  if tmp is not None:
163
+ print(f'ack received in {time.perf_counter() - start_time} seconds')
163
164
  return 1
164
165
  time.sleep(0.001)
165
166
 
@@ -180,13 +180,20 @@ class ArtusLite:
180
180
  Get the joint angles and feedback list data
181
181
  and populate the feedback fields in the hand_joints dictionary
182
182
  """
183
- print(f'FB PACKAGE = {feedback_package}')
184
- for name,joint_data in self.hand_joints.items():
185
- joint_data.feedback_angle = feedback_package[1][joint_data.index]
186
- joint_data.feedback_current = feedback_package[1][joint_data.index+15]
187
- joint_data.feedback_temperature = feedback_package[1][joint_data.index+31]
188
-
189
- return feedback_package
183
+ # print(f'FB PACKAGE = {feedback_package}')
184
+ try:
185
+ for name,joint_data in self.hand_joints.items():
186
+ joint_data.feedback_angle = feedback_package[1][joint_data.index]
187
+ joint_data.feedback_current = feedback_package[1][joint_data.index+15]
188
+ joint_data.feedback_temperature = feedback_package[1][joint_data.index+31]
189
+
190
+ return feedback_package
191
+ except TypeError:
192
+ # print(f'feedback_package is None')
193
+ return None
194
+ except Exception as e:
195
+ print(e)
196
+ return None
190
197
 
191
198
 
192
199
  def main():
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ArtusAPI
3
- Version: 1.1.0
3
+ Version: 1.1.1
4
4
  Summary: API to control Artus Family of Robots by Sarcomere Dynamics Inc
5
5
  Home-page: UNKNOWN
6
6
  Author: Sarcomere Dynamics Inc.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ArtusAPI
3
- Version: 1.1.0
3
+ Version: 1.1.1
4
4
  Summary: API to control Artus Family of Robots by Sarcomere Dynamics Inc
5
5
  Home-page: UNKNOWN
6
6
  Author: Sarcomere Dynamics Inc.
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name='ArtusAPI',
5
- version='1.1.0',
5
+ version='1.1.1',
6
6
  description='API to control Artus Family of Robots by Sarcomere Dynamics Inc',
7
7
  # package_dir={'': '/'}, # tells setuptools that your packages are under src
8
8
  packages=find_packages(exclude=['data*', 'examples*', 'tests*','venv*', 'urdf*', 'ros2*']),
File without changes
File without changes
File without changes