ArtusAPI 1.1.1__tar.gz → 1.3__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 (36) hide show
  1. ArtusAPI-1.3/ArtusAPI/__init__.py +1 -0
  2. {ArtusAPI-1.1.1 → ArtusAPI-1.3}/ArtusAPI/artus_api.py +299 -32
  3. {ArtusAPI-1.1.1 → ArtusAPI-1.3}/ArtusAPI/commands/commands.py +21 -1
  4. {ArtusAPI-1.1.1 → ArtusAPI-1.3}/ArtusAPI/communication/UART/uart.py +22 -5
  5. {ArtusAPI-1.1.1 → ArtusAPI-1.3}/ArtusAPI/communication/WiFi/wifi_server.py +15 -3
  6. {ArtusAPI-1.1.1 → ArtusAPI-1.3}/ArtusAPI/communication/communication.py +88 -35
  7. {ArtusAPI-1.1.1 → ArtusAPI-1.3}/ArtusAPI/firmware_update/firmware_updater.py +55 -41
  8. {ArtusAPI-1.1.1 → ArtusAPI-1.3}/ArtusAPI/firmware_update/run_full_firmware_update.py +12 -0
  9. ArtusAPI-1.3/ArtusAPI/robot/artus_lite/__init__.py +5 -0
  10. {ArtusAPI-1.1.1 → ArtusAPI-1.3}/ArtusAPI/robot/artus_lite/artus_lite.py +15 -11
  11. ArtusAPI-1.3/ArtusAPI/robot/artus_lite/artus_lite_plus.py +63 -0
  12. ArtusAPI-1.3/ArtusAPI/robot/artus_lite/artus_lite_plus_right.py +10 -0
  13. {ArtusAPI-1.1.1 → ArtusAPI-1.3}/ArtusAPI/robot/robot.py +18 -12
  14. ArtusAPI-1.3/ArtusAPI/sensors/ForceSensor.py +12 -0
  15. ArtusAPI-1.3/ArtusAPI/sensors/__init__.py +1 -0
  16. {ArtusAPI-1.1.1 → ArtusAPI-1.3}/ArtusAPI.egg-info/PKG-INFO +3 -2
  17. {ArtusAPI-1.1.1 → ArtusAPI-1.3}/ArtusAPI.egg-info/SOURCES.txt +7 -1
  18. ArtusAPI-1.3/ArtusAPI.egg-info/entry_points.txt +3 -0
  19. ArtusAPI-1.3/ArtusAPI.egg-info/requires.txt +6 -0
  20. {ArtusAPI-1.1.1 → ArtusAPI-1.3}/PKG-INFO +3 -2
  21. ArtusAPI-1.3/README.md +176 -0
  22. {ArtusAPI-1.1.1 → ArtusAPI-1.3}/setup.py +18 -3
  23. ArtusAPI-1.1.1/ArtusAPI/__init__.py +0 -0
  24. ArtusAPI-1.1.1/ArtusAPI/robot/artus_lite/__init__.py +0 -3
  25. ArtusAPI-1.1.1/README.md +0 -217
  26. {ArtusAPI-1.1.1 → ArtusAPI-1.3}/ArtusAPI/commands/__init__.py +0 -0
  27. {ArtusAPI-1.1.1 → ArtusAPI-1.3}/ArtusAPI/communication/UART/__init__.py +0 -0
  28. {ArtusAPI-1.1.1 → ArtusAPI-1.3}/ArtusAPI/communication/WiFi/__init__.py +0 -0
  29. {ArtusAPI-1.1.1 → ArtusAPI-1.3}/ArtusAPI/communication/__init__.py +0 -0
  30. {ArtusAPI-1.1.1 → ArtusAPI-1.3}/ArtusAPI/firmware_update/__init__.py +0 -0
  31. {ArtusAPI-1.1.1 → ArtusAPI-1.3}/ArtusAPI/robot/__init__.py +0 -0
  32. {ArtusAPI-1.1.1 → ArtusAPI-1.3}/ArtusAPI/robot/artus_lite/artus_lite_left.py +0 -0
  33. {ArtusAPI-1.1.1 → ArtusAPI-1.3}/ArtusAPI/robot/artus_lite/artus_lite_right.py +0 -0
  34. {ArtusAPI-1.1.1 → ArtusAPI-1.3}/ArtusAPI.egg-info/dependency_links.txt +0 -0
  35. {ArtusAPI-1.1.1 → ArtusAPI-1.3}/ArtusAPI.egg-info/top_level.txt +0 -0
  36. {ArtusAPI-1.1.1 → ArtusAPI-1.3}/setup.cfg +0 -0
