Joint-python-library 0.0.7__tar.gz → 0.0.8__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 (22) hide show
  1. {joint_python_library-0.0.7 → joint_python_library-0.0.8}/Joint_python_library.egg-info/PKG-INFO +1 -1
  2. {joint_python_library-0.0.7 → joint_python_library-0.0.8}/PKG-INFO +1 -1
  3. {joint_python_library-0.0.7 → joint_python_library-0.0.8}/acrome_joint/joint.py +90 -87
  4. joint_python_library-0.0.8/gui/joint_device.py +14 -0
  5. joint_python_library-0.0.8/gui/limits.py +18 -0
  6. {joint_python_library-0.0.7 → joint_python_library-0.0.8}/gui/main.py +1 -0
  7. {joint_python_library-0.0.7 → joint_python_library-0.0.8}/setup.py +1 -1
  8. joint_python_library-0.0.7/gui/joint_device.py +0 -6
  9. joint_python_library-0.0.7/gui/limits.py +0 -17
  10. {joint_python_library-0.0.7 → joint_python_library-0.0.8}/Joint_python_library.egg-info/SOURCES.txt +0 -0
  11. {joint_python_library-0.0.7 → joint_python_library-0.0.8}/Joint_python_library.egg-info/dependency_links.txt +0 -0
  12. {joint_python_library-0.0.7 → joint_python_library-0.0.8}/Joint_python_library.egg-info/entry_points.txt +0 -0
  13. {joint_python_library-0.0.7 → joint_python_library-0.0.8}/Joint_python_library.egg-info/requires.txt +0 -0
  14. {joint_python_library-0.0.7 → joint_python_library-0.0.8}/Joint_python_library.egg-info/top_level.txt +0 -0
  15. {joint_python_library-0.0.7 → joint_python_library-0.0.8}/LICENSE +0 -0
  16. {joint_python_library-0.0.7 → joint_python_library-0.0.8}/README.md +0 -0
  17. {joint_python_library-0.0.7 → joint_python_library-0.0.8}/acrome_joint/Slave_Device.py +0 -0
  18. {joint_python_library-0.0.7 → joint_python_library-0.0.8}/acrome_joint/__init__.py +0 -0
  19. {joint_python_library-0.0.7 → joint_python_library-0.0.8}/acrome_joint/serial_port.py +0 -0
  20. {joint_python_library-0.0.7 → joint_python_library-0.0.8}/gui/__init__.py +0 -0
  21. {joint_python_library-0.0.7 → joint_python_library-0.0.8}/gui/ramp_trajectory.py +0 -0
  22. {joint_python_library-0.0.7 → joint_python_library-0.0.8}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: Joint-python-library
3
- Version: 0.0.7
3
+ Version: 0.0.8
4
4
  Summary: Python library for interfacing with Acrome Robotic Arm Joint BLDC Motor Controllers. This Python library provides an easy-to-use interface for communication and control of BLDC motor controllers used in Acrome robotic arm joints. It is designed to simplify the integration of Acrome’s robotic joint actuators into custom applications, allowing developers and researchers to focus on building advanced robotic systems without dealing with low-level communication details.
5
5
  Home-page: https://github.com/Acrome-Smart-Motion-Devices/python-library-new
6
6
  Author: BeratComputer
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: Joint-python-library
3
- Version: 0.0.7
3
+ Version: 0.0.8
4
4
  Summary: Python library for interfacing with Acrome Robotic Arm Joint BLDC Motor Controllers. This Python library provides an easy-to-use interface for communication and control of BLDC motor controllers used in Acrome robotic arm joints. It is designed to simplify the integration of Acrome’s robotic joint actuators into custom applications, allowing developers and researchers to focus on building advanced robotic systems without dealing with low-level communication details.
5
5
  Home-page: https://github.com/Acrome-Smart-Motion-Devices/python-library-new
6
6
  Author: BeratComputer
@@ -12,7 +12,8 @@ from acrome_joint.Slave_Device import *
12
12
 
13
13
 
14
14
  # enter here for extra commands:
15
- #class Device_ExtraCommands(enum.IntEnum):
15
+ class Device_ExtraCommands(enum.IntEnum):
16
+ PROTOCOL_RESET_ABSOLUTE_ENCODER = 0x11
16
17
  # .......... start with 11
17
18
  # .......... end of extra commmands max: 39
18
19
 
@@ -143,7 +144,7 @@ class Joint(Slave_Device):
143
144
  Data_(Index_Joint.current_Id, 'f'),
144
145
  Data_(Index_Joint.current_Iq, 'f'),
145
146
  Data_(Index_Joint.current_velocity, 'f'),
146
- Data_(Index_Joint.current_position, 'i'),
147
+ Data_(Index_Joint.current_position, 'f'),
147
148
  Data_(Index_Joint.current_electrical_degree, 'f'),
