ArtusAPI 1.3.15__tar.gz → 1.3.17__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 (35) hide show
  1. {ArtusAPI-1.3.15 → ArtusAPI-1.3.17}/ArtusAPI/artus_api.py +22 -13
  2. {ArtusAPI-1.3.15 → ArtusAPI-1.3.17}/ArtusAPI/commands/commands.py +3 -1
  3. {ArtusAPI-1.3.15 → ArtusAPI-1.3.17}/ArtusAPI/communication/UART/uart.py +1 -1
  4. {ArtusAPI-1.3.15 → ArtusAPI-1.3.17}/ArtusAPI/communication/WiFi/wifi_server.py +16 -0
  5. ArtusAPI-1.3.17/ArtusAPI/communication/__init__.py +1 -0
  6. {ArtusAPI-1.3.15 → ArtusAPI-1.3.17}/ArtusAPI/communication/communication.py +12 -9
  7. {ArtusAPI-1.3.15 → ArtusAPI-1.3.17}/ArtusAPI/robot/artus_lite/artus_lite_plus.py +26 -1
  8. {ArtusAPI-1.3.15 → ArtusAPI-1.3.17}/ArtusAPI/robot/robot.py +5 -2
  9. {ArtusAPI-1.3.15 → ArtusAPI-1.3.17}/ArtusAPI.egg-info/PKG-INFO +1 -1
  10. {ArtusAPI-1.3.15 → ArtusAPI-1.3.17}/PKG-INFO +1 -1
  11. {ArtusAPI-1.3.15 → ArtusAPI-1.3.17}/setup.py +1 -1
  12. ArtusAPI-1.3.15/ArtusAPI/communication/__init__.py +0 -1
  13. {ArtusAPI-1.3.15 → ArtusAPI-1.3.17}/ArtusAPI/__init__.py +0 -0
  14. {ArtusAPI-1.3.15 → ArtusAPI-1.3.17}/ArtusAPI/commands/__init__.py +0 -0
  15. {ArtusAPI-1.3.15 → ArtusAPI-1.3.17}/ArtusAPI/communication/UART/__init__.py +0 -0
  16. {ArtusAPI-1.3.15 → ArtusAPI-1.3.17}/ArtusAPI/communication/WiFi/__init__.py +0 -0
  17. {ArtusAPI-1.3.15 → ArtusAPI-1.3.17}/ArtusAPI/firmware_update/__init__.py +0 -0
  18. {ArtusAPI-1.3.15 → ArtusAPI-1.3.17}/ArtusAPI/firmware_update/firmware_updater.py +0 -0
  19. {ArtusAPI-1.3.15 → ArtusAPI-1.3.17}/ArtusAPI/firmware_update/run_full_firmware_update.py +0 -0
  20. {ArtusAPI-1.3.15 → ArtusAPI-1.3.17}/ArtusAPI/robot/__init__.py +0 -0
  21. {ArtusAPI-1.3.15 → ArtusAPI-1.3.17}/ArtusAPI/robot/artus_lite/__init__.py +0 -0
  22. {ArtusAPI-1.3.15 → ArtusAPI-1.3.17}/ArtusAPI/robot/artus_lite/artus_lite.py +0 -0
  23. {ArtusAPI-1.3.15 → ArtusAPI-1.3.17}/ArtusAPI/robot/artus_lite/artus_lite_left.py +0 -0
  24. {ArtusAPI-1.3.15 → ArtusAPI-1.3.17}/ArtusAPI/robot/artus_lite/artus_lite_plus_left.py +0 -0
  25. {ArtusAPI-1.3.15 → ArtusAPI-1.3.17}/ArtusAPI/robot/artus_lite/artus_lite_plus_right.py +0 -0
  26. {ArtusAPI-1.3.15 → ArtusAPI-1.3.17}/ArtusAPI/robot/artus_lite/artus_lite_right.py +0 -0
  27. {ArtusAPI-1.3.15 → ArtusAPI-1.3.17}/ArtusAPI/sensors/ForceSensor.py +0 -0
  28. {ArtusAPI-1.3.15 → ArtusAPI-1.3.17}/ArtusAPI/sensors/__init__.py +0 -0
  29. {ArtusAPI-1.3.15 → ArtusAPI-1.3.17}/ArtusAPI.egg-info/SOURCES.txt +0 -0
  30. {ArtusAPI-1.3.15 → ArtusAPI-1.3.17}/ArtusAPI.egg-info/dependency_links.txt +0 -0
  31. {ArtusAPI-1.3.15 → ArtusAPI-1.3.17}/ArtusAPI.egg-info/entry_points.txt +0 -0
  32. {ArtusAPI-1.3.15 → ArtusAPI-1.3.17}/ArtusAPI.egg-info/requires.txt +0 -0
  33. {ArtusAPI-1.3.15 → ArtusAPI-1.3.17}/ArtusAPI.egg-info/top_level.txt +0 -0
  34. {ArtusAPI-1.3.15 → ArtusAPI-1.3.17}/README.md +0 -0
  35. {ArtusAPI-1.3.15 → ArtusAPI-1.3.17}/setup.cfg +0 -0