@@ -0,0 +1 @@
1
+ from .artus_api import ArtusAPI, main_flash
@@ -1,4 +1,14 @@
1
+ """
2
+ Sarcomere Dynamics Software License Notice
3
+ ------------------------------------------
4
+ This software is developed by Sarcomere Dynamics Inc. for use with the ARTUS family of robotic products,
5
+ including ARTUS Lite, ARTUS+, ARTUS Dex, and Hyperion.
1
6
 
7
+ Copyright (c) 2023–2025, Sarcomere Dynamics Inc. All rights reserved.
8
+
9
+ Licensed under the Sarcomere Dynamics Software License.
10
+ See the LICENSE file in the repository for full details.
11
+ """
2
12
  import sys
3
13
  import logging
4
14
  from pathlib import Path
@@ -27,15 +37,17 @@ class ArtusAPI:
27
37
  robot_type='artus_lite',
28
38
  hand_type ='left',
29
39
  stream = False,
30
- communication_frequency = 200, # hz
40
+ communication_frequency = 50, # hz
31
41
  logger = None,
32
42
  reset_on_start = 0,
33
43
  baudrate = 921600,
34
44
  awake = False
35
45
  ):
36
46
  """
37
- ArtusAPI class controls the communication and control of between a system and an Artus Hand by Sarcomere Dynamics Inc.
47
+ ArtusAPI class controls the communication and control of between a system and an Artus Hand by Sarcomere Dynamics Inc. This file contains the high-level calls that
48
+ are used to control the hand. The low-level calls are separated by robot, command and communication classes.
38
49
  :communication_method: communication method that is supported on the Artus Hand, see Robot folder for supported methods. Default is UART over USBC
50
+ - UART (USBC or RS485), CAN
39
51
  :communication_channel_identifier: channel identifier for the communication method. Usually a COM Port
40
52
  :robot_type: name of the series of robot hand. See Robot folder for list of robots
41
53
  :hand_type: left or right
@@ -43,12 +55,12 @@ class ArtusAPI:
43
55
  :communication_frequency: maximum frequency to stream data to the device and feedback data from the device
44
56
  :logger: python logger settings to inherit
45
57
  :reset_on_start: If hand is powered off in a non-opened state, or software is stopped in a non-opened state, this value should be set to `1` to reduce risk of jamming. May require a calibration.
46
- :baudrate: Required for difference between serial over USBC (921600) and serial over RS485 (115200)
58
+ :baudrate: Required for difference between serial over USBC (921600) and serial over RS485 (115200) when connected to a UR arm
47
59
  :awake: False by default - if the hand is already in a ready state (LED is green) when starting or restarting a control script, set awake to `True` to bypass resending the `wake_up` function. Sending the `wake_up` function when the hand IS NOT in an open state will cause it to lose calibration
48
60
  """
49
61
 
50
62
  self._communication_handler = Communication(communication_method=communication_method,
51
- communication_channel_identifier=communication_channel_identifier,baudrate=baudrate)
63
+ communication_channel_identifier=communication_channel_identifier,baudrate=baudrate,robot_type=robot_type)
52
64
  self._command_handler = Commands(reset_on_start=reset_on_start)
53
65
  self._robot_handler = Robot(robot_type = robot_type,
54
66
  hand_type = hand_type)
@@ -71,7 +83,7 @@ class ArtusAPI:
71
83
  # communication setup
72
84
  def connect(self):
73
85
  """
74
- Open a connection to the Artus Hand
86
+ Open a connection to the Artus Hand and send a wake command to initiate communication
75
87
  """
76
88
  self._communication_handler.open_connection()
77
89
 
@@ -79,7 +91,6 @@ class ArtusAPI:
79
91
  # send wake command with it
80
92
  if not self.awake:
81
93
  self.wake_up()
82
- self.awake = True
83
94
  return
84
95
 
85
96
  def disconnect(self):
@@ -91,7 +102,7 @@ class ArtusAPI:
91
102
  # robot states
92
103
  def wake_up(self):
93
104
  """
94
- Wake-up the Artus Hand
105
+ Wake-up the Artus Hand by sending an initialization command to the hand
95
106
  """
