moteus 0.3.92__tar.gz → 0.3.93__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.
- {moteus-0.3.92 → moteus-0.3.93}/PKG-INFO +1 -1
- {moteus-0.3.92 → moteus-0.3.93}/moteus/moteus.py +27 -0
- {moteus-0.3.92 → moteus-0.3.93}/moteus/moteus_tool.py +3 -17
- {moteus-0.3.92 → moteus-0.3.93}/moteus/version.py +1 -1
- {moteus-0.3.92 → moteus-0.3.93}/moteus.egg-info/PKG-INFO +1 -1
- {moteus-0.3.92 → moteus-0.3.93}/setup.py +1 -1
- {moteus-0.3.92 → moteus-0.3.93}/README.md +0 -0
- {moteus-0.3.92 → moteus-0.3.93}/moteus/__init__.py +0 -0
- {moteus-0.3.92 → moteus-0.3.93}/moteus/aioserial.py +0 -0
- {moteus-0.3.92 → moteus-0.3.93}/moteus/aiostream.py +0 -0
- {moteus-0.3.92 → moteus-0.3.93}/moteus/calibrate_encoder.py +0 -0
- {moteus-0.3.92 → moteus-0.3.93}/moteus/command.py +0 -0
- {moteus-0.3.92 → moteus-0.3.93}/moteus/device_info.py +0 -0
- {moteus-0.3.92 → moteus-0.3.93}/moteus/export.py +0 -0
- {moteus-0.3.92 → moteus-0.3.93}/moteus/fdcanusb.py +0 -0
- {moteus-0.3.92 → moteus-0.3.93}/moteus/fdcanusb_device.py +0 -0
- {moteus-0.3.92 → moteus-0.3.93}/moteus/multiplex.py +0 -0
- {moteus-0.3.92 → moteus-0.3.93}/moteus/posix_aioserial.py +0 -0
- {moteus-0.3.92 → moteus-0.3.93}/moteus/protocol.py +0 -0
- {moteus-0.3.92 → moteus-0.3.93}/moteus/pythoncan.py +0 -0
- {moteus-0.3.92 → moteus-0.3.93}/moteus/pythoncan_device.py +0 -0
- {moteus-0.3.92 → moteus-0.3.93}/moteus/reader.py +0 -0
- {moteus-0.3.92 → moteus-0.3.93}/moteus/regression.py +0 -0
- {moteus-0.3.92 → moteus-0.3.93}/moteus/transport.py +0 -0
- {moteus-0.3.92 → moteus-0.3.93}/moteus/transport_device.py +0 -0
- {moteus-0.3.92 → moteus-0.3.93}/moteus/transport_factory.py +0 -0
- {moteus-0.3.92 → moteus-0.3.93}/moteus/transport_wrapper.py +0 -0
- {moteus-0.3.92 → moteus-0.3.93}/moteus/win32_aioserial.py +0 -0
- {moteus-0.3.92 → moteus-0.3.93}/moteus.egg-info/SOURCES.txt +0 -0
- {moteus-0.3.92 → moteus-0.3.93}/moteus.egg-info/dependency_links.txt +0 -0
- {moteus-0.3.92 → moteus-0.3.93}/moteus.egg-info/entry_points.txt +0 -0
- {moteus-0.3.92 → moteus-0.3.93}/moteus.egg-info/requires.txt +0 -0
- {moteus-0.3.92 → moteus-0.3.93}/moteus.egg-info/top_level.txt +0 -0
- {moteus-0.3.92 → moteus-0.3.93}/setup.cfg +0 -0
@@ -14,6 +14,7 @@
|
|
14
14
|
|
15
15
|
import asyncio
|
16
16
|
import argparse
|
17
|
+
import collections.abc
|
17
18
|
import copy
|
18
19
|
import enum
|
19
20
|
import io
|
@@ -30,6 +31,32 @@ from .transport_factory import TRANSPORT_FACTORIES, get_singleton_transport, mak
|
|
30
31
|
import moteus.reader
|
31
32
|
|
32
33
|
|
34
|
+
def namedtuple_to_dict(obj):
|
35
|
+
'''Convert a namedtuple recursively into a nested dictionary.
|
36
|
+
|
37
|
+
This function handles namedtuples, dictionaries, and sequences,
|
38
|
+
converting them to nested dictionaries and lists suitable for
|
39
|
+
JSON serialization.
|
40
|
+
|
41
|
+
Args:
|
42
|
+
obj: The object to convert (typically a namedtuple)
|
43
|
+
|
44
|
+
Returns:
|
45
|
+
dict, list, or primitive type representation of the input
|
46
|
+
'''
|
47
|
+
|
48
|
+
if isinstance(obj, tuple) and hasattr(obj, "_fields"):
|
49
|
+
return {field: namedtuple_to_dict(getattr(obj, field)) for field in obj._fields}
|
50
|
+
|
51
|
+
if isinstance(obj, collections.abc.Mapping):
|
52
|
+
return {k: namedtuple_to_dict(v) for k, v in obj.items()}
|
53
|
+
|
54
|
+
if isinstance(obj, collections.abc.Sequence) and not isinstance(obj, (str, bytes, bytearray)):
|
55
|
+
return [namedtuple_to_dict(x) for x in obj]
|
56
|
+
|
57
|
+
return obj
|
58
|
+
|
59
|
+
|
33
60
|
def _merge_resolutions(a, b):
|
34
61
|
if a == mp.IGNORE:
|
35
62
|
return b
|
@@ -37,6 +37,7 @@ from . import moteus
|
|
37
37
|
from . import aiostream
|
38
38
|
from . import regression
|
39
39
|
from . import calibrate_encoder as ce
|
40
|
+
from .moteus import namedtuple_to_dict
|
40
41
|
|
41
42
|
from .device_info import DeviceAddress
|
42
43
|
|
@@ -63,21 +64,6 @@ CURRENT_QUALITY_MIN = 20
|
|
63
64
|
VOLTAGE_MODE_QUALITY_MIN = 40
|
64
65
|
|
65
66
|
|
66
|
-
def _deep_asdict(obj):
|
67
|
-
'''Convert a namedtuple recursively into a nested dictionary'''
|
68
|
-
|
69
|
-
if isinstance(obj, tuple) and hasattr(obj, "_fields"):
|
70
|
-
return {field: _deep_asdict(getattr(obj, field)) for field in obj._fields}
|
71
|
-
|
72
|
-
if isinstance(obj, collections.abc.Mapping):
|
73
|
-
return {k: _deep_asdict(v) for k, v in obj.items()}
|
74
|
-
|
75
|
-
if isinstance(obj, collections.abc.Sequence) and not isinstance(obj, (str, bytes, bytearray)):
|
76
|
-
return [_deep_asdict(x) for x in obj]
|
77
|
-
|
78
|
-
return obj
|
79
|
-
|
80
|
-
|
81
67
|
def _wrap_neg_pi_to_pi(value):
|
82
68
|
while value > math.pi:
|
83
69
|
value -= 2.0 * math.pi
|
@@ -1014,7 +1000,7 @@ class Stream:
|
|
1014
1000
|
|
1015
1001
|
async def do_read(self, channel):
|
1016
1002
|
result = await self.read_data(channel)
|
1017
|
-
print(json.dumps(
|
1003
|
+
print(json.dumps(namedtuple_to_dict(result), indent=2))
|
1018
1004
|
|
1019
1005
|
async def do_flash(self, elffile):
|
1020
1006
|
elf = _read_elf(elffile, [".text", ".ARM.extab", ".ARM.exidx",
|
@@ -1177,7 +1163,7 @@ class Stream:
|
|
1177
1163
|
print()
|
1178
1164
|
print("*** FAILED: Gate driver fault (code=33) during calibration: ")
|
1179
1165
|
drv8323 = await self.read_data("drv8323")
|
1180
|
-
print(json.dumps(
|
1166
|
+
print(json.dumps(namedtuple_to_dict(drv8323), indent=2))
|
1181
1167
|
sys.exit(1)
|
1182
1168
|
else:
|
1183
1169
|
raise
|
@@ -25,7 +25,7 @@ long_description = (here / 'README.md').read_text(encoding='utf-8')
|
|
25
25
|
|
26
26
|
setuptools.setup(
|
27
27
|
name = 'moteus',
|
28
|
-
version = "0.3.
|
28
|
+
version = "0.3.93",
|
29
29
|
description = 'moteus brushless controller library and tools',
|
30
30
|
long_description = long_description,
|
31
31
|
long_description_content_type = 'text/markdown',
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|