148
149
  Data_(Index_Joint.current_electrical_radian, 'f'),
149
150
  Data_(Index_Joint.setpoint_current, 'f'),
@@ -282,7 +283,17 @@ class Joint(Slave_Device):
282
283
  return super().set_variables(*idx_val_pairs, ack=ack)
283
284
 
284
285
 
286
+ def get_currentStatus_parameters(self):
287
+ classic_package = [
288
+ Index_Joint.Enable,
289
+ Index_Joint.current_Id, Index_Joint.current_Iq,
290
+ Index_Joint.current_velocity, Index_Joint.current_position,
291
+ Index_Joint.Temprature_read,
292
+ Index_Joint.setpoint_current, Index_Joint.setpoint_velocity, Index_Joint.setpoint_position
293
+ ]
294
+ return self.get_variables(*classic_package)
285
295
 
296
+
286
297
  def get_FOC_parameters(self, package_number:int):
287
298
  if package_number >= 4:
288
299
  raise "invalid package number ex: 0, 1, 2"
@@ -324,112 +335,104 @@ class Joint(Slave_Device):
324
335
  elif package_number == 3:
325
336
  return self.get_variables(*classic_package)
326
337
 
338
+ def reset_absolute_encoder(self):
339
+ self._pure_command_send(Device_ExtraCommands.PROTOCOL_RESET_ABSOLUTE_ENCODER)
340
+
327
341
 
328
-
329
- def set_joint_variables_sync(port:SerialPort, parameter_idx, *idx_val_pairs):
342
+ def set_joint_variables_sync(port: SerialPort, parameter_idx, *idx_val_pairs):
330
343
  """
331
- Build & send a WRITE_SYNC packet:
332
- [HEADER, 0xFF, DEVICE_FAMILY, LENGTH, WRITE_SYNC, 0, PARAM_IDX, (ID, VALUE)*, CRC32]
333
- - parameter_idx: single parameter index to write on each target
334
- - idx_val_pairs: variadic list of 2-tuples/lists like (id, value) or [id, value]
335
- - port: SerialPort-like object that has write(bytes) method
336
-
337
- Returns: number of bytes written.
338
- Raises: ValueError on malformed inputs.
344
+ Sync Write paketi oluşturur ve gönderir.
345
+
346
+ Args:
347
+ port: SerialPort nesnesi.
348
+ parameter_idx: Index_Joint enum değeri (örn: Index_Joint.Enable).
349
+ idx_val_pairs: [DeviceID, Value] listeleri. Örn: [0, True], [1, True]
339
350
  """
340
-
341
- # --- Validate & fetch parameter meta
342
- if parameter_idx not in VARS:
343
- raise ValueError(f"Unknown parameter index: {parameter_idx}")
344
-
345
- var_desc = VARS[parameter_idx]
346
- val_fmt = var_desc.type() # e.g., 'f', 'i', 'H', etc. (little-endian will be applied later)
347
- val_size = var_desc.size() # size in bytes
348
-
349
- # --- Validate pairs; normalize to tuples
351
+
352
+ # 1. Port Kontrolü
353
+ if port is None:
354
+ raise ValueError("Port tanımlı değil.")
355
+
356
+ # 2. Referans Cihaz Oluşturma
357
+ # Data_ yapısındaki .type() ve .size() metotlarına erişmek için.
358
+ try:
359
+ ref_device = Joint(0, port)
360
+ except Exception as e:
361
+ raise ValueError(f"Referans Joint nesnesi oluşturulamadı: {e}")
362
+
363
+ # 3. Parametre Bilgilerini Çekme
364
+ try:
365
+ var_desc = ref_device._vars[parameter_idx]
366
+ except IndexError:
367
+ raise ValueError(f"Bilinmeyen parametre indeksi: {parameter_idx}")
368
+ except AttributeError:
369
+ raise ValueError("Joint nesnesinde '_vars' listesi bulunamadı.")
370
+
371
+ # --- DÜZELTME BURADA ---
372
+ # .type ve .size muhtemelen metot olduğu için () ile çağırıyoruz.
373
+ val_fmt = var_desc.type() # 'f', 'B', 'I' vb. döndürür
374
+ val_size = var_desc.size() # 4, 1 vb. int döndürür
375
+
376
+ # 4. Veri Çiftlerini Doğrulama
350
377
  pairs = []
351
378
  for p in idx_val_pairs:
352
379
  if not hasattr(p, '__len__') or len(p) != 2:
353
- raise ValueError(f"{p} must be a pair like [ID, value]")
380
+ raise ValueError(f"Hatalı veri çifti: {p}. Format [ID, Value] olmalı.")
381
+
354
382
  dev_id, value = p[0], p[1]
355
-
356
- # Device ID range (0..254), 255 is reserved for broadcast in header
383
+
384
+ # ID Kontrolü
357
385
  if not (0 <= int(dev_id) <= 254):