96
107
  print(f"communication period = {self._communication_period_ms} ms")
97
108
  robot_wake_up_command = self._command_handler.get_robot_start_command(self.stream,int(self._communication_period_ms)) # to ms for masterboard
@@ -102,25 +113,38 @@ class ArtusAPI:
102
113
  self.logger.info(f'Finished calibration')
103
114
  else:
104
115
  self.logger.warning(f'Error in calibration')
116
+ self.awake = True
105
117
 
106
118
  def sleep(self):
107
119
  """
108
- Sleep the Artus Hand
120
+ Put the Artus Hand to sleep by sending a sleep command to the hand which
121
+ initiates a shutdown sequence. This command will tell the hand to save it's current
122
+ positions to non-volatile memory and shut down the motors. The LED will turn yellow and
123
+ now be able to be powered off.
109
124
  """
110
125
  robot_sleep_command = self._command_handler.get_sleep_command()
111
126
  return self._communication_handler.send_data(robot_sleep_command)
112
- def calibrate(self):
127
+
128
+ def calibrate(self,joint=0,calibration_type=0):
113
129
  """
114
130
  Calibrate the Artus Hand
131
+
132
+ Parameters:
133
+ joint (int): Joint to calibrate. 0 for all joints, 1-16 for specific joints mapping to joint map
134
+ calibration_type (int): Type of calibration.
135
+ 0 for a soft reset (i.e. fingers will go to open endstop)
136
+ 1 for a hard reset, finding both open and close endstops
115
137
  """
116
138
  if not self.awake:
117
139
  self.logger.warning(f'Hand not ready, send `wake_up` command')
118
140
  return
119
141
  robot_calibrate_command = self._command_handler.get_calibration_command()
142
+ robot_calibrate_command[1] = joint
143
+ robot_calibrate_command[2] = calibration_type
120
144
  self._communication_handler.send_data(robot_calibrate_command)
121
145
 
122
146
  # wait for data back
123
- if self._communication_handler.wait_for_ack():
147
+ if self._communication_handler.wait_for_ack(visual=True):
124
148
  self.logger.info(f'Finished calibration')
125
149
  else:
126
150
  self.logger.warning(f'Error in calibration')
@@ -130,7 +154,9 @@ class ArtusAPI:
130
154
  def set_joint_angles(self, joint_angles:dict):
131
155
  """
132
156
  Set joint angle targets and speed values to the Artus Hand
133
- :joint_angles: dictionary of input angles and input speeds
157
+
158
+ Parameters:
159
+ :joint_angles: dictionary of input angles and input speeds. See the grasps in the hand_data folder for accepted structure
134
160
  """
135
161
  if not self.awake:
136
162
  self.logger.warning(f'Hand not ready, send `wake_up` command')
@@ -142,9 +168,26 @@ class ArtusAPI:
142
168
  return False
143
169
  return self._communication_handler.send_data(robot_set_joint_angles_command)
144
170
 
171
+ def set_zero_manual_calibration(self):
172
+ """
173
+ Set the zero position of the joints used in manual calibration
174
+ This is important to have the fingers look centered in an open/neutral position as we are working
175
+ on the calibration process
176
+
177
+ The hand will need to be power cycled after this function is called to take effect
178
+ """
179
+ if not self.awake:
180
+ self.logger.warning(f'Hand not ready, send `wake_up` command')
181
+ return
182
+ robot_set_zero_command = self._command_handler.get_set_zero_command()
183
+ self._communication_handler.send_data(robot_set_zero_command)
184
+
185
+ time.sleep(1)
186
+
187
+
145
188
  def set_home_position(self):
146
189
  """
147
- sends the joints to home positions (0) which opens the Artus Hand
190
+ sends the joints to home positions (0) which opens all the joints of the Artus Hand
148
191
  """
149
192
  if not self.awake:
150
193
  self.logger.warning(f'Hand not ready, send `wake_up` command')
@@ -159,7 +202,15 @@ class ArtusAPI:
159
202
 
160
203
  def _check_communication_frequency(self,last_command_time):
161
204
  """
162
- check if the communication frequency is too high
205
+ checks if the time between the last command and the current command is less than the communication period
206
+ Necessary so that the messages stay in sync
207
+
208
+ Parameters:
209
+ :last_command_time: time of the last command
210
+
211
+ Returns:
212
+ :True if the time between the last command and the current command is greater than the communication period
213
+ :False if the time between the last command and the current command is less than the communication period
163
214
  """