@@ -21,7 +21,7 @@ print(desired_path)
21
21
 
22
22
 
23
23
 
24
- from .communication import Communication
24
+ from .communication import Communication,STARTUP_ACK,NORMAL_ACK
25
25
  from .commands import Commands
26
26
  from .robot import Robot
27
27
  from .firmware_update import FirmwareUpdater
@@ -112,7 +112,7 @@ class ArtusAPI:
112
112
  self._communication_handler.send_data(robot_wake_up_command)
113
113
 
114
114
  # wait for data back
115
- if self._communication_handler.wait_for_ack():
115
+ if self._communication_handler.wait_for_ack(value=STARTUP_ACK):
116
116
  self.logger.info(f'Finished calibration')
117
117
  else:
118
118
  self.logger.warning(f'Error in calibration')
@@ -217,13 +217,13 @@ class ArtusAPI:
217
217
  """
218
218
  current_time = time.perf_counter()
219
219
  if current_time - self.last_times[type] < self._communication_period:
220
- self.logger.warning("Command not sent. Communication frequency is too high.")
220
+ self.logger.debug("Command not sent. Communication frequency is too high.")
221
221
  return False
222
222
  self.last_times[type] = current_time
223
223
  return True
224
224
 
225
225
  # robot feedback
226
- def _receive_feedback(self):
226
+ def _receive_feedback(self,type=0):
227
227
  """
228
228
  Send a request for feedback data and receive feedback data
229
229
 
@@ -234,15 +234,19 @@ class ArtusAPI:
234
234
  self.logger.warning(f'Hand not ready, send `wake_up` command')
235
235
  return
236
236
 
237
- feedback_command = self._command_handler.get_states_command()
237
+ feedback_command = self._command_handler.get_states_command(type=type)
238
238
  self._communication_handler.send_data(feedback_command)
239
239
  # test
240
240
  time.sleep(0.001)
241
- return self._communication_handler.receive_data()
241
+ return self._communication_handler.receive_data(type)
242
242
 
