ArtusAPI 1.0.0__tar.gz → 1.1.0__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 (28) hide show
  1. {ArtusAPI-1.0.0 → ArtusAPI-1.1.0}/ArtusAPI/artus_api.py +181 -28
  2. {ArtusAPI-1.0.0 → ArtusAPI-1.1.0}/ArtusAPI/commands/commands.py +70 -1
  3. {ArtusAPI-1.0.0 → ArtusAPI-1.1.0}/ArtusAPI/communication/UART/uart.py +3 -1
  4. {ArtusAPI-1.0.0 → ArtusAPI-1.1.0}/ArtusAPI/communication/communication.py +5 -2
  5. {ArtusAPI-1.0.0 → ArtusAPI-1.1.0}/ArtusAPI/firmware_update/firmware_updater.py +3 -3
  6. ArtusAPI-1.1.0/ArtusAPI/firmware_update/run_full_firmware_update.py +105 -0
  7. {ArtusAPI-1.0.0 → ArtusAPI-1.1.0}/ArtusAPI.egg-info/PKG-INFO +1 -1
  8. {ArtusAPI-1.0.0 → ArtusAPI-1.1.0}/ArtusAPI.egg-info/SOURCES.txt +2 -2
  9. {ArtusAPI-1.0.0 → ArtusAPI-1.1.0}/PKG-INFO +1 -1
  10. {ArtusAPI-1.0.0 → ArtusAPI-1.1.0}/README.md +98 -26
  11. {ArtusAPI-1.0.0 → ArtusAPI-1.1.0}/setup.py +2 -2
  12. ArtusAPI-1.0.0/test/test.py +0 -0
  13. {ArtusAPI-1.0.0 → ArtusAPI-1.1.0}/ArtusAPI/__init__.py +0 -0
  14. {ArtusAPI-1.0.0 → ArtusAPI-1.1.0}/ArtusAPI/commands/__init__.py +0 -0
  15. {ArtusAPI-1.0.0 → ArtusAPI-1.1.0}/ArtusAPI/communication/UART/__init__.py +0 -0
  16. {ArtusAPI-1.0.0 → ArtusAPI-1.1.0}/ArtusAPI/communication/WiFi/__init__.py +0 -0
  17. {ArtusAPI-1.0.0 → ArtusAPI-1.1.0}/ArtusAPI/communication/WiFi/wifi_server.py +0 -0
  18. {ArtusAPI-1.0.0 → ArtusAPI-1.1.0}/ArtusAPI/communication/__init__.py +0 -0
  19. {ArtusAPI-1.0.0 → ArtusAPI-1.1.0}/ArtusAPI/firmware_update/__init__.py +0 -0
  20. {ArtusAPI-1.0.0 → ArtusAPI-1.1.0}/ArtusAPI/robot/__init__.py +0 -0
  21. {ArtusAPI-1.0.0 → ArtusAPI-1.1.0}/ArtusAPI/robot/artus_lite/__init__.py +0 -0
  22. {ArtusAPI-1.0.0 → ArtusAPI-1.1.0}/ArtusAPI/robot/artus_lite/artus_lite.py +0 -0
  23. {ArtusAPI-1.0.0 → ArtusAPI-1.1.0}/ArtusAPI/robot/artus_lite/artus_lite_left.py +0 -0
  24. {ArtusAPI-1.0.0 → ArtusAPI-1.1.0}/ArtusAPI/robot/artus_lite/artus_lite_right.py +0 -0
  25. {ArtusAPI-1.0.0 → ArtusAPI-1.1.0}/ArtusAPI/robot/robot.py +0 -0
  26. {ArtusAPI-1.0.0 → ArtusAPI-1.1.0}/ArtusAPI.egg-info/dependency_links.txt +0 -0
  27. {ArtusAPI-1.0.0 → ArtusAPI-1.1.0}/ArtusAPI.egg-info/top_level.txt +0 -0
  28. {ArtusAPI-1.0.0 → ArtusAPI-1.1.0}/setup.cfg +0 -0
@@ -27,20 +27,24 @@ class ArtusAPI:
27
27
  robot_type='artus_lite',
28
28
  hand_type ='left',
29
29
  stream = False,
30
- communication_frequency = 400, # hz
30
+ communication_frequency = 200, # hz
31
31
  logger = None,
32
32
  reset_on_start = 0,
33
- baudrate = 921600
33
+ baudrate = 921600,
34
+ awake = False
34
35
  ):
35
36
  """
36
37
  ArtusAPI class controls the communication and control of between a system and an Artus Hand by Sarcomere Dynamics Inc.
37
- :communication_method: communication method that is supported on the Artus Hand
38
- :communication_channel_identifier: channel identifier for the communication method
39
- :robot_type: name of the series of robot hand
38
+ :communication_method: communication method that is supported on the Artus Hand, see Robot folder for supported methods. Default is UART over USBC
39
+ :communication_channel_identifier: channel identifier for the communication method. Usually a COM Port
40
+ :robot_type: name of the series of robot hand. See Robot folder for list of robots
40
41
  :hand_type: left or right
41
- :stream: streaming feedback data
42
- :communication_frequency: maximum frequency to stream data
42
+ :stream: Whether feedback data should be streamed (True) or require polling (False)
43
+ :communication_frequency: maximum frequency to stream data to the device and feedback data from the device
43
44
  :logger: python logger settings to inherit
45
+ :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)
47
+ :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
44
48
  """
45
49
 