358
- raise ValueError(f"Device ID out of range (0..254): {dev_id}")
386
+ raise ValueError(f"Device ID aralık dışı (0..254): {dev_id}")
359
387
 
360
388
  pairs.append((int(dev_id), value))
361
389
 
362
390
  if not pairs:
363
- raise ValueError("At least one [ID, value] pair is required.")
391
+ raise ValueError("Gönderilecek veri çifti bulunamadı.")
364
392
 
365
- # --- Compute size field used by your protocol
366
- # Payload after the 6 fixed header bytes:
367
- # PARAM_IDX (1 byte)
368
- # + for each pair: ID (1 byte) + VALUE (val_size bytes)
393
+ # 5. Paket Boyutlarını Hesaplama
394
+ # Payload: [PARAM_IDX] + ([ID] + [VALUE]) * N
395
+ # Artık val_size bir int olduğu için toplama işlemi çalışacaktır.
369
396
  payload_size = 1 + len(pairs) * (1 + val_size)
397
+
398
+ length_field = payload_size + Joint._PACKAGE_ESSENTIAL_SIZE + 4 # 4 byte CRC ekle
370
399
 
371
- # Protocol total-length field used in your other function:
372
- # size + PING_PACKAGE_SIZE (to mirror your existing framing)
373
- length_field = payload_size + PING_PACKAGE_SIZE
374
-
375
- # --- Build struct format string & flat args
376
- # Fixed header: '<BBBBBB'
377
- # Then: PARAM_IDX (B)
378
- # Then for each pair: ID (B) + VALUE (val_fmt)
400
+ # 6. Struct Formatını Hazırlama
401
+ # Header(6 byte) + ParamIdx(1 byte) + (DevID(1 byte) + Value(N byte)) * Adet
379
402
  fmt = '<BBBBBB' + 'B' + ''.join(['B' + val_fmt for _ in pairs])
380
403
 
404
+ # 7. Paket İçeriği (Header, ID, Family, Length, Command...)
405
+ HEADER_BYTE = 0x55
406
+ BROADCAST_ID = 0xFF
407
+ CMD_WRITE_SYNC = Device_Commands.WRITE_SYNC
408
+ device_family = Joint._PRODUCT_TYPE
409
+
381
410
  flat = [
382
- dev.SERIAL_HEADER, # header
383
- 0xFF, # broadcast ID
384
- DEVICE_FAMILY, # device family
385
- length_field, # total length field
386
- Device_Commands.WRITE_SYNC, # command
387
- 0x00, # reserved
388
- int(parameter_idx), # parameter index
411
+ HEADER_BYTE, # Header
412
+ BROADCAST_ID, # Broadcast ID (0xFF)
413
+ device_family, # Device Family
414
+ length_field, # Length
415
+ CMD_WRITE_SYNC, # Command
416
+ 0x00, # Status
417
+ int(parameter_idx), # Parametre ID
389
418
  ]
390
419
 
391
- # Append all (ID, VALUE) flattened; VALUE goes in native python type, struct packs it
420
+ # Değerleri ekle
392
421
  for dev_id, value in pairs:
393
422
  flat.append(dev_id)
394
423
  flat.append(value)
395
424
 
396
- # --- Pack without CRC
397
- pkt_wo_crc = struct.pack(fmt, *flat)
398
-
399
- # --- Append CRC32 (little-endian uint32 of the bytes above)
400
- pkt = pkt_wo_crc + struct.pack('<I', CRC32.calc(pkt_wo_crc))
401
-
402
- # --- Send over the provided port (broadcast sync write typically has no ACK)
403
- written = port.write(pkt)
404
- return written
405
-
406
-
407
- def set_variables(self, *idx_val_pairs, ack = False):
408
- # returns : did ACK come?
409
- fmt_str = '<BBBBBB'
410
- var_count = 0
411
- size = 0
412
- for one_pair in idx_val_pairs:
413
- try:
414
- if len(one_pair) != 2:
415
- raise ValueError(f"{one_pair} more than a pair! It is not a pair")
416
- else:
417
- fmt_str += ('B' + self._vars[one_pair[0]].type())
418
- var_count+=1
419
- size += (1 + self._vars[one_pair[0]].size())
420
- except:
421
- raise ValueError(f"{one_pair} is not proper pair")
422
-
423
- flattened_list = [item for sublist in idx_val_pairs for item in sublist]
424
-
425
- struct_out = list(struct.pack(fmt_str, *[self._header, self._id, self._device_family, size + PING_PACKAGE_SIZE, Device_Commands.WRITE, 0, *flattened_list]))
426
- struct_out = bytes(struct_out) + struct.pack('<' + 'I', CRC32.calc(struct_out))
427
- self._ack_size = PING_PACKAGE_SIZE
428
-
429
- self._write_port(struct_out)
430
- if(self.write_ack_enable):
431
- if self._read_ack():
432
- return True
433
- else:
434
- return False
435
- return False
425
+ # 8. Paketleme
426
+ try:
427
+ pkt_wo_crc = struct.pack(fmt, *flat)
428
+ except struct.error as e:
429
+ # Genellikle float yerine int veya tam tersi gelince oluşur
430
+ raise ValueError(f"Struct paketleme hatası (Veri tipi uyumsuzluğu): {e}")
431
+
432
+ # 9. CRC32
433
+ crc_val = CRC32.calc(pkt_wo_crc)
434
+ pkt = pkt_wo_crc + struct.pack('<I', crc_val)
435
+
436
+ # 10. Gönder
437
+ written = port._write_bus(pkt)
438
+ return written
@@ -0,0 +1,14 @@
1
+ from acrome_joint.joint import*
2
+
3
+ keyword_for_usb = "USB-SERIAL"
4
+ altarnate_keyword_for_usb = "USB-Enhanced-SERIAL"
5
+ if(not USB_serial_port(keyword_for_usb)):
6
+ if(not USB_serial_port(altarnate_keyword_for_usb)):
7
+ raise Exception("No USB serial port found. Please check your connections.")
8
+ else:
9
+ keyword_for_usb = altarnate_keyword_for_usb
10
+
11
+ port = SerialPort(USB_serial_port(keyword_for_usb), baudrate=921600, timeout=0.1)
12
+
13
+
14
+ Device = Joint(1, port)
@@ -0,0 +1,18 @@
1
+
2
+ # SPEED = RPM, ACC= RPM/s
3
+ ENCODER_CPR = 16384
4
+
5
+ MOTOR_VEL_MAX = 3000.0 # in rpm
6
+ MOTOR_ACC_MAX = 3000.0
7
+
8
+ ENC_TO_RPM_CONSTANT = ENCODER_CPR / 60
9
+
10
+ MOTOR_VEL_MAX_IN_ENC_TYPE = MOTOR_VEL_MAX * ENC_TO_RPM_CONSTANT
11
+ MOTOR_ACC_MAX_IN_ENC_TYPE = MOTOR_ACC_MAX * ENC_TO_RPM_CONSTANT
12
+
13
+ def rpm_to_tick_per_second(rpm:float):
14
+ return rpm*ENCODER_CPR/60
15
+
16
+ def tick_per_second_to_rpm(tick_per_second:float):
17
+ return tick_per_second*60/ENCODER_CPR
18
+
@@ -546,6 +546,7 @@ class OperationTab(QtWidgets.QWidget):
546
546
  continue
547
547
  try:
548
548
  idx = Index_Joint[nm]
549
+ print(f"Pulling {nm} (Index {idx})")
549
550
  out[nm] = Device.get_variables(idx)[0]
550
551
  except Exception:
551
552
  out[nm] = ""
@@ -5,7 +5,7 @@ with open("README.md", "r", encoding="utf-8") as fh:
5
5
 
6
6
  setuptools.setup(
7
7
  name="Joint-python-library",
8
- version="0.0.7",
8
+ version="0.0.8",
9
9
  author="BeratComputer",
10
10
  author_email="beratdogan@acrome.net",
11
11
  description="Python library for interfacing with Acrome Robotic Arm Joint BLDC Motor Controllers. This Python library provides an easy-to-use interface for communication and control of BLDC motor controllers used in Acrome robotic arm joints. It is designed to simplify the integration of Acrome’s robotic joint actuators into custom applications, allowing developers and researchers to focus on building advanced robotic systems without dealing with low-level communication details.",
@@ -1,6 +0,0 @@
1
- from acrome_joint.joint import*
2
-
3
- keyword_for_usb = "USB-SERIAL"
4
- port = SerialPort(USB_serial_port(keyword_for_usb), baudrate=921600, timeout=0.01)
5
-
6
- Device = Joint(0, port)
@@ -1,17 +0,0 @@
1
-
2
- # SPEED = RPM, ACC= RPM/s
3
- ENCODER_CPR = 4096
4
-
5
- MOTOR_VEL_MAX = 150.0 # in rpm
6
- MOTOR_ACC_MAX = 500.0
7
-
8
-
9
- MOTOR_VEL_MAX_IN_ENC_TYPE = MOTOR_VEL_MAX * 68.2666
10
- MOTOR_ACC_MAX_IN_ENC_TYPE = MOTOR_ACC_MAX * 68.2666
11
-
12
- def rpm_to_tick_per_second(rpm:float):
13
- return rpm*ENCODER_CPR/60
14
-
15
- def tick_per_second_to_rpm(tick_per_second:float):
16
- return tick_per_second*60/ENCODER_CPR
17
-