243
- def get_joint_angles(self):
243
+
244
+ def get_joint_angles(self,type=0):
244
245
  """
245
246
  Populate feedback fields in self._robot_handler.hand_joints dict
247
+ type: only applicable to artus+
248
+ 0: get joint angles and force values from fingertip
249
+ 1: get actuator data (temperature and current)
246
250
 
247
251
  Returns:
248
252
  :tuple: (ack, angles, velocities, temperatures)
@@ -255,16 +259,16 @@ class ArtusAPI:
255
259
  self.logger.warning(f'Hand not ready, send `wake_up` command')
256
260
  return
257
261
 
258
- feedback_command = self._receive_feedback()
262
+ feedback_command = self._receive_feedback(type)
259
263
  if not self._check_communication_frequency(1):
260
264
  return None
261
- joint_angles = self._robot_handler.get_joint_angles(feedback_command)
265
+ joint_angles = self._robot_handler.get_joint_angles(feedback_command,type=type)
262
266
  if joint_angles is None:
263
267
  return None
264
268
 
265
269
  angles = joint_angles[1][0:16]
266
270
 
267
- if self._robot_handler.robot_type == 'artus_lite':
271
+ if self._robot_handler.robot_type == 'artus_lite' or type == 1:
268
272
  # separate joint angles into 3 lists
269
273
  velocities = joint_angles[1][16:32]
270
274
  temperatures = joint_angles[1][32:48]
@@ -298,7 +302,7 @@ class ArtusAPI:
298
302
  if not feedback_command:
299
303
  print(f'feedback is none')
300
304
  return None
301
- joint_angles = self._robot_handler.get_joint_angles(feedback_command)
305
+ joint_angles = self._robot_handler.get_joint_angles(feedback_command,type=0)
302
306
  return joint_angles
303
307
 
304
308
  def update_firmware(self,upload_flag='y',file_location=None,drivers_to_flash=0):
@@ -603,7 +607,8 @@ def main_flash():
603
607
  bin_paths = {
604
608
  "actuator_64": "https://gist.githubusercontent.com/SDRyanLee/ad8bbe17164c74e6417d1e2d4d0843d2/raw/actuator_64.txt",
605
609
  "peripheral_64": "https://gist.githubusercontent.com/SDRyanLee/ad8bbe17164c74e6417d1e2d4d0843d2/raw/peripheral_64.txt",
606
- "peripheral_plus_64": "https://gist.githubusercontent.com/SDRyanLee/ad8bbe17164c74e6417d1e2d4d0843d2/raw/peripheral_plus_64.txt",
610
+ "peripheral_plus_right_64": "https://gist.githubusercontent.com/SDRyanLee/ad8bbe17164c74e6417d1e2d4d0843d2/raw/peripheral_plus_right_64.txt",
611
+ "peripheral_plus_left_64": "https://gist.githubusercontent.com/SDRyanLee/ad8bbe17164c74e6417d1e2d4d0843d2/raw/peripheral_plus_left_64.txt",
607
612
 
608
613
  "master_64_right": "https://gist.githubusercontent.com/SDRyanLee/ad8bbe17164c74e6417d1e2d4d0843d2/raw/master_right_64.txt",
609
614
  "master_plus_64_right": "https://gist.githubusercontent.com/SDRyanLee/ad8bbe17164c74e6417d1e2d4d0843d2/raw/master_plus_64.txt",
@@ -646,10 +651,14 @@ def main_flash():
646
651
  driver_to_flash = 0
647
652
  print('Flashing actuator')
648
653
  elif type_flash == 'peripheral':
654
+ print(f'flashing peripheral with parameters: {args.robot} {args.side}')
649
655
  if args.robot == 'artus_lite':
650
656
  file_location = bin_paths['peripheral_64']
651
657
  elif args.robot == 'artus_lite_plus':
652
- file_location = bin_paths['peripheral_plus_64']
658
+ if args.side == 'right':
659
+ file_location = bin_paths['peripheral_plus_right_64']
660
+ elif args.side == 'left':
661
+ file_location = bin_paths['peripheral_plus_left_64']
653
662
  driver_to_flash = 9
654
663
  print('Flashing peripheral')
655
664
 
@@ -110,9 +110,11 @@ class Commands:
110
110
  command_list.insert(0,self.commands['sleep_command'])
111
111
  return command_list
112
112
 
113
- def get_states_command(self):
113
+ def get_states_command(self,type=0):
114
114
  command_list = [0]*32
115
115
  command_list.insert(0,self.commands['get_feedback_command'])
116
+ if type == 1:
117
+ command_list[1] = 1 # get actuator data -- only applicable to artus+
116
118
  return command_list
117
119
 
118
120
  def get_firmware_update_command(self):
@@ -89,7 +89,7 @@ class UART:
89
89
  # print(msg_bytes)
90
90
  return msg_bytes
91
91
  elif self.esp32.in_waiting > 0:
92
- # msg_bytes = self.esp32.read_all()
92
+ msg_bytes = self.esp32.read_all()
93
93
  # self.logger.warning(f"Incomplete data received - package size = {(self.esp32.in_waiting)}")
94
94
  return None
95
95
  else: # non blocking
@@ -73,6 +73,20 @@ class WiFiServer:
73
73
  """ Start server and listen for connections """
74
74
  def open(self):
75
75
  try:
76
+ # Refresh network interfaces on the OS to ensure up-to-date network info
77
+ sys_platform = platform.system()
78
+ if sys_platform == "Windows":
79
+ os.system("ipconfig /release")
80
+ os.system("ipconfig /renew")
81
+ elif sys_platform == "Linux":
82
+ os.system("nmcli networking off")
83
+ time.sleep(1)
84
+ os.system("nmcli networking on")
85
+ elif sys_platform == "Darwin":
86
+ os.system("sudo ifconfig en0 down")
87
+ time.sleep(1)
88
+ os.system("sudo ifconfig en0 up")
89
+ time.sleep(2)
76
90
 
77
91
  # look for wifi
78
92
  self._find_ssid()
@@ -196,6 +210,8 @@ class WiFiServer:
196
210
  else:
197
211
  self.logger.warning(f"Incomplete data received - package size = {len(byte_msg)}")
198
212
  return None
213
+ except TimeoutError:
214
+ None
199
215
  except Exception as e:
200
216
  # TODO logging
201
217
  self.logger.warning(f"No data available to receive {e}")
@@ -0,0 +1 @@
1
+ from .communication import Communication,STARTUP_ACK,NORMAL_ACK
@@ -89,11 +89,11 @@ class Communication:
89
89
  # return byte array to send
90
90
  return send_data
91
91
 
92
- def _byte_to_list_decode(self,package:bytearray) -> tuple:
92
+ def _byte_to_list_decode(self,package:bytearray,type=0) -> tuple:
93
93
  recv_data = []
94
94
  i = 0
95
95
 
96
- if self.robot_type == 'artus_lite':
96
+ if self.robot_type == 'artus_lite' or type == 1:
97
97
  # BYTE 0 : ACK
98
98
  # BYTE 1 - 16 : 8 BIT POSITION
99
99
  # BYTE 17 - 49 : 16 BIT POSITION
@@ -164,7 +164,7 @@ class Communication:
164
164
  pass
165
165
  return False
166
166
 
167
- def receive_data(self) -> list:
167
+ def receive_data(self,type=0) -> list:
168
168
  """