46
50
  self._communication_handler = Communication(communication_method=communication_method,
@@ -53,6 +57,7 @@ class ArtusAPI:
53
57
  self._communication_frequency = 1 / communication_frequency
54
58
  self._communication_frequency_us = int(self._communication_frequency * 1000000)
55
59
  self.stream = stream
60
+ self.awake = awake
56
61
 
57
62
  if not logger:
58
63
  self.logger = logging.getLogger(__name__)
@@ -64,16 +69,21 @@ class ArtusAPI:
64
69
  """
65
70
  Open a connection to the Artus Hand
66
71
  """
67
- return self._communication_handler.open_connection()
72
+ self._communication_handler.open_connection()
73
+
74
+ time.sleep(1)
75
+ # send wake command with it
76
+ if not self.awake:
77
+ self.wake_up()
78
+ self.awake = True
79
+ return
80
+
68
81
  def disconnect(self):
69
82
  """
70
83
  Close a connection to the Artus Hand
71
84
  """
72
85
  return self._communication_handler.close_connection()
73
86
 
74
-
75
-
76
-
77
87
  # robot states
78
88
  def wake_up(self):
79
89
  """
@@ -87,7 +97,7 @@ class ArtusAPI:
87
97
  if self._communication_handler.wait_for_ack():
88
98
  self.logger.info(f'Finished calibration')
89
99
  else:
90
- self.logger.warn(f'Error in calibration')
100
+ self.logger.warning(f'Error in calibration')
91
101
 
92
102
  def sleep(self):
93
103
  """
@@ -99,6 +109,9 @@ class ArtusAPI:
99
109
  """
100
110
  Calibrate the Artus Hand
101
111
  """
112
+ if not self.awake:
113
+ self.logger.warning(f'Hand not ready, send `wake_up` command')
114
+ return
102
115
  robot_calibrate_command = self._command_handler.get_calibration_command()
103
116
  self._communication_handler.send_data(robot_calibrate_command)
104
117
 
@@ -106,7 +119,7 @@ class ArtusAPI:
106
119
  if self._communication_handler.wait_for_ack():
107
120
  self.logger.info(f'Finished calibration')
108
121
  else:
109
- self.logger.warn(f'Error in calibration')
122
+ self.logger.warning(f'Error in calibration')
110
123
 
111
124
 
112
125
  # robot control
@@ -115,6 +128,9 @@ class ArtusAPI:
115
128
  Set joint angle targets and speed values to the Artus Hand
116
129
  :joint_angles: dictionary of input angles and input speeds
117
130
  """
131
+ if not self.awake:
132
+ self.logger.warning(f'Hand not ready, send `wake_up` command')
133
+ return
118
134
  self._robot_handler.set_joint_angles(joint_angles=joint_angles,name=False)
119
135
  robot_set_joint_angles_command = self._command_handler.get_target_position_command(self._robot_handler.robot.hand_joints)
120
136
  # check communication frequency
@@ -126,6 +142,10 @@ class ArtusAPI:
126
142
  """
127
143
  sends the joints to home positions (0) which opens the Artus Hand
128
144
  """
145
+ if not self.awake:
146
+ self.logger.warning(f'Hand not ready, send `wake_up` command')
147
+ return
148
+
129
149
  self._robot_handler.set_home_position()
130
150
  robot_set_home_position_command = self._command_handler.get_target_position_command(hand_joints=self._robot_handler.robot.hand_joints)
131
151
  # check communication frequency
@@ -146,6 +166,13 @@ class ArtusAPI:
146
166
 
147
167
  # robot feedback
148
168
  def _receive_feedback(self):
169
+ """
170
+ Send a request for feedback data and receive feedback data
171
+ """
172
+ if not self.awake:
173
+ self.logger.warning(f'Hand not ready, send `wake_up` command')
174
+ return
175
+
149
176
  feedback_command = self._command_handler.get_states_command()
150
177
  self._communication_handler.send_data(feedback_command)
151
178
  # test
@@ -156,6 +183,10 @@ class ArtusAPI:
156
183
  """
157
184
  Populate feedback fields in self._robot_handler.hand_joints dict
158
185
  """
186
+ if not self.awake:
187
+ self.logger.warning(f'Hand not ready, send `wake_up` command')
188
+ return
189
+
159
190
  feedback_command = self._receive_feedback()
160
191
  joint_angles = self._robot_handler.get_joint_angles(feedback_command)
161
192
  print(joint_angles)
@@ -166,6 +197,10 @@ class ArtusAPI:
166
197
  """
167
198
  Populate feedback fields in self._robot_handler.hand_joints dict
168
199
  """
200
+ if not self.awake:
201
+ self.logger.warning(f'Hand not ready, send `wake_up` command')
202
+ return
203
+
169
204
  if not self._check_communication_frequency():
170
205
  return False
171
206
  feedback_command = self._communication_handler.receive_data()
@@ -174,14 +209,19 @@ class ArtusAPI:
174
209
  joint_angles = self._robot_handler.get_joint_angles(feedback_command)
175
210
  return joint_angles
176
211
 
177
- def update_firmware(self):
212
+ def update_firmware(self,upload_flag='y',file_location=None,drivers_to_flash=0):
213
+ """
214
+ send firmware update to the actuators
215
+ """
178
216
  file_path = None
179
217
  fw_size = 0
180
218
  # input to upload a new file
181
- upload_flag = input(f'Uploading a new BIN file? (y/n) : ')
219
+ if upload_flag == None:
220
+ upload_flag = input(f'Uploading a new BIN file? (y/n) : ')
182
221
  upload = True
183
-
184
222
 
223
+
224
+ # Create new firmware updater instance
185
225
  self._firmware_updater = FirmwareUpdater(self._communication_handler,
186
226
  self._command_handler)
187
227
 
@@ -189,15 +229,14 @@ class ArtusAPI:
189
229
  self._firmware_updater.file_location = 'not empty'
190
230
  upload = False
191
231
  else:
192
-
193
- self._firmware_updater.file_location = input('Please enter binfile absolute path: ')
232
+ if file_location is None: file_location = input('Please enter binfile absolute path: ')
233
+ self._firmware_updater.file_location = file_location
194
234
 
195
235
  fw_size = self._firmware_updater.get_bin_file_info()
196
236
 
197
237
  # set which drivers to flash should be 1-8
198
- drivers_to_flash = int(input(f'Which drivers would you like to flash? \n0:ALL\nor 1-8\n: '))
199
- if not drivers_to_flash:
200
- drivers_to_flash = 0
238
+ if drivers_to_flash == None:
239
+ drivers_to_flash = int(input(f'Which drivers would you like to flash? \n0: All Actuators \n1-8 Specific Actuator \n9: Peripheral Controller \nEnter: '))
201
240
 
202
241
  firmware_command = self._command_handler.get_firmware_command(fw_size,upload,drivers_to_flash)
203
242
  self._communication_handler.send_data(firmware_command)
@@ -209,18 +248,132 @@ class ArtusAPI:
209
248
  self._communication_handler.wait_for_ack()
210
249
  print(f'Power Cycle the device to take effect')
211
250
 
212
- def reset(self):
213
- j = int(input(f'Enter Joint to reset: '))
214
- m = int(input(f'Enter Motor to reset: '))
251
+
252
+
253
+
254
+ def request_joint_and_motor(self):
255
+ """
256
+ request joint and motor from user
257
+ """
258
+ j,m = None,None
259
+ while True:
260
+ j = int(input(f'Enter Joint to reset: '))
261
+ if 0 <= j <= 15:
262
+ break
263
+ else:
264
+ print(f'Invalid joint number, please try again')
265
+ while True:
266
+ m = int(input(f'Enter Motor to reset: '))
267
+ if 0 <= m <= 2:
268
+ break
269
+ else:
270
+ print(f'Invalid motor number, please try again')
271
+ return j,m
272
+
273
+
274
+ def reset(self,j=None,m=None):
275
+ """
276
+ Reset a joint back to it's open state, used if finger is "jammed" in close state
277
+ """
278
+ if not self.awake:
279
+ self.logger.warning(f'Hand not ready, send `wake_up` command')
280
+ return
281
+ if j is None or m is None:
282
+ j,m = self.request_joint_and_motor()
283
+
215
284
  reset_command = self._command_handler.get_locked_reset_low_command(j,m)
216
285
  self._communication_handler.send_data(reset_command)
217
286
 
218
- def hard_close(self):
219
- j = int(input(f'Enter Joint to reset: '))
220
- m = int(input(f'Enter Motor to reset: '))
287
+ def hard_close(self,j=None,m=None):
288
+ """
289
+ drive a joint partially closed - used if finger is "jammed" in open state
290
+ """
291
+ if not self.awake:
292
+ self.logger.warning(f'Hand not ready, send `wake_up` command')
293
+ return
294
+ if j is None or m is None:
295
+ j,m = self.request_joint_and_motor()
296
+
221
297
  hard_close = self._command_handler.get_hard_close_command(j,m)
222
298
  self._communication_handler.send_data(hard_close)
223
299
 
300
+ def update_param(self):
301
+ """
302
+ Parameter update, used to change the communication method
303
+ """
304
+ com = None
305
+ while com not in ['UART','CAN','RS485']:
306
+ com = input('Enter Communication Protocol you would like to change to (default: UART, CAN, RS485): ')
307
+ if com == 'CAN':
308
+ feed = None
309
+ while feed not in ['P','C','ALL']:
310
+ feed = input('Enter feedback information (P: Positions only, C: Positions and Force, ALL: Position, force and temperature): ')
311
+ else:
312
+ feed = None
313
+ command = self._command_handler.update_param_command(com,feed)
314
+ self._communication_handler.send_data(command)
315
+
316
+ # wait for data back
317
+ if self._communication_handler.wait_for_ack():
318
+ self.logger.info(f'Finished Updating Param')
319
+ else:
320
+ self.logger.warning(f'Error in updating Param')
321
+
322
+ def save_grasp_onhand(self,index=1):
323
+ """
324
+ function to save a grasp on the Artus Hand in non-volatile memory to be called.
325
+ Defeault index is 1, value can be 1-6
326
+ """
327
+ command = [0]*32
328
+ for joint,data in self._robot_handler.robot.hand_joints.items():
329
+ command[data.index] = data.target_angle
330
+ command[data.index+16] = data.velocity
331
+
332
+ self._communication_handler.send_data(self._command_handler.get_save_grasp_command(index,command))
333
+ feedback = None
334
+ while not feedback:
335
+ ack,feedback = self._communication_handler.receive_data()
336
+
337
+ if feedback is not None:
338
+ print(feedback[:33])
339
+
340
+ def get_saved_grasps_onhand(self):
341
+ """
342
+ Function to print saved grasps on the Artus non-volatile memory.
343
+ Prints 6 grasps
344
+ """
345
+ self._communication_handler.send_data(self._command_handler.get_return_grasps_command())
346
+
347
+ for i in range(6):
348
+ feedback = None
349
+ while not feedback:
350
+ ack,feedback = self._communication_handler.receive_data()
351
+
352
+ if feedback is not None:
353
+ print(feedback[:33])
354
+
355
+ def execute_grasp(self,index=1):
356
+ """
357
+ Sends a command to the Artus hand that executes a grasp position from the non-volatile memory grasp array
358
+ """
359
+ self._communication_handler.send_data(self._command_handler.get_execute_grasp_command(index))
360
+ feedback = None
361
+ while not feedback:
362
+ ack,feedback = self._communication_handler.receive_data()
363
+
364
+ if feedback is not None:
365
+ print(feedback[:33])
366
+
367
+ def wipe_sd(self):
368
+ """
369
+ wipe sd card and reset with factory default settings
370
+ """
371
+ self._communication_handler.send_data(self._command_handler.get_wipe_sd_command())
372
+ feedback = None
373
+ while not feedback:
374
+ ack,feedback = self._communication_handler.receive_data()
375
+
376
+
224
377
  def test_artus_api():
225
378
  artus_api = ArtusAPI()
226
379
  artus_api.connect()
@@ -231,4 +384,4 @@ def test_artus_api():
231
384
  artus_api.disconnect()
232
385
 
233
386
  if __name__ == "__main__":
234
- test_artus_api()
387
+ test_artus_api()
@@ -13,10 +13,12 @@ class Commands:
13
13
 
14
14
  target_command = 0x66,
15
15
  get_feedback_command = 0x68,
16
+ update_param_command = 0x44,
16
17
 
17
18
  save_grasp_onboard_command = 0xC8,
18
19
  return_grasps_command = 0xD2,
19
20
  execute_grasp_command = 0xE0,
21
+ wipe_sd_command = 0x46,
20
22
  reset_on_start = 0):
21
23
 
22
24
  self.commands = {
@@ -30,10 +32,14 @@ class Commands:
30
32
  'get_feedback_command': get_feedback_command,
31
33
  'save_grasp_onboard_command': save_grasp_onboard_command,
32
34
  'return_grasps_command': return_grasps_command,
33
- 'execute_grasp_command': execute_grasp_command
35
+ 'execute_grasp_command': execute_grasp_command,
36
+ 'update_param_command' : update_param_command,
37
+ 'wipe_sd_command' : wipe_sd_command
34
38
  }
35
39
  self.reset_on_start = reset_on_start
36
40
 
41
+ self.command_buffer = None
42
+
37
43
  def get_robot_start_command(self,stream:bool,freq:int) -> list:
38
44
  """
39
45
  Creates a message to start the hand
@@ -129,7 +135,70 @@ class Commands:
129
135
  None
130
136
 
131
137
  return command_list
138
+
139
+ def update_param_command(self,communication='UART', feedback=None):
140
+ """
141
+ Communication Options:
142
+ 'UART' - USBC
143
+ 'RS485' - RS485
144
+ 'CAN' - CAN
145
+ Feedback Options (only if CAN):
146
+ 'ALL' - Positions,Currents,Temperatures
147
+ 'PC' - Positions,Currentns
148
+ 'P' - Positions
149
+ """
150
+ command_list = [0]*32
151
+ command_list.insert(0,self.commands['update_param_command'])
152
+
153
+ if communication:
154
+ command_list[1] = 1
155
+ if communication == 'UART':
156
+ command_list[17] = 1
157
+ elif communication == 'CAN':
158
+ command_list[17] = 2
159
+ elif communication == 'RS485':
160
+ command_list[17] = 3
161
+
162
+ if feedback:
163
+ command_list[2] = 1
164
+ if feedback == 'ALL':
165
+ command_list[18] = 2
166
+ elif feedback == 'PC':
167
+ command_list[18] = 1
168
+ elif feedback == 'P':
169
+ command_list[18] = 0
170
+
171
+ return command_list
172
+
173
+ def get_save_grasp_command(self,grasp_index=1, command=None):
174
+ """
175
+ Used to save grasps commands directly to the Artus hand's non-volatile memory.
176
+ @param: grasp_index - 1-6
177
+ @param: command should be a 32B integer list, 16 target positions, 16 velocities
178
+ """
179
+ command_list = [(self.commands['save_grasp_onboard_command'])+grasp_index] + command
180
+ if len(command_list) == 33:
181
+ return command_list
182
+ else:
183
+ return None
184
+
185
+ def get_return_grasps_command(self):
186
+ command_list = [0]*32
187
+ command_list.insert(0,self.commands['return_grasps_command'])
188
+
189
+ return command_list
190
+
191
+ def get_execute_grasp_command(self,index=1):
192
+ command_list = [0]*32
193
+ command_list.insert(0,self.commands['execute_grasp_command']+index)
194
+
195
+ return command_list
196
+
197
+ def get_wipe_sd_command(self):
198
+ command_list = [0]*32
199
+ command_list.insert(0,self.commands['wipe_sd_command'])
132
200
 
201
+ return command_list
133
202
 
134
203
  if __name__ == "__main__":
135
204
  None
@@ -33,6 +33,7 @@ class UART:
33
33
  self.esp32.open()
34
34
  self.logger.info(f"Opening {self.port} @ {self.baudrate} baudrate")
35
35
  self.esp32.flush()
36
+ msg_bytes = self.esp32.read_all()
36
37
  except Exception as e:
37
38
  self.logger.error(f'Error opening port {self.port}')
38
39
  self.logger.error(e)
@@ -41,6 +42,7 @@ class UART:
41
42
  # print(data)
42
43
  try:
43
44
  self.esp32.write(data)
45
+ self.esp32.flush()
44
46
 
45
47
  # required delay
46
48
  t = time.perf_counter()
@@ -70,7 +72,7 @@ class UART:
70
72
  print(msg_bytes)
71
73
  return msg_bytes
72
74
  elif self.esp32.in_waiting > 0: # clear buffer if not correct amount of data
73
- msg_bytes = self.esp32.read_all()
75
+ # msg_bytes = self.esp32.read_all()
74
76
  self.logger.warning(f"Incomplete data received - package size = {(self.esp32.in_waiting)}")
75
77
  return None
76
78
  else: # non blocking
@@ -113,14 +113,15 @@ 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):
116
+ def send_data(self, message:list,no_debug=None):
117
117
  """
118
118
  send message
119
119
  """
120
120
  try:
121
121
  # Test
122
122
  self.logger.info(f'data sent to hand {message}')
123
- print(f'data sent to hand = {message}')
123
+ if not no_debug:
124
+ print(f'data sent to hand = {message}')
124
125
  byte_msg = self._list_to_byte_encode(message)
125
126
  self.communicator.send(byte_msg)
126
127
  return True
@@ -142,6 +143,8 @@ class Communication:
142
143
  # self.logger.warning("No data received")
143
144
  return None,None
144
145
  ack,message_received = self._byte_to_list_decode(byte_msg_recv)
146
+ if ack == 9:
147
+ self.logger.warning("[E] error ack")
145
148
  # print(ack)
146
149
  except Exception as e:
147
150
  self.logger.warning("unable to receive message")
@@ -1,6 +1,8 @@
1
1
  import os
2
2
  import time
3
3
  import logging
4
+ import platform
5
+ import subprocess
4
6
 
5
7
  BYTES_CHUNK = 32
6
8
  UPLOAD_CHUNKS_COMMAND = 0x30
@@ -74,7 +76,7 @@ class FirmwareUpdater:
74
76
  # print(f'{chunk} {len(chunk)}')
75
77
 
76
78
  # send data
77
- self._communication_handler.send_data(chunk)
79
+ self._communication_handler.send_data(chunk,1)
78
80
 
79
81
  # sleep
80
82
  time.sleep(0.008)
@@ -107,7 +109,6 @@ class FirmwareUpdater:
107
109
  while 1:
108
110
  tmp,rc_csum = self._communication_handler.receive_data()
109
111
  if tmp == 2:
110
- # print(f'{tmp} {rc_csum[0]}')
111
112
  if rc_csum[0] == 1:
112
113
  return True
113
114
  else:
@@ -117,7 +118,6 @@ class FirmwareUpdater:
117
118
  self.logger.error(f'firmware flash failed')
118
119
  return False
119
120
  time.sleep(0.001)
120
-
121
121
 
122
122
 
123
123
  def test_firmware_updater():
@@ -0,0 +1,105 @@
1
+ # ------------------------------------------------------------------------------
2
+ # ---------------------------- Import Libraries --------------------------------
3
+ # ------------------------------------------------------------------------------
4
+ import time
5
+ import json
6
+ # Add the desired path to the system path
7
+ import os
8
+ import sys
9
+ PROJECT_ROOT = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
10
+ print("Project Root", PROJECT_ROOT)
11
+ sys.path.append(PROJECT_ROOT)
12
+ # import ArtusAPI
13
+ from ..ArtusAPI.artus_api import ArtusAPI
14
+
15
+ # Determine OS and run appropriate flash script
16
+ import platform
17
+ import subprocess
18
+
19
+ def example():
20
+
21
+ periph = "periph.bin"
22
+ act = "actuator.bin"
23
+ fp = PROJECT_ROOT+"/Sarcomere_Dynamics_Resources/ArtusAPI/firmware_update/bins/"
24
+
25
+ print(fp+periph)
26
+ print(fp+act)
27
+
28
+ input("""
29
+ ╔══════════════════════════════════════════════════════════════════╗
30
+ ║ Make sure ARTUS masterboard is in boot mode ║
31
+ ║ Press Enter when ready ║
32
+ ╚══════════════════════════════════════════════════════════════════╝
33
+ """)
34
+ # Prompt user for communication method and identifier
35
+ communication_method = input(
36
+ """
37
+ ╔══════════════════════════════════════════════════════════════════╗
38
+ ║ Select Communication Method ║
39
+ ╠══════════════════════════════════════════════════════════════════╣
40
+ ║ Options: ║
41
+ ║ 1 -> UART ║
42
+ ║ 2 -> RS485 ║
43
+ ╚══════════════════════════════════════════════════════════════════╝
44
+ >> Input Option (1-2): """
45
+ )
46
+
47
+ if communication_method == "1":
48
+ communication_method = "UART"
49
+ else:
50
+ communication_method = "RS485"
51
+
52
+ communication_channel_identifier = input("Enter COM port (e.g. COM3): ")
53
+
54
+ artusapi = ArtusAPI(communication_method=communication_method,
55
+ communication_channel_identifier=communication_channel_identifier,
56
+ awake = True)
57
+
58
+ # -------------------------------------------------------------------------------
59
+ # --------------------------------- Example -------------------------------------
60
+ # -------------------------------------------------------------------------------
61
+
62
+ os_type = platform.system()
63
+
64
+ if os_type == "Windows":
65
+ flash_script = os.path.join(PROJECT_ROOT, "Sarcomere_Dynamics_Resources", "ArtusAPI", "firmware_update", "flash_script.bat")
66
+ elif os_type in ["Linux", "Darwin"]:
67
+ flash_script = os.path.join(PROJECT_ROOT, "Sarcomere_Dynamics_Resources", "ArtusAPI", "firmware_update", "flash_script.sh")
68
+ else:
69
+ raise OSError(f"Unsupported operating system: {os_type}")
70
+
71
+ print(f"\nRunning firmware update script for {os_type}...")
72
+
73
+ try:
74
+ # Run the flash script
75
+ subprocess.run([flash_script], check=True, shell=True)
76
+ print("Firmware update completed successfully")
77
+ except subprocess.CalledProcessError as e:
78
+ print(f"Error running firmware update script: {e}")
79
+ except FileNotFoundError:
80
+ print(f"Flash script not found at: {flash_script}")
81
+
82
+
83
+ input("""
84
+ ╔══════════════════════════════════════════════════════════════════╗
85
+ ║ Please restart the ARTUS hand in normal mode ║
86
+ ║ Press Enter when ready ║
87
+ ╚══════════════════════════════════════════════════════════════════╝
88
+ """)
89
+
90
+ artusapi.connect()
91
+
92
+
93
+ # update firmware for spi first
94
+ artusapi.update_firmware(upload_flag='y', file_location=fp+periph, drivers_to_flash=9)
95
+ artusapi.update_firmware(upload_flag='y', file_location=fp+act, drivers_to_flash=0)
96
+
97
+ print("""
98
+ ╔══════════════════════════════════════════════════════════════════╗
99
+ ║ Firmware update completed successfully ║
100
+ ║ Please close this script and restart the ARTUS hand ║
101
+ ╚══════════════════════════════════════════════════════════════════╝
102
+ """)
103
+
104
+ if __name__ == "__main__":
105
+ example()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ArtusAPI
3
- Version: 1.0.0
3
+ Version: 1.1.0
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.
@@ -16,10 +16,10 @@ ArtusAPI/communication/WiFi/__init__.py
16
16
  ArtusAPI/communication/WiFi/wifi_server.py
17
17
  ArtusAPI/firmware_update/__init__.py
18
18
  ArtusAPI/firmware_update/firmware_updater.py
19
+ ArtusAPI/firmware_update/run_full_firmware_update.py
19
20
  ArtusAPI/robot/__init__.py
20
21
  ArtusAPI/robot/robot.py
21
22
  ArtusAPI/robot/artus_lite/__init__.py
22
23
  ArtusAPI/robot/artus_lite/artus_lite.py
23
24
  ArtusAPI/robot/artus_lite/artus_lite_left.py
24
- ArtusAPI/robot/artus_lite/artus_lite_right.py
25
- test/test.py
25
+ ArtusAPI/robot/artus_lite/artus_lite_right.py
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ArtusAPI
3
- Version: 1.0.0
3
+ Version: 1.1.0
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,10 +1,28 @@
1
1
  <img src='data/images/SarcomereLogoHorizontal.svg'>
2
2
 
3
- # Python Artus Robotic Hand API
4
- This repository contains a Python API for controlling the Artus robotic hands by Sarcomere Dynamics Inc.
3
+ # Python ARTUS Robotic Hand API
4
+
5
+ This repository contains a Python API for controlling the ARTUS robotic hands by Sarcomere Dynamics Inc.
5
6
 
6
7
  Please contact the team if there are any issues that arise through the use of the API.
7
8
 
9
+ ## Introduction
10
+ __Please read through the entire README and the _User Manual_ before using the ARTUS hand__
11
+
12
+ The user manual contains in-depth operational and troubleshooting guidelines for the device.
13
+
14
+ This repository contains the following:
15
+ * [ARTUS API](/ArtusAPI/)
16
+ * [ROS2 Node](/ros2/)
17
+ * [Examples](/examples/)
18
+
19
+ Below is a list of the ARTUS hands that are compatible with the API:
20
+ * ARTUS Lite
21
+
22
+ ### VERY IMPORTANT
23
+ * [Requirements](#requirements)
24
+ * [Normal Startup Procedure](#normal-startup-procedure)
25
+
8
26
  ## Table of Contents
9
27
  * [Getting Started](#getting-started)
10
28
  * [Video Introduction](#video-introduction)
@@ -17,8 +35,15 @@ Please contact the team if there are any issues that arise through the use of th
17
35
  * [Serial Example](#serial-example)
18
36
  * [Normal Startup Procedure](#normal-startup-procedure)
19
37
  * [Interacting with the API](#interacting-with-the-api)
38
+ * [Startup Commands](#startup-commands)
20
39
  * [Setting Joints](#setting-joints)
40
+ * [Input Units](#input-units)
21
41
  * [Getting Feedback](#getting-feedback)
42
+ * [SD Card Interactions](#sd-card-intersactions)
43
+ * [Changing Communication Methods](#changing-communication-methods)
44
+ * [Controlling Multiple Hands](#controlling-multiple-hands)
45
+ * [Special Commands](#special-commands)
46
+ * [Teleoperation Considerations](#teleoperation-considerations)
22
47
  * [Directory Structure](#directory-structure)
23
48
 
24
49
  ## Getting Started
@@ -39,18 +64,16 @@ pip install pyserial
39
64
  pip install ArtusAPI
40
65
  ```
41
66
 
42
- ## Usage
67
+ __Alternatively, cloning the repository and using the repository locally in a project scope is another option, it may be more up-to-date than the pip stable release.__
43
68
 
44
- ### Running example.py
45
- Before running the example script, determine whether your Artus Lite is running USB Serial or WiFi, and edit the following line with the name of the port over UART or target SSID for WiFi
69
+ ```bash
70
+ pip install -r requirements.txt
71
+ ```
46
72
 
47
- * On Windows, find the port name by navigating to "Device Manager">"Ports". It should show up as a COM port. (e.g. COM3)
48
- * On Linux, use the command `dmesg | grep ttyUSB` to find the usb device. (e.g. /dev/ttyUSB1)
49
- * If a permission error is encountered, use the command `sudo chmod 777 /dev/ttyUSB1`
73
+ ## Usage
50
74
 
51
- ```python
52
- artusapi = ArtusAPI(communication_method='UART',hand_type='right',communication_channel_identifier='/dev/ttyUSB1')
53
- ```
75
+ ### Running example.py
76
+ See [General Example README](/examples/general_example/README.md)
54
77
 
55
78
  ### Creating an ArtusAPI Class Object
56
79
  Below are some examples of instantiating the ArtusAPI class to control a single hand. Below is a description of the parameters and what they mean.
@@ -60,15 +83,16 @@ Below are some examples of instantiating the ArtusAPI class to control a single
60
83
  * `__robot_type__` : The Artus robot hand name
61
84
  * `__hand_type__` : left or right hand
62
85
  * `__stream__` : whether streaming feedback data is required or not. Default: `False`
63
- * `__communication_frequency__` : The frequency of the feedback and command communication. Default: `400` Hz
86
+ * `__communication_frequency__` : The frequency of the feedback and command communication. Default: `200` Hz
64
87
  * `__logger__` : If integrating the API into control code, you may already have a logger. THis will allow for homogeneous logging to the same files as what you currently have. Default: `None`
65
- * `__reset_on_start__` : If the hand is not in a closed state when last powered off, setting to `1` will open the hand before ready to receive commands. This _MUST_ be set if powered off in a closed state, or a calibrate must be run before sending target commands
66
- * `__baudrate__` : required to differentiate between Serial over USB-C and Serial over RS485, default `921600` for SUBC, `115200` for RS485
88
+ * `__reset_on_start__` : If the hand is not in a closed state when last powered off, setting to `1` will open the hand before ready to receive commands. This _MUST_ be set if powered off in a closed state, and a calibrate may need to be run before sending accurate target commands
89
+ * `__baudrate__` : required to differentiate between Serial over USB-C and Serial over RS485, default `921600`
90
+ * `__awake__` : False by default - if the hand is already in a ready state (LED is green) when starting or restarting a control script, set woken to `True` to bypass resending the `wake_up` function, which could lead to lost calibration.
67
91
 
68
92
  #### Serial Example
69
93
  ```python
70
94
  from ArtusAPI.artus_api import ArtusAPI
71
- artus_lite = ArtusAPI(robot_type='artus_lite', communication_type='UART',hand_type='right',communication_channel_identifier='COM7')
95
+ artus_lite = ArtusAPI(robot_type='artus_lite', communication_type='UART',hand_type='right',communication_channel_identifier='COM7',reset_on_start=0)
72
96
 
73
97
  artus_lite.connect()
74
98
  ```
@@ -84,11 +108,24 @@ Second, the `ArtusAPI.wake_up()` function must be run to allow the hand to load
84
108
 
85
109
  Once these two steps are complete, optionally, you can run `ArtusAPI.calibrate()` to calibrate the finger joints. Otherwise, the system is now ready to start sending and receiving data!
86
110
 
111
+ **_Note: If running version v1.0.1, `wake_up` is called inside the `connect()` function_**
112
+
87
113
  ## Interacting with the API
88
114
  To get the most out of the Artus hands, the functions that will likely be most interacted with are `set_joint_angles(self, joint_angles:dict)` and `get_joint_angles(self)`. The `set_joint_angles` function allows the user to set 16 independent joint values with a desired velocity/force value in the form of a dictionary. See the [grasp_close file](data/hand_poses/grasp_close.json) for an example of a full 16 joint dictionary for the Artus Lite. See the [Artus Lite README](ArtusAPI/robot/artus_lite/README.md) for joint mapping.
89
115
 
116
+ e.g.
117
+ ```python
118
+ artusapi.set_joint_angles(pinky_dict)
119
+ ```
120
+ ### Startup Commands
121
+ * `connect` is used to start a connection between the API and the hand via the communication method chosen. It will then send a `wake_up` command if `awake == False`.
122
+ * The `wake_up` command properly configures the hand and the actuators. Once an `ack` is returned, the hand is now ready to be controlled
123
+ * `calibrate` sends a full calibration command sequence for all the fingers.
124
+
125
+
90
126
  ### Setting Joints
91
127
  As mentioned above, there are 16 independent degrees of freedom for the Artus Lite, which can be set simultaneously or independently. If, for example, a user need only curl the pinky, a shorter dictionary like the following could be used as a parameter to the function:
128
+
92
129
  ```
93
130
  pinky_dict = {"pinky_flex" :
94
131
  {
@@ -107,12 +144,50 @@ ArtusAPI.set_joint_angles(pinky_dict)
107
144
 
108
145
  Notice that the above example does not include the `"input_speed"` field that the json file has. The `"input_speed"` field is optional and will default to the nominal speed.
109
146
 
147
+ ### Input Units
148
+ * Input Angle: the input angle is an integer value in degrees
149
+ * velocity: the velocity is in a percentage unit 0-100. Minimum movement requirement is around 30. This value pertains to the gripping force of the movement.
150
+
110
151
  ### Getting Feedback
111
152
  There are two ways to get feedback data depending on how the class is instantiated.
112
153
 
113
154
  1. In streaming mode (`stream = True`), after sending the `wake_up()` command, the system will start streaming feedback data which will populate the `ArtusAPI._robot_handler.robot.hand_joints` dictionary. Fields that hold feedback data are named with `feedback_X` where _X_ could be angle, current or temperature.
114
155
  2. In Request mode (`stream = False`), sending a `get_joint_angles()` command will request the feedback data before anything is sent from the Artus hand. This communication setting is slower than the streaming mode, but for testing purposes and getting familiar with the Artus hand, we recommend starting with this setting.
156
+ 3. Feedback message has the following data: ACK, Feedback angle (degrees), Motor Current (mA), Temperature. The following is a table for the ACK value.
157
+
158
+ | ACK Value | Meaning |
159
+ | :---: | :------: |
160
+ | 2 | ACK_RECEIVED FOR BLOCKING COMMANDS |
161
+ | 9 | ERROR |
162
+ | 25 | TARGET ACHIEVED |
163
+
164
+
165
+ ### SD Card Intersactions
166
+ Before using the Artus Lite's digital IO functionality to communicate with a robotic arm, there are two steps that need to be done.
167
+ 1. Users must set the grasps that they want to call. This is done through the UI or general_example.py, using the `save_grasp_onhand` command. This command will save the last command sent to the hand in the designated position specified (1-6) on the SD card and persist through resets.
168
+ 2. Users can use the `execute_grasp` command to call the grasps through the API.
169
+ 3. Users can print to the terminal all 6 grasps saved to the SD Card using `get_saved_grasps_onhand`
170
+
171
+ Each of the above will print the target command saved on the SD card to the terminal.
172
+
173
+ ### Changing Communication Methods
174
+ To change the communication method between USBC, RS485 and CAN, use the `update_param` command. __Additional steps have to be taken to switch to CAN__. See the User Manual for instructions.
175
+
176
+ ### Controlling multiple hands
177
+ We can define two instances of hands with different `communication_channel_identifier`. In theory, it can spin up an unlimited amount of hands, bottlenecked by the amount of wifi controllers and COM ports associated with the machine.
115
178
 
179
+ ### Special Commands
180
+ The following commands are to be used in only certain circumstances with the help of the Sarcomere Dynamics Team. __THESE COMMANDS ARE NOT TO BE USED WITHOUT INSTRUCTION FROM SARCOMERE DYNAMICS INC.__
181
+
182
+ * `reset` command is to be used when a finger is jammed in an closed state and won't respond to a open command, requiring the index of the joint and the motor.
183
+ * `hard_close` command is used when a joint is fully opened and isn't responding to closing command, requiring the index of the joint and the motor.
184
+
185
+ ## Teleoperation Considerations
186
+ For teleoperation, there is a parameter for the class that lets the user set the `communication frequency` without adding delays into the communication.
187
+
188
+ ```python
189
+ artus_liteLeft = Artus3DAPI(target_ssid='Artus3DLH',port='COM5',communication_method='UART',communication_frequency = 40)
190
+ ```
116
191
 
117
192
  ## Directory Structure
118
193
  ```bash
@@ -130,16 +205,13 @@ There are two ways to get feedback data depending on how the class is instantiat
130
205
  │   │   │   ├── artus_lite.py # Artus Lite Hand class
131
206
  │   │   ├── robot.py # Robot Hand class for the API
132
207
  │   ├── artus_api.py # API Core
133
-
134
- ├── data
135
- │   ├── grasp_poses
136
- │   ├── images
137
-
138
- ├── examples
139
- │   ├── example.py # Example usage of the API
140
208
  ```
141
209
 
142
- ## API Core
143
- ```python
144
- class ArtusAPI()
145
- ```
210
+ ## Revision Control
211
+ | Date | Revision | Description | Pip Release |
212
+ | :---: | :------: | :---------: | :----------: |
213
+ | Nov. 14, 2023 | v1.0b | Initial release - Artus Lite Mk 5 | NA |
214
+ | Apr. 23, 2024 | v1.1b | Beta release - Artus Lite Mk 6 | NA |
215
+ | Oct. 9, 2024 | v1.0 | Artus Lite Release | v1.0 |
216
+ | Oct. 23, 2024 | v1.0.2 | awake parameter added, wake up function in connect | v1.0.1 |
217
+ | Nov. 14, 2024 | v1.1 | firmware v1.1 release | v1.1 |
@@ -2,10 +2,10 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name='ArtusAPI',
5
- version='1.0.0',
5
+ version='1.1.0',
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
- packages=find_packages(exclude=['data*', 'examples*', 'tests*','venv*']),
8
+ packages=find_packages(exclude=['data*', 'examples*', 'tests*','venv*', 'urdf*', 'ros2*']),
9
9
  author='Sarcomere Dynamics Inc.'
10
10
  # packages=find_packages(where='/'),
11
11
  # other setup configurations
File without changes
File without changes
File without changes