imt-ring 1.3.13__py3-none-any.whl → 1.4.1__py3-none-any.whl
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.
- {imt_ring-1.3.13.dist-info → imt_ring-1.4.1.dist-info}/METADATA +1 -1
- {imt_ring-1.3.13.dist-info → imt_ring-1.4.1.dist-info}/RECORD +8 -7
- ring/__init__.py +81 -1
- ring/ml/__init__.py +2 -23
- ring/ml/base.py +26 -1
- ring/ml/params/0x1d76628065a71e0f.pickle +0 -0
- {imt_ring-1.3.13.dist-info → imt_ring-1.4.1.dist-info}/WHEEL +0 -0
- {imt_ring-1.3.13.dist-info → imt_ring-1.4.1.dist-info}/top_level.txt +0 -0
@@ -1,4 +1,4 @@
|
|
1
|
-
ring/__init__.py,sha256=
|
1
|
+
ring/__init__.py,sha256=1kDuGEkC-Fkuzlijg4PFGg1r60HDmk1xsNNTiLKRToA,4331
|
2
2
|
ring/algebra.py,sha256=F0GwbP8LQP5qGVkoMUYJmkp9Hn2nKAVIkCVYDEjNjGU,3128
|
3
3
|
ring/base.py,sha256=YFPrUWelWswEhq8x8Byv-5pK64mipiGW6x5IlMr4we4,33803
|
4
4
|
ring/maths.py,sha256=jJr_kr78-XDce8B4tXQ2Li-jBntVQhaS8csxglCsj8A,12193
|
@@ -50,8 +50,8 @@ ring/io/xml/from_xml.py,sha256=8b44sPVWgoY8JGJZLpJ8M_eLfcfu3IsMtBzSytPTPmw,9234
|
|
50
50
|
ring/io/xml/test_from_xml.py,sha256=bckVrVVmEhCwujd_OF9FGYnX3zU3BgztpqGxxmd0htM,1562
|
51
51
|
ring/io/xml/test_to_xml.py,sha256=NGn4VSiFdwhYN5YTBduWMiY9B5dwtxZhCQAR_PXeqKU,946
|
52
52
|
ring/io/xml/to_xml.py,sha256=fohb-jWMf2cxVdT5dmknsGyrNMseICSbKEz_urbaWbQ,3407
|
53
|
-
ring/ml/__init__.py,sha256=
|
54
|
-
ring/ml/base.py,sha256
|
53
|
+
ring/ml/__init__.py,sha256=8SZTCs9rJ1kzR0Psh7lUzFhIMhKRPIK41mVfxJAGyMo,1471
|
54
|
+
ring/ml/base.py,sha256=-3JQ27zMFESNn5zeNer14GJU2yQgiqDcJUaULOeSyp8,9799
|
55
55
|
ring/ml/callbacks.py,sha256=W19QF6_uvaNCjs8ObsjNXD7mv9gFgJBixdRSbB_BynE,13301
|
56
56
|
ring/ml/ml_utils.py,sha256=hQEmeZoahdJyFrz0NZXYi1Yijl7GvPBdqwzZBzlUIUM,7638
|
57
57
|
ring/ml/optimizer.py,sha256=fWyF__ezUltrA16SLfOC1jvS3zBh9NJsMYa6-V0frhs,4709
|
@@ -60,6 +60,7 @@ ring/ml/rnno_v1.py,sha256=T4SKG7iypqn2HBQLKhDmJ2Slj2Z5jtUBHvX_6aL8pyM,1103
|
|
60
60
|
ring/ml/train.py,sha256=huUfMK6eotS6BRrQKoZ-AUG0um3jlqpfQFZNJT8LKiE,10854
|
61
61
|
ring/ml/training_loop.py,sha256=CEokvPQuuk_WCd-J60ZDodJYcPVvyxLfgXDr_DnbzRI,3359
|
62
62
|
ring/ml/params/0x13e3518065c21cd8.pickle,sha256=Zh2k1zK-TNxJl5F7nyTeQ9001qqRE_dfvaq1HWV287A,9355838
|
63
|
+
ring/ml/params/0x1d76628065a71e0f.pickle,sha256=YTNVuvfw-nCRD9BH1PZYcR9uCFpNWDhw8Lc50eDn_EE,9351038
|
63
64
|
ring/rendering/__init__.py,sha256=Zf7qOdzK3t2hljIrs5P4zFhzHljLSMRyDDZO2YlZk4k,75
|
64
65
|
ring/rendering/base_render.py,sha256=s5dF-GVBqjiWkqVuPQMtTLuM7EtA-YrB7RVWFfIaQ1I,8956
|
65
66
|
ring/rendering/mujoco_render.py,sha256=aluzQJp3jrDdPfAyNmQuXIHRfgfBTCCZQqxKOx_0D2s,7770
|
@@ -79,7 +80,7 @@ ring/utils/hdf5.py,sha256=BzXwVypZmEZeHVgeGZ78YYdi10NEQtnPhdrb8dQAXo0,5856
|
|
79
80
|
ring/utils/normalizer.py,sha256=67L2BU1MRsMT4pD41ta3JJMppLN0ozFmnwrmXDtnqrQ,1698
|
80
81
|
ring/utils/path.py,sha256=hAfSlqRi-ew536RnjDDM7IKapdMJc-EvhrR0Y-BCFWc,1265
|
81
82
|
ring/utils/utils.py,sha256=mIcKNv5v2de8HrG7bAhl2bNfmwkMZyIIwFkJq2XWMOI,5357
|
82
|
-
imt_ring-1.
|
83
|
-
imt_ring-1.
|
84
|
-
imt_ring-1.
|
85
|
-
imt_ring-1.
|
83
|
+
imt_ring-1.4.1.dist-info/METADATA,sha256=uxnuzRi_YRN2-Toh7TyiglMt5O4bQ2H7TpWHq_-Yj7g,3104
|
84
|
+
imt_ring-1.4.1.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
85
|
+
imt_ring-1.4.1.dist-info/top_level.txt,sha256=EiT790-lAyi8iwTzJArH3f2k77rwhDn00q-4PlmvDQo,5
|
86
|
+
imt_ring-1.4.1.dist-info/RECORD,,
|
ring/__init__.py
CHANGED
@@ -18,7 +18,87 @@ from .algorithms import step
|
|
18
18
|
from .base import State
|
19
19
|
from .base import System
|
20
20
|
from .base import Transform
|
21
|
-
|
21
|
+
|
22
|
+
|
23
|
+
def RING(lam: list[int], Ts: float | None):
|
24
|
+
"""Creates the RING network.
|
25
|
+
|
26
|
+
Params:
|
27
|
+
lam: parent array
|
28
|
+
Ts : sampling interval of IMU data; time delta in seconds
|
29
|
+
|
30
|
+
Usage:
|
31
|
+
>>> import ring
|
32
|
+
>>> import numpy as np
|
33
|
+
>>>
|
34
|
+
>>> T : int = 30 # sequence length [s]
|
35
|
+
>>> Ts : float = 0.01 # sampling interval [s]
|
36
|
+
>>> B : int = 1 # batch size
|
37
|
+
>>> lam: list[int] = [0, 1, 2] # parent array
|
38
|
+
>>> N : int = len(lam) # number of bodies
|
39
|
+
>>> T_i: int = int(T/Ts) # number of timesteps
|
40
|
+
>>>
|
41
|
+
>>> X = np.zeros((B, T_i, N, 9))
|
42
|
+
>>> # where X is structured as follows:
|
43
|
+
>>> # X[..., :3] = acc
|
44
|
+
>>> # X[..., 3:6] = gyr
|
45
|
+
>>> # X[..., 6:9] = jointaxis
|
46
|
+
>>>
|
47
|
+
>>> # let's assume we have an IMU on each outer segment of the
|
48
|
+
>>> # three-segment kinematic chain
|
49
|
+
>>> X[:, :, 0, :3] = acc_segment1
|
50
|
+
>>> X[:, :, 2, :3] = acc_segment3
|
51
|
+
>>> X[:, :, 0, 3:6] = gyr_segment1
|
52
|
+
>>> X[:, :, 2, 3:6] = gyr_segment3
|
53
|
+
>>>
|
54
|
+
>>> ringnet = ring.RING(lam, Ts)
|
55
|
+
>>>
|
56
|
+
>>> yhat, _ = ringnet.apply(X)
|
57
|
+
>>> # yhat : unit quaternions, shape = (B, T_i, N, 4)
|
58
|
+
>>>
|
59
|
+
>>> # use `jax.jit` to compile the forward pass
|
60
|
+
>>> jit_apply = jax.jit(ringnet.apply)
|
61
|
+
>>> yhat, _ = jit_apply(X)
|
62
|
+
>>>
|
63
|
+
>>> # manually pass in and out the hidden state like so
|
64
|
+
>>> initial_state = None
|
65
|
+
>>> yhat, state = ringnet.apply(X, state=initial_state)
|
66
|
+
>>> # state: final hidden state, shape = (B, N, 2*H)
|
67
|
+
|
68
|
+
"""
|
69
|
+
from pathlib import Path
|
70
|
+
import warnings
|
71
|
+
|
72
|
+
if Ts is not None and (Ts > (1 / 40) or Ts < (1 / 200)):
|
73
|
+
warnings.warn(
|
74
|
+
"RING was only trained on sampling rates between 40 to 200 Hz "
|
75
|
+
f"but found {1 / Ts}Hz"
|
76
|
+
)
|
77
|
+
|
78
|
+
if Ts is not None and Ts == 0.01:
|
79
|
+
# this set of parameters was trained exclusively on 100Hz data; it also
|
80
|
+
# expects F=9 features per node and not F=10 where the last features is
|
81
|
+
# the sampling interval Ts
|
82
|
+
params = Path(__file__).parent.joinpath("ml/params/0x1d76628065a71e0f.pickle")
|
83
|
+
add_Ts = False
|
84
|
+
else:
|
85
|
+
# this set of parameters was trained on sampling rates from 40 to 200 Hz
|
86
|
+
params = Path(__file__).parent.joinpath("ml/params/0x13e3518065c21cd8.pickle")
|
87
|
+
add_Ts = True
|
88
|
+
|
89
|
+
ringnet = ml.RING(params=params, lam=tuple(lam), jit=False, name="RING")
|
90
|
+
ringnet = ml.base.ScaleX_FilterWrapper(ringnet)
|
91
|
+
ringnet = ml.base.LPF_FilterWrapper(
|
92
|
+
ringnet,
|
93
|
+
ml._LPF_CUTOFF_FREQ,
|
94
|
+
samp_freq=None if Ts is None else 1 / Ts,
|
95
|
+
quiet=True,
|
96
|
+
)
|
97
|
+
ringnet = ml.base.GroundTruthHeading_FilterWrapper(ringnet)
|
98
|
+
if add_Ts:
|
99
|
+
ringnet = ml.base.AddTs_FilterWrapper(ringnet, Ts)
|
100
|
+
return ringnet
|
101
|
+
|
22
102
|
|
23
103
|
_TRAIN_TIMING_START = None
|
24
104
|
_UNIQUE_ID = None
|
ring/ml/__init__.py
CHANGED
@@ -13,28 +13,7 @@ from .optimizer import make_optimizer
|
|
13
13
|
from .ringnet import RING
|
14
14
|
from .train import train_fn
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
def RING_ICML24(params=None, eval: bool = True, **kwargs):
|
20
|
-
"""Create the RING network used in the icml24 paper.
|
21
|
-
|
22
|
-
X[..., :3] = acc
|
23
|
-
X[..., 3:6] = gyr
|
24
|
-
X[..., 6:9] = jointaxis
|
25
|
-
X[..., 9:] = dt
|
26
|
-
"""
|
27
|
-
from pathlib import Path
|
28
|
-
|
29
|
-
if params is None:
|
30
|
-
params = Path(__file__).parent.joinpath("params/0x13e3518065c21cd8.pickle")
|
31
|
-
|
32
|
-
ringnet = RING(params=params, **kwargs) # noqa: F811
|
33
|
-
ringnet = base.ScaleX_FilterWrapper(ringnet)
|
34
|
-
if eval:
|
35
|
-
ringnet = base.LPF_FilterWrapper(ringnet, _lpf_cutoff_freq, samp_freq=None)
|
36
|
-
ringnet = base.GroundTruthHeading_FilterWrapper(ringnet)
|
37
|
-
return ringnet
|
16
|
+
_LPF_CUTOFF_FREQ = 10.0
|
38
17
|
|
39
18
|
|
40
19
|
def RNNO(
|
@@ -70,7 +49,7 @@ def RNNO(
|
|
70
49
|
ringnet = base.NoGraph_FilterWrapper(ringnet, quat_normalize=return_quats)
|
71
50
|
ringnet = base.ScaleX_FilterWrapper(ringnet)
|
72
51
|
if eval and return_quats:
|
73
|
-
ringnet = base.LPF_FilterWrapper(ringnet,
|
52
|
+
ringnet = base.LPF_FilterWrapper(ringnet, _LPF_CUTOFF_FREQ, samp_freq=samp_freq)
|
74
53
|
if return_quats:
|
75
54
|
ringnet = base.GroundTruthHeading_FilterWrapper(ringnet)
|
76
55
|
return ringnet
|
ring/ml/base.py
CHANGED
@@ -144,11 +144,13 @@ class LPF_FilterWrapper(AbstractFilterWrapper):
|
|
144
144
|
cutoff_freq: float,
|
145
145
|
samp_freq: float | None,
|
146
146
|
filtfilt: bool = True,
|
147
|
+
quiet: bool = False,
|
147
148
|
name="LPF_FilterWrapper",
|
148
149
|
) -> None:
|
149
150
|
super().__init__(filter, name)
|
150
151
|
self.samp_freq = samp_freq
|
151
152
|
self._kwargs = dict(cutoff_freq=cutoff_freq, filtfilt=filtfilt)
|
153
|
+
self.quiet = quiet
|
152
154
|
|
153
155
|
def apply(self, X, params=None, state=None, y=None, lam=None):
|
154
156
|
if X.ndim == 4:
|
@@ -166,7 +168,7 @@ class LPF_FilterWrapper(AbstractFilterWrapper):
|
|
166
168
|
dt = X[0, 0, -1]
|
167
169
|
samp_freq = 1 / dt
|
168
170
|
|
169
|
-
if self.samp_freq is None:
|
171
|
+
if self.samp_freq is None and not self.quiet:
|
170
172
|
print(f"Detected the following sampling rates from `X`: {samp_freq}")
|
171
173
|
|
172
174
|
yhat, state = super().apply(X, params, state, y, lam)
|
@@ -290,3 +292,26 @@ class NoGraph_FilterWrapper(AbstractFilterWrapper):
|
|
290
292
|
yhat = ring.maths.safe_normalize(yhat)
|
291
293
|
|
292
294
|
return yhat, state
|
295
|
+
|
296
|
+
|
297
|
+
class AddTs_FilterWrapper(AbstractFilterWrapper):
|
298
|
+
def __init__(
|
299
|
+
self, filter: AbstractFilter, Ts: float | None, name="AddTs_FilterWrapper"
|
300
|
+
) -> None:
|
301
|
+
super().__init__(filter, name)
|
302
|
+
self.Ts = Ts
|
303
|
+
|
304
|
+
def _add_Ts(self, X):
|
305
|
+
if self.Ts is None:
|
306
|
+
assert X.shape[-1] == 10
|
307
|
+
return X
|
308
|
+
else:
|
309
|
+
assert X.shape[-1] == 9
|
310
|
+
X_Ts = jnp.ones(X.shape[:-1] + (1,)) * self.Ts
|
311
|
+
return jnp.concatenate((X, X_Ts), axis=-1)
|
312
|
+
|
313
|
+
def init(self, bs=None, X=None, lam=None, seed: int = 1):
|
314
|
+
return super().init(bs, self._add_Ts(X), lam, seed)
|
315
|
+
|
316
|
+
def apply(self, X, params=None, state=None, y=None, lam=None):
|
317
|
+
return super().apply(self._add_Ts(X), params, state, y, lam)
|
Binary file
|
File without changes
|
File without changes
|