169
169
  receive message
170
170
  """
@@ -174,7 +174,7 @@ class Communication:
174
174
  if not byte_msg_recv:
175
175
  # self.logger.warning("No data received")
176
176
  return None,None
177
- ack,message_received = self._byte_to_list_decode(byte_msg_recv)
177
+ ack,message_received = self._byte_to_list_decode(byte_msg_recv,type)
178
178
  if ack == 9:
179
179
  self.logger.warning("[E] error ack")
180
180
  # print(ack)
@@ -194,12 +194,12 @@ class Communication:
194
194
  with tqdm(total=timeout, unit="s", desc="Waiting for ack") as pbar:
195
195
  while 1:
196
196
  tmp,rc_csum = self.receive_data()
197
- if value == NORMAL_ACK:
198
- if tmp is not None:
199
- self.logger.info(f'ack received in {time.perf_counter() - start_time} seconds')
200
- return 1
201
- elif tmp == value:
197
+ # if value == NORMAL_ACK:
198
+ if tmp is not None:
202
199
  self.logger.info(f'ack received in {time.perf_counter() - start_time} seconds')
200
+ if value == STARTUP_ACK:
201
+ self.logger.info(f'Artus Version {rc_csum[0]}.{rc_csum[1]}')
202
+ print(f'Artus Version {rc_csum[0]}.{rc_csum[1]}')
203
203
  return 1
204
204
  time.sleep(0.01)
205
205
  if time.perf_counter() - start_time > timeout:
@@ -212,6 +212,9 @@ class Communication:
212
212
  tmp,rc_csum = self.receive_data()
213
213
  if tmp is not None:
214
214
  self.logger.info(f'ack received in {time.perf_counter() - start_time} seconds')
215
+ if value == STARTUP_ACK:
216
+ self.logger.info(f'Artus Version {rc_csum[0]}.{rc_csum[1]}')
217
+ print(f'Artus Version {rc_csum[0]}.{rc_csum[1]}')
215
218
  return 1
216
219
  if time.perf_counter() - start_time > timeout:
217
220
  self.logger.error('timeout error\r\ntimeout error\r\ntimeout error')
@@ -27,7 +27,7 @@ class ArtusLite_Plus(ArtusLite):
27
27
  'indices' : indices[i]
28
28
  }
29
29
 
30
- def get_joint_angles(self, feedback_package:list):
30
+ def get_joint_angles_force(self, feedback_package:list):
31
31
  """
32
32
  Get the joint angles and feedback list data
33
33
  and populate the feedback fields in the hand_joints dictionary
@@ -54,6 +54,31 @@ class ArtusLite_Plus(ArtusLite):
54
54
  object['data'].z = feedback_slice[i+2]
55
55
  i += 3
56
56
 
57
+ return feedback_package
58
+ except TypeError:
59
+ # print(f'feedback_package is None')
60
+ return None
61
+ except Exception as e:
62
+ print(e)
63
+ return None
64
+
65
+ def get_joint_angles(self, feedback_package:list):
66
+ """
67
+ Get the joint angles and feedback list data
68
+ and populate the feedback fields in the hand_joints dictionary
69
+ """
70
+ # print(f'FB PACKAGE = {feedback_package}')
71
+ try:
72
+ for name,joint_data in self.hand_joints.items():
73
+ joint_data.feedback_angle = feedback_package[1][joint_data.index]
74
+ joint_data.feedback_current = feedback_package[1][joint_data.index+15]
75
+ joint_data.feedback_force = round(feedback_package[1][joint_data.index+15] * 0.0035904, 2) # take current value and convert to force
76
+ joint_data.feedback_temperature = feedback_package[1][joint_data.index+31]
77
+
78
+ if joint_data.index in [1,5,8,11,14] and joint_data.feedback_angle < 0:
79
+ joint_data.feedback_angle = -joint_data.feedback_angle
80
+ feedback_package[1][joint_data.index] = -feedback_package[1][joint_data.index]
81
+
57
82
  return feedback_package
58
83
  except TypeError:
59
84
  # print(f'feedback_package is None')
@@ -71,11 +71,14 @@ class Robot:
71
71
  """
72
72
  return self.robot.set_home_position()
73
73
 
74
- def get_joint_angles(self, joint_angles):
74
+ def get_joint_angles(self, joint_angles,type=0):
75
75
  """
76
76
  Get the joint angles of the hand
77
77
  """
78
- return self.robot.get_joint_angles(joint_angles)
78
+ if type == 1 or self.robot_type == 'artus_lite':
79
+ return self.robot.get_joint_angles(joint_angles)
80
+ elif self.robot_type == 'artus_lite_plus':
81
+ return self.robot.get_joint_angles_force(joint_angles)
79
82
 
80
83
 
81
84
  def main():
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ArtusAPI
3
- Version: 1.3.15
3
+ Version: 1.3.17
4
4
  Summary: API to control Artus Family of Robots by Sarcomere Dynamics Inc
5
5
  Home-page: https://sarcomeredynamics.com/home
6
6
  Author: Sarcomere Dynamics Inc.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ArtusAPI
3
- Version: 1.3.15
3
+ Version: 1.3.17
4
4
  Summary: API to control Artus Family of Robots by Sarcomere Dynamics Inc
5
5
  Home-page: https://sarcomeredynamics.com/home
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.3.15',
5
+ version='1.3.17',
6
6
  description='API to control Artus Family of Robots by Sarcomere Dynamics Inc',
7
7
  long_description=open('README.md').read(),
8
8
  long_description_content_type='text/markdown',
@@ -1 +0,0 @@
1
- from .communication import Communication
File without changes
File without changes