164
215
  current_time = time.perf_counter()
165
216
  if current_time - last_command_time < self._communication_period:
@@ -172,6 +223,9 @@ class ArtusAPI:
172
223
  def _receive_feedback(self):
173
224
  """
174
225
  Send a request for feedback data and receive feedback data
226
+
227
+ Returns:
228
+ :feedback_command: feedback data list from the hand
175
229
  """
176
230
  if not self.awake:
177
231
  self.logger.warning(f'Hand not ready, send `wake_up` command')
@@ -186,6 +240,13 @@ class ArtusAPI:
186
240
  def get_joint_angles(self):
187
241
  """
188
242
  Populate feedback fields in self._robot_handler.hand_joints dict
243
+
244
+ Returns:
245
+ :tuple: (ack, angles, velocities, temperatures)
246
+ ack: acknowledgement from the hand
247
+ angles: list of joint angles
248
+ velocities: list of joint velocities
249
+ temperatures: list of joint temperatures
189
250
  """
190
251
  if not self.awake:
191
252
  self.logger.warning(f'Hand not ready, send `wake_up` command')
@@ -193,13 +254,33 @@ class ArtusAPI:
193
254
 
194
255
  feedback_command = self._receive_feedback()
195
256
  joint_angles = self._robot_handler.get_joint_angles(feedback_command)
196
- # print(joint_angles)
197
- return joint_angles
257
+ if joint_angles is None:
258
+ return None
259
+
260
+ angles = joint_angles[1][0:16]
261
+
262
+ if self._robot_handler.robot_type == 'artus_lite':
263
+ # separate joint angles into 3 lists
264
+ velocities = joint_angles[1][16:32]
265
+ temperatures = joint_angles[1][32:48]
266
+ # print(joint_angles)
267
+ return joint_angles[0],angles,velocities,temperatures
268
+
269
+ elif self._robot_handler.robot_type == 'artus_lite_plus':
270
+ # separate into lists and concat decimals
271
+ # angles = joint_angles[1][0:16]
272
+ forces = [round(force, 4) for force in joint_angles[1][16:]]
273
+ return joint_angles[0],angles,forces
198
274
 
199
275
  # robot feedback stream
200
276
  def get_streamed_joint_angles(self):
201
277
  """
202
- Populate feedback fields in self._robot_handler.hand_joints dict
278
+ Populate feedback fields in self._robot_handler.hand_joints dict without sending a request for feedback data
279
+ This is used for real-time streaming of data for the Artus Hand
280
+ Returns:
281
+ :tuple: (ack, feedback list)
282
+ ack: acknowledgement from the hand
283
+ feedback list: list of joint angles, velocities, and temperatures
203
284
  """
204
285
  if not self.awake:
205
286
  self.logger.warning(f'Hand not ready, send `wake_up` command')
@@ -217,7 +298,15 @@ class ArtusAPI:
217
298
 
218
299
  def update_firmware(self,upload_flag='y',file_location=None,drivers_to_flash=0):
219
300
  """
220
- send firmware update to the actuators
301
+ send a firmware update to the actuators
302
+
303
+ Parameters:
304
+ :upload_flag: whether to upload a new firmware file or not. Default is 'y'
305
+ :file_location: location of the firmware file. Default is None
306
+ :drivers_to_flash: which drivers to flash. Default is 0 (all motor drivers)
307
+ 0 - all motor drivers
308
+ 1-8 - specific motor driver
309
+ 9 - peripheral controller
221
310
  """
222
311
  file_path = None
223
312
  fw_size = 0
@@ -235,7 +324,8 @@ class ArtusAPI:
235
324
  self._firmware_updater.file_location = 'not empty'
236
325
  upload = False
237
326
  else:
238
- if file_location is None: file_location = input('Please enter binfile absolute path: ')
327
+ if file_location is None:
328
+ file_location = input('Please enter binfile absolute path: ')
239
329
  self._firmware_updater.file_location = file_location
240
330
 
241
331
  fw_size = self._firmware_updater.get_bin_file_info()
@@ -244,22 +334,44 @@ class ArtusAPI:
244
334
  if drivers_to_flash == None:
245
335
  drivers_to_flash = int(input(f'Which drivers would you like to flash? \n0: All Actuators \n1-8 Specific Actuator \n9: Peripheral Controller \nEnter: '))
246
336
 
247
- firmware_command = self._command_handler.get_firmware_command(fw_size,upload,drivers_to_flash)
248
- self._communication_handler.send_data(firmware_command)
249
- if upload:
250
- self._firmware_updater.update_firmware(fw_size)
251
-
252
- print(f'File size = {fw_size}')
253
- print(f'flashing...')
254
- self._communication_handler.wait_for_ack()
337
+ if drivers_to_flash == 0:
338
+
339
+ for i in range(1,9):
340
+ print(f'Flashing driver {i}')
341
+ time.sleep(1)
342
+ self.update_firmware_single_driver(i,fw_size,upload)
343
+ if upload:
344
+ self._firmware_updater.update_firmware(fw_size)
345
+ upload = False
346
+
347
+ if not self._communication_handler.wait_for_ack(25,True):
348
+ print(f'Error flashing driver {i}')
349
+ return
350
+ else:
351
+ self.update_firmware_single_driver(drivers_to_flash,fw_size,upload)
352
+ if upload:
353
+ self._firmware_updater.update_firmware(fw_size)
354
+
355
+ print(f'Flashing driver {drivers_to_flash}')
356
+ self._communication_handler.wait_for_ack(25,True)
357
+
255
358
  print(f'Power Cycle the device to take effect')
256
359
 
257
-
360
+ def update_firmware_single_driver(self,actuator_number,fw_size,upload):
361
+ """
362
+ update firmware for a single driver
258
363
 
364
+ Parameters:
365
+ :actuator_number: which actuator to update
366
+ :fw_size: size of the firmware file
367
+ :upload: whether to upload a new firmware file or not
368
+ """
369
+ self._communication_handler.send_data(self._command_handler.get_firmware_command(fw_size,upload,actuator_number))
259
370
 
260
371
  def request_joint_and_motor(self):
261
372
  """
262
- request joint and motor from user
373
+ user facing request for joint and motor used in reset and hard close functions
374
+ :return: joint and motor number
263
375
  """
264
376
  j,m = None,None
265
377
  while True:
@@ -279,7 +391,11 @@ class ArtusAPI:
279
391
 
280
392
  def reset(self,j=None,m=None):
281
393
  """
282
- Reset a joint back to it's open state, used if finger is "jammed" in close state
394
+ Pulse the motor open, used if finger is "jammed" in close state
395
+
396
+ Parameters:
397
+ :j: joint number to reset
398
+ :m: motor number to reset
283
399
  """
284
400
  if not self.awake:
285
401
  self.logger.warning(f'Hand not ready, send `wake_up` command')
@@ -292,7 +408,11 @@ class ArtusAPI:
292
408
 
293
409
  def hard_close(self,j=None,m=None):
294
410
  """
295
- drive a joint partially closed - used if finger is "jammed" in open state
411
+ Pulse the motor open - used if finger is "jammed" in open state
412
+
413
+ Parameters:
414
+ :j: joint number to reset
415
+ :m: motor number to reset
296
416
  """
297
417
  if not self.awake:
298
418
  self.logger.warning(f'Hand not ready, send `wake_up` command')
@@ -305,7 +425,9 @@ class ArtusAPI:
305
425
 
306
426
  def update_param(self):
307
427
  """
308
- Parameter update, used to change the communication method
428
+ Parameter update, used to change the communication method which must be within the available options.
429
+ Hand will require a power cycle to take effect
430
+ :return: None
309
431
  """
310
432
  com = None
311
433
  while com not in ['UART','CAN','RS485']:
@@ -328,7 +450,10 @@ class ArtusAPI:
328
450
  def save_grasp_onhand(self,index=1):
329
451
  """
330
452
  function to save a grasp on the Artus Hand in non-volatile memory to be called.
331
- Defeault index is 1, value can be 1-6
453
+ Uses the last set joint angles and velocities to save the grasp that are in the robot.hand_joints dict
454
+
455
+ Parameters:
456
+ Default index is 1, value can be 1-6
332
457
  """
333
458
  command = [0]*32
334
459
  for joint,data in self._robot_handler.robot.hand_joints.items():
@@ -373,6 +498,7 @@ class ArtusAPI:
373
498
  def wipe_sd(self):
374
499
  """
375
500
  wipe sd card and reset with factory default settings
501
+ Requires a power cycle to take effect
376
502
  """
377
503
  self._communication_handler.send_data(self._command_handler.get_wipe_sd_command())
378
504
  feedback = None
@@ -389,5 +515,146 @@ def test_artus_api():
389
515
  time.sleep(2)
390
516
  artus_api.disconnect()
391
517
 
518
+ # script entry points
519
+
520
+ def main_flash():
521
+ # import specific to the cli entry point
522
+ import argparse
523
+ import requests
524
+ import os
525
+ import json
526
+ import base64
527
+ import esptool
528
+
529
+ bin_paths = {
530
+ "actuator_64": "https://gist.githubusercontent.com/SDRyanLee/ad8bbe17164c74e6417d1e2d4d0843d2/raw/actuator_64.txt",
531
+ "peripheral_64": "https://gist.githubusercontent.com/SDRyanLee/ad8bbe17164c74e6417d1e2d4d0843d2/raw/peripheral_64.txt",
532
+ "peripheral_plus_64": "https://gist.githubusercontent.com/SDRyanLee/ad8bbe17164c74e6417d1e2d4d0843d2/raw/peripheral_plus_64.txt",
533
+ "master_64": "https://gist.githubusercontent.com/SDRyanLee/ad8bbe17164c74e6417d1e2d4d0843d2/raw/master_64.txt",
534
+ "master_plus_64": "https://gist.githubusercontent.com/SDRyanLee/ad8bbe17164c74e6417d1e2d4d0843d2/raw/master_plus_64.txt",
535
+ "master_bootapp0_64": "https://gist.githubusercontent.com/SDRyanLee/ad8bbe17164c74e6417d1e2d4d0843d2/raw/master_bootapp0_64.txt",
536
+ "master_partitions_64": "https://gist.githubusercontent.com/SDRyanLee/ad8bbe17164c74e6417d1e2d4d0843d2/raw/master_partitions_64.txt",
537
+ "master_bootloader_64": "https://gist.githubusercontent.com/SDRyanLee/ad8bbe17164c74e6417d1e2d4d0843d2/raw/master_bootloader_64.txt"
538
+ }
539
+
540
+ parser = argparse.ArgumentParser(
541
+ description="Artus API CLI Tool"
542
+ )
543
+
544
+ # add required arguments
545
+ parser.add_argument('-p','--port',required=True,help="required com port (COMx) or (/dev/ttyUSBx)")
546
+ parser.add_argument('-r','--robot',default='artus_lite',help="Robot type",choices=['artus_lite','artus_lite_plus'])
547
+ parser.add_argument('-s','--side',default='right',choices=['left','right'],help='specify hand side, left or right')
548
+
549
+ args = parser.parse_args()
550
+
551
+ type_flash = None
552
+ driver_to_flash = None
553
+ bootapp_path = None
554
+ partitions_path = None
555
+ bootloader_path = None
556
+ file_location = None
557
+
558
+ # get type of flash
559
+ while type_flash not in ['actuator','peripheral','master']:
560
+ type_flash = input('Enter subsystem to flash (actuator, peripheral, master): ')
561
+
562
+ if type_flash == 'actuator':
563
+ file_location = bin_paths['actuator_64']
564
+ driver_to_flash = 0
565
+ elif type_flash == 'peripheral':
566
+ if args.robot == 'artus_lite':
567
+ file_location = bin_paths['peripheral_64']
568
+ elif args.robot == 'artus_lite_plus':
569
+ file_location = bin_paths['peripheral_plus_64']
570
+ driver_to_flash = 9
571
+ elif type_flash == 'master':
572
+ if args.robot == 'artus_lite':
573
+ file_location = bin_paths['master_64']
574
+ elif args.robot == 'artus_lite_plus':
575
+ file_location = bin_paths['master_plus_64']
576
+
577
+ bootapp_path = bin_paths['master_bootapp0_64']
578
+ partitions_path = bin_paths['master_partitions_64']
579
+ bootloader_path = bin_paths['master_bootloader_64']
580
+
581
+ # write files
582
+ # Download and decode base64 firmware file
583
+ response = requests.get(file_location)
584
+ decoded_firmware = base64.b64decode(response.text)
585
+
586
+ # Write decoded firmware to flash.bin
587
+ with open('flash.bin', 'wb') as f:
588
+ f.write(decoded_firmware)
589
+
590
+ # For master firmware, also download and decode bootloader files
591
+ if type_flash == 'master':
592
+ # Download and decode bootapp
593
+ response = requests.get(bootapp_path)
594
+ decoded_bootapp = base64.b64decode(response.text)
595
+ with open('bootapp0.bin', 'wb') as f:
596
+ f.write(decoded_bootapp)
597
+
598
+ # Download and decode partitions
599
+ response = requests.get(partitions_path)
600
+ decoded_partitions = base64.b64decode(response.text)
601
+ with open('partitions.bin', 'wb') as f:
602
+ f.write(decoded_partitions)
603
+
604
+ # Download and decode bootloader
605
+ response = requests.get(bootloader_path)
606
+ decoded_bootloader = base64.b64decode(response.text)
607
+ with open('bootloader.bin', 'wb') as f:
608
+ f.write(decoded_bootloader)
609
+
610
+
611
+ # flash through api
612
+ if type_flash != 'master':
613
+ myrobot = ArtusAPI(robot_type=args.robot, hand_type=args.side, communication_channel_identifier=args.port)
614
+ myrobot.connect()
615
+ print('Connected to robot')
616
+
617
+ file_location = 'flash.bin'
618
+ myrobot.update_firmware(upload_flag='y',file_location=file_location,drivers_to_flash=driver_to_flash)
619
+
620
+ myrobot.disconnect()
621
+ print('Disconnected from robot')
622
+
623
+ else:
624
+
625
+ # Build esptool command arguments
626
+ cmd_args = [
627
+ '--chip', 'esp32s3',
628
+ '--port', args.port,
629
+ '--baud', '921600',
630
+ '--before', 'default_reset',
631
+ '--after', 'hard_reset',
632
+ 'write_flash',
633
+ '-z',
634
+ '--flash_mode', 'keep',
635
+ '--flash_freq', 'keep',
636
+ '--flash_size', 'keep',
637
+ '0x0', 'bootloader.bin',
638
+ '0x8000', 'partitions.bin',
639
+ '0xe000', 'bootapp0.bin',
640
+ '0x10000', 'flash.bin'
641
+ ]
642
+
643
+ # Run esptool flash command
644
+ esptool.main(cmd_args)
645
+
646
+ # Clean up temporary bootloader files
647
+ os.remove('bootloader.bin')
648
+ os.remove('partitions.bin')
649
+ os.remove('bootapp0.bin')
650
+
651
+ # delete bin file
652
+ time.sleep(1)
653
+ os.remove('flash.bin')
654
+ print('Flash complete')
655
+
656
+ print('Done')
657
+
658
+
392
659
  if __name__ == "__main__":
393
660
  test_artus_api()
@@ -1,3 +1,15 @@
1
+ """
2
+ Sarcomere Dynamics Software License Notice
3
+ ------------------------------------------
4
+ This software is developed by Sarcomere Dynamics Inc. for use with the ARTUS family of robotic products,
5
+ including ARTUS Lite, ARTUS+, ARTUS Dex, and Hyperion.
6
+
7
+ Copyright (c) 2023–2025, Sarcomere Dynamics Inc. All rights reserved.
8
+
9
+ Licensed under the Sarcomere Dynamics Software License.
10
+ See the LICENSE file in the repository for full details.
11
+ """
12
+
1
13
  import os
2
14
  import json
3
15
  import time
@@ -14,6 +26,7 @@ class Commands:
14
26
  target_command = 0x66,
15
27
  get_feedback_command = 0x68,
16
28
  update_param_command = 0x44,
29
+ set_zero_command = 0x15,
17
30
 
18
31
  save_grasp_onboard_command = 0xC8,
19
32
  return_grasps_command = 0xD2,
@@ -34,7 +47,8 @@ class Commands:
34
47
  'return_grasps_command': return_grasps_command,
35
48
  'execute_grasp_command': execute_grasp_command,
36
49
  'update_param_command' : update_param_command,
37
- 'wipe_sd_command' : wipe_sd_command
50
+ 'wipe_sd_command' : wipe_sd_command,
51
+ 'set_zero_command' : set_zero_command
38
52
  }
39
53
  self.reset_on_start = reset_on_start
40
54
 
@@ -68,6 +82,11 @@ class Commands:
68
82
  command_list.insert(0,self.commands['target_command'])
69
83
 
70
84
  return command_list
85
+
86
+ def get_set_zero_command(self):
87
+ command_list = [0]*32
88
+ command_list.insert(0,self.commands['set_zero_command'])
89
+ return command_list
71
90
 
72
91
  def get_firmware_command(self,fw_size,upload,drivers):
73
92
  command_list = [0]*32
@@ -83,6 +102,7 @@ class Commands:
83
102
  def get_calibration_command(self):
84
103
  command_list = [0]*32
85
104
  command_list.insert(0,self.commands['calibrate_command'])
105
+
86
106
  return command_list
87
107
 
88
108
  def get_sleep_command(self):
@@ -1,6 +1,20 @@
1
+ """
2
+ Sarcomere Dynamics Software License Notice
3
+ ------------------------------------------
4
+ This software is developed by Sarcomere Dynamics Inc. for use with the ARTUS family of robotic products,
5
+ including ARTUS Lite, ARTUS+, ARTUS Dex, and Hyperion.
6
+
7
+ Copyright (c) 2023–2025, Sarcomere Dynamics Inc. All rights reserved.
8
+
9
+ Licensed under the Sarcomere Dynamics Software License.
10
+ See the LICENSE file in the repository for full details.
11
+ """
12
+
1
13
  import serial
2
14
  import logging
3
15
  import time
16
+ from tqdm import tqdm
17
+
4
18
 
5
19
  class UART:
6
20
  def __init__(self,
@@ -35,8 +49,11 @@ class UART:
35
49
  self.esp32.flush()
36
50
  msg_bytes = self.esp32.read_all()
37
51
  except Exception as e:
38
- self.logger.error(f'Error opening port {self.port}')
39
52
  self.logger.error(e)
53
+ self.logger.error(f'Error opening port {self.port} ......... QUITTING ........')
54
+ for i in range(25):
55
+ time.sleep(0.1)
56
+ quit()
40
57
 
41
58
  def send(self, data:bytearray):
42
59
  # print(data)
@@ -52,7 +69,7 @@ class UART:
52
69
  self.logger.error(f'Unable to send command through {self.port}')
53
70
  self.logger.error(e)
54
71
 
55
- def receive(self):
72
+ def receive(self,size=65):
56
73
 
57
74
  # required delay
58
75
  # t = time.perf_counter()
@@ -61,14 +78,14 @@ class UART:
61
78
  try:
62
79
  x = time.perf_counter()
63
80
  # # print(f'time start: {x}')
64
- while self.esp32.in_waiting < 65:
81
+ while self.esp32.in_waiting < size:
65
82
  if time.perf_counter() - x > 0.001:
66
83
  break
67
84
  # print(f'elapsed time: {time.perf_counter() - x}')
68
85
  # time.sleep(0.03)
69
86
  # check data
70
- if self.esp32.in_waiting >= 65: # get data if greater or equal to 65
71
- msg_bytes = self.esp32.read(65)
87
+ if self.esp32.in_waiting >= size: # get data if greater or equal to 65
88
+ msg_bytes = self.esp32.read(size)
72
89
  # print(msg_bytes)
73
90
  return msg_bytes
74
91
  elif self.esp32.in_waiting > 0:
@@ -1,3 +1,15 @@
1
+ """
2
+ Sarcomere Dynamics Software License Notice
3
+ ------------------------------------------
4
+ This software is developed by Sarcomere Dynamics Inc. for use with the ARTUS family of robotic products,
5
+ including ARTUS Lite, ARTUS+, ARTUS Dex, and Hyperion.
6
+
7
+ Copyright (c) 2023–2025, Sarcomere Dynamics Inc. All rights reserved.
8
+
9
+ Licensed under the Sarcomere Dynamics Software License.
10
+ See the LICENSE file in the repository for full details.
11
+ """
12
+
1
13
  import socket
2
14
  import time
3
15
  import os
@@ -174,11 +186,11 @@ class WiFiServer:
174
186
 
175
187
  return
176
188
 
177
- def receive(self):
189
+ def receive(self,size=65):
178
190
  try:
179
- byte_msg = self.conn.recv(65) # receive bytes
191
+ byte_msg = self.conn.recv(size) # receive bytes
180
192
 
181
- if len(byte_msg) == 65: # receive the first 65 bytes
193
+ if len(byte_msg) == size: # receive the first 65 bytes
182
194
  return byte_msg
183
195
 
184
196
  else: