dsfb-robotics 0.1.0

DSFB Structural Semiotics Engine for Robotics Health Monitoring — a deterministic, non-intrusive observer layer that reads the residuals existing robot control, kinematic identification, and whole-body balance observers already compute, and structures them into a human-readable grammar of typed episodes. Read-only augmentation, not replacement, of incumbent PHM / FDD / MPC / observer pipelines.
Documentation
+
7
�i�Y����Rt^RIHt^RIt^RIt^RIt^RIt^RIHt^RI	H
t
^RIt]
!]
4P4PPt]R,R,t]R,R,t^t^tR	tR
t.RJOtRRKRRLRRMRRN/tRtR tR!tR"tR#R$R%R&R'R(/t/RR%bRR%bR
R%bRR%bRR'bRR'bRR#bRR%bRR%bRR#bRR'bRR'bRR#bRR%bRR%bRR%bRR%bRR%RR'RR%/Ct]!R)R*44tR+R,lt R-R.lt!R/R0lt"R1R2lt#R3R4lt$R5R6lt%R7R8lt&R9R:lt'R;R<lt(R=R>lt)R?R@lt*RARBlt+RCRDlt,RERFlt-RORGRHllt.]/RI8Xd]P`!].!44R#R#)Pu�
scripts/figures_real.py — publication-quality figure generator for
the dsfb-robotics paper.

Reads `data/processed/<slug>.csv` (one residual norm per row) directly,
runs the residual through the DSFB grammar offline (replicating the
canonical `paper-lock` pipeline), and renders six figure types per
dataset:

  1. Grammar-state timeline      — sample-by-sample Admissible (green)
                                    / Boundary (yellow) / Violation (red)
                                    shading with the residual norm
                                    overlaid; this is the headline
                                    "structure emerging" view.
  2. Residual-on-envelope        — residual norm vs. sample index,
                                    with ρ, boundary_frac·ρ, and the
                                    healthy-window calibration prefix
                                    overlaid.
  3. Side-by-side comparison     — upper panel: incumbent threshold
                                    monitor on the same residual scalar;
                                    lower panel: DSFB grammar timeline.
                                    Shows what the threshold *misses* in
                                    the trajectory structure.
  4. Compression histogram       — per-dataset review-surface
                                    compression ratio (across-dataset
                                    summary).
  5. Semiotic-manifold 3D scatter — the (‖r‖, ṙ, r̈) tuple as a 3-D
                                    point cloud coloured by grammar
                                    state. The literal visual of the
                                    "structure emerges from residuals"
                                    thesis.
  6. Per-joint 3D scatter        — for kinematic arms only, one panel
                                    per joint of the (τ_meas, τ_pred,
                                    residual) triplet. Reveals which
                                    joint(s) carry the residual.

Output: publication-quality PDFs in `paper/figures/`. PNG renders
also written for the Colab notebook to display inline. Same DSFB
parameters as `paper-lock`: W=8, K=4, ρ from Stage III calibration,
hysteresis=2, boundary_frac=0.5.
)�annotationsN)�	dataclass)�Path�data�	processed�paper�figuresg�?g�������?�aloha_static�aloha_static_pingpong_test�aloha_static_screw_driver�aloha_static_tape�anymal_parkour�cheetah3�cwru�
dlr_justin�droid�femto_st�icub3_sorrentino�icub_pushrecovery�ims�kuka_lwr�mobile_aloha�openx�	panda_gaz�so100�
unitree_g1�ur10_kufietaz#4caf50z#ffca28z#e53935z#212121�PHMz#546e7a�
Kinematicsz#1e88e5�	Balancingz#8e24aac�J�]tRt^t$R]R&R]R&R]R&R]R&R]R&R	tR
#)�Episode�int�index�float�norm�drift�slew�str�grammar�N)�__name__�
__module__�__qualname__�__firstlineno__�__annotations__�__static_attributes__r*��;/home/one/dsfb/crates/dsfb-robotics/scripts/figures_real.pyr!r!s���J�
�K��L�
�K�
�Lr1r!c� �V^8�dQhRRRR/#)��	residuals�
np.ndarray�returnztuple[float, int]r*)�formats"r2�__annotate__r9�s��#�#�*�#�1B�#r1c���\V4pV^8Xd\R4^3#\^V^,4pVRVpV\P!V4,pVP
^8Xd\R4V3#\\P!\P!V444p\\P!\P!V444pVRV,,V3#)uHStage III calibration: ρ = μ + 3σ over the first 20 % finite samples.�infNg@)	�lenr$�max�np�isfinite�size�mean�abs�std)r5�n�cal_n�cal�finite�mu�sigmas&      r2�calibrate_enveloperJ�s����I��A��A�v��U�|�Q�����1��6�N�E�
�F�U�
�C�
����S�!�
"�F�
�{�{�a���U�|�U�"�"�	�r�w�w�r�v�v�f�~�&�	'�B��"�&�&������(�)�E�
��e���U�"�"r1c� �V^8�dQhRRRR/#)r4r5r6r7ztuple[list[Episode], float]r*)r8s"r2r9r9�s��@�@�
�@�'B�@r1c���\V4wr.p.pRpRp^pRpR.\,p	^p
^p\V4EF�wr�\P!V
4'*p\P!V
4'd\V
4MRpVP
V4\V4\8�dVP^4V'g\V4^8dRpRpRpM@\P!V4p\\P!V44pVV,
pTpW�8�dRpMJV\V,8�d.V^8�dRpM.\V4\8�dRpM\W�4pM\W�4pV\V,8�;'dW�8*pVW�&V
^,\,p
V\8d
V^,
pVV8XdV^8d
V^,
pV^8�dTpMTp^pVP
\!W�VVVR74EK�	W13#)z�Replay the canonical DSFB engine offline. Returns (episodes,
envelope_radius). Mirrors `dsfb_robotics::engine::DsfbRoboticsEngine`.��
AdmissibleF�	Violation�Boundary)r#r%r&r'r))rJ�K�	enumerater>r?rB�appendr<�W�pop�diffr$rA�
BOUNDARY_FRAC�DELTA_S�
check_grazingr!)r5�rho�_�eps�norms_window�
prev_drift�pending�confirms�	committed�
boundary_hits�hit_head�	hit_count�i�r�below_floorr%r&r'�diffs�raw�is_approachs&                    r2�run_dsfbrk�s��� �	�
*�F�C��C� "�L��J��G��H��I��G�a�K�M��H��I��)�$����+�+�a�.�(�����Q���s�1�v�S�����D�!��|��q� ����Q���#�l�+�a�/��E��D��J��G�G�L�)�E��"�'�'�%�.�)�E��:�%�D��J��:��C�
�M�C�'�
'��q�y� ���T��W�$� ��#�M�=���
�9�C�
�=�3�&�&�
�
���	�#.�
���q�L�A�%���q�=���N�I��'�>��!�|��A�
���1�}��	���G��H��
�
�7��U��y�Y�Z�c%�d�8�Or1c�$�V^8�dQhRRRRRR/#)r4�hitsz
list[bool]rdr"r7r(r*)r8s"r2r9r9�s!����
��s��s�r1c�H�V\8�d\V4\8�dR#R#)rPrN)rQ�sum)rmrds&&r2rYrY�s���A�~�#�d�)�q�.��r1c� �V^8�dQhRRRR/#)r4�slugr(r7r6r*)r8s"r2r9r9�s��+�+��+��+r1c	�j�\VR2,pVP4'g'\P!.\PR7#.pVPR4;_uu_4p\P!V4p\VR4VF�pV'gK
V^,P4P4pVR9dVP\R44KUVR9dVP\R44KxVR	9dVP\R44K�VP\V44K�	RRR4\P!V\PR7# \d TP\R44EKi;i +'giLc;i)
z.csv)�dtyperfN�nanr;�-inf)rt)r;z+inf�infinity)ruz	-infinity)�
PROCESSED_DIR�is_filer>�array�float64�open�csv�reader�next�strip�lowerrSr$�
ValueError)rq�path�arr�frf�row�toks&      r2�load_residualsr��s*���d�V�4�=�(�D��<�<�>�>��x�x��"�*�*�-�-��C�	
���3���1��J�J�q�M���Q��
��C����a�&�,�,�.�&�&�(�C��h���
�
�5��<�(��3�3��
�
�5��<�(��-�-��
�
�5��=�)�-��J�J�u�S�z�*��
�$�8�8�C�r�z�z�*�*��"�-��J�J�u�U�|�,�,�-��!
��s1�(CF"�)E5�F"�5%F	�F"�F	�F"�"F2	c� �V^8�dQhRRRR/#)r4rqr(r7znp.ndarray | Noner*)r8s"r2r9r9�s��I�I��I�!2�Ir1c��\VR2,pVP4'gR#\P!VR^\PR7#)z_per_joint.csvN�,)�	delimiter�skiprowsrs)rwrxr>�loadtxtrz)rqr�s& r2�load_per_jointr��s:���d�V�>�2�2�D��<�<�>�>��
�:�:�d�c�A�R�Z�Z�H�Hr1c� �V^8�dQhRRRR/#)r4r)r(r7r*)r8s"r2r9r9s����s��s�r1c�B�VR8Xd\#VR8Xd\#\#)rNrP)�COL_ADM�COL_BND�COL_VIO�r)s&r2�	color_forr�s!���,�����*�����Nr1c�0�V^8�dQhRRRRRRRRR	R
RR/#�
r4rqr(r5r6r\�
list[Episode]rZr$�outrr7�Noner*)r8s"r2r9r9s9��!�!�#�!�*�!�=�!�!&�!�-1�!�6:�!r1c��^RIHpVPRRR7wrg\V4pV^8XdVP	V4R#\^VR,4p	\P!^W�4p
\P!V
Uu.uFq�V,PNK	up4pV
Uu.uFq�V,PNK	p
p\V
4FLwr�VPW�,V	^,,
W�,V	^,,\V4R^R7KN	VPW�\RR7VP!V\"R	R
RVR
2R
7VP!\$V,\&R	R
\$R\$V,R
2R
7VP)^V4VP+R4VP-R4VP/VRVR
R24VP1R ^^\2RRR7VP1R ^^\&RRR7VP1R ^^\"RRR7.pVP5VRR^R7VP7RR7VP94\;WdR4VP	V4R#uupiuupi)!�N�,��figsize�dpi���?��color�alpha�lw��?�r�r��--��������?uρ=�.3g�r��lsr��labelu·ρ=�sample index k�residual norm ‖r(k)‖u — grammar-state timeline (r�� real samples)�333333�?rN��fcr�r�rPrO�
upper left�333333�?��handles�loc�
framealpha�fontsize�
ףp=
�?�r��grammar_timeline�� @g������@�r�r�)�matplotlib.pyplot�pyplot�subplotsr<�closer=r>�arangeryr%r)rR�axvspanr��plot�COL_LINE�axhliner�rWr��set_xlim�
set_xlabel�
set_ylabel�	set_title�	Rectangler��legend�grid�tight_layout�_save)rqr5r\rZr��plt�fig�axrD�stride�idxrer%�grammars�g�legend_proxiess&&&&&           r2�render_grammar_timeliner�s$��#��l�l�:�3�l�7�G�C��C��A��A�v��	�	�#���
��A��I�
�F�
�)�)�A�q�
!�C�
�8�8�#�.�#�Q��V�[�[�#�.�/�D�(+�,��1�A�����H�,��(�#���
�
�
�3�6�F�Q�J�&����!��(;�"�1��T�a�	�	9�$��G�G�C�X�#�G�.��J�J�s�'�d�s�C��C�y�/�J�J��J�J�}�s�"�'�d�s�%��e�M�C�,?��+D�E��G��K�K��1���M�M�"�#��M�M�,�-��L�L�D�6�6�q��e�>�J�K��
�
�f�a��w�c��
�N��
�
�f�a��w�c��
�L��
�
�f�a��w�c��
�M��N�
�I�I�n�,�4�RS�I�T��G�G�$�G������	�#�&�'��I�I�c�N��-/��,s�?I?�%Jc�4�V^8�dQhRRRRRRRRR	R
RRR
R/#)r4rqr(r5r6r\r�rZr$rEr"r�rr7r�r*)r8s"r2r9r93sA����#��*��=����'*��15��:>�r1c
��^RIHpVPRRR7wrx\V4p	V	^8XdVP	V4R#\^V	R,4p
\P!^W�4p\P!VUu.uFq�V,PNK	up4p
VPW�\RRR7VPV\RR	R
VR
2R7VP\V,\RR	\R
\V,R
2R7VP!^VRRRVR2R7VP#^V	4VP%R4VP'R4VP)VRV	R
R24VP+RR^R7VP-RR7VP/4\1WuR4VP	V4R#uupi)r�Nr�r�r��333333�?�
‖r(k)‖)r�r�r�r�gffffff�?uρ = μ + 3σ = r�r�u·ρ = z#2196f3g�������?zhealthy window (k<�))r�r�r�r�r�u) — residual on admissibility envelope (r�r�r�r��r�r�r�r�r��residual_on_enveloper�)r�r�r�r<r�r=r>r�ryr%r�r�r�r�rWr�r�r�r�r�r�r�r�r�r�)rqr5r\rZrEr�r�r�r�rDr�r�rer%s&&&&&&        r2�render_enveloper�3s���#��l�l�:�3�l�7�G�C��C��A��A�v��	�	�#���
��A��I�
�F�
�)�)�A�q�
!�C�
�8�8�#�.�#�Q��V�[�[�#�.�/�D��G�G�C�X�#�\�G�B��J�J�s�'�d�s�<L�S�QT�I�:V�J�W��J�J�}�s�"�'�d�s�%��g�m�c�.A�#�-F�G��I��J�J�q�%�y��>P�QV�PW�WX�<Y�J�Z��K�K��1���M�M�"�#��M�M�,�-��L�L�D�6�B�1�Q�%�~�V�W��I�I�,�4�!�I�<��G�G�$�G������	�#�*�+��I�I�c�N��/s�?G
c�0�V^8�dQhRRRRRRRRR	R
RR/#r�r*)r8s"r2r9r9Ns9��-�-�C�-�J�-�]�-� �-�'+�-�04�-r1c���^RIHp\V4pV^8XdR#VP^^R#RRR7wpwr�\	^VR,4p
\
P!^Wj4p\
P!VUu.uFq�V,PNK	up4p
VPW�\RR7VPV\RR	R
VR
R2R
7W�8�pVPV^W�\RRR7VPR4VPVR24VP!RR^R7VP#RR7VUu.uFq�V,P$NK	pp\'V4FMwppV	P)W�,V
^,,
W�,V
^,,\+V4R^R7KO	V	PW�\RR7V	PV\RRR7V	P\,V,\.RRR7V	P1^V4V	P3R4V	PR4VP5R$^^\6RRR7VP5R$^^\.RRR7VP5R$^^\RR R7.pV	P!VRR^R!7V	P#RR7VP94\;WtR"4VP=V4R#uupiuupi)%z=T1.2: side-by-side incumbent-threshold-alarm vs DSFB grammar.Nr�T)r�r��sharexr�r�r�r�r�u3σ threshold (ρ=r�r�r�r�zincumbent ALARM)�wherer�r�r�r�uZ — incumbent threshold monitor (top) vs DSFB grammar (bottom) on the SAME residual tracer�r�r�r�r�r�r�)r�r�r�r�r�rNr�rPrOr��
comparison)r�g������@r�)r�r�r<r�r=r>r�ryr%r�r�r�r��fill_betweenr�r�r�r�r)rRr�r�rWr�r�r�r�r�r�r�r�)rqr5r\rZr�r�rDr��ax_top�ax_botr�r�rer%�abover�r�r�s&&&&&             r2�render_comparisonr�Ns���$��C��A��A�v���L�L��A�z�s�SW�L�X��C�	�&�
��A��I�
�F�
�)�)�A�q�
!�C�
�8�8�#�.�#�Q��V�[�[�#�.�/�D��K�K���c�K�2�
�N�N�3�g�$�3�-�c�#�Y�a�8��:��J�E�
����Q����/��1�
���l�#�
����v�2�3�4�
�M�M�l�t�a�M�@�
�K�K�d�K��),�,��1�A�����H�,��(�#���1����s�v���
�*�C�F�V�a�Z�,?�&�q�\��!�	�	=�$��K�K���c�K�2�
�N�N�3�g�$�3�N�7�
�N�N�=�3�&�g�$�3�N�G�
�O�O�A�q��
���&�'�
���l�#��
�
�f�a��w�c��
�N��
�
�f�a��w�c��
�L��
�
�f�a��w�c��
�M��N�
�M�M�.�l�t�VW�M�X�
�K�K�d�K������	�#�L�!��I�I�c�N��G/�� -s�4K#�;K(c�(�V^8�dQhRRRRRRRR/#�	r4rqr(r\r�r�rr7r�r*)r8s"r2r9r9~s(��#�#�3�#�]�#��#�$�#r1c��^RIHp^RIHp\	V4pV^8XdR#\^VR,4p\
\^WV44p\P!VUu.uFq�V,PNK	up4p	\P!VUu.uFq�V,PNK	up4p
\P!VUu.uFq�V,PNK	up4pVUu.uFp\W,P4NK 	ppVPRRR7p
V
P!^oRR7pVP#W�W�^R^R	7VP%R
4VP'R4VP)R4VP+VR
\	V4R
RVR
R24VP-^.^.RR\.^RR7VP-^.^.RR\0^RR7VP-^.^.RR\2^RR7.pVP5VRR^	R7V
P74\9W�R4VP;V
4R#uupiuupiuupiuupi)uDT1.4.5: 3D scatter of (‖r‖, ṙ, r̈) coloured by grammar state.N��Axes3Dipr�r��3d��
projectiong�������?��c�sr�r�r�uṙ(k)ur̈(k)u4 — semiotic manifold σ(k) = (‖r‖, ṙ, r̈)
(r�z-point downsample of z& real samples; colour = grammar state)�o�wrN��markerr��markerfacecolor�
markersizer�rPrOr�r�r��semiotic_manifold_3d)g������@g@)r�r��mpl_toolkits.mplot3dr�r<r=�list�ranger>ryr%r&r'r�r)�figure�add_subplot�scatterr�r��
set_zlabelr��Line2Dr�r�r�r�r�r�r�)rqr\r�r�r�rDr��selre�norms�drifts�slews�colsr�r�r�s&&&             r2�render_semiotic_manifoldr~s��#�+��C��A��A�v��
��A��I�
�F�
�u�Q��"�
#�C��H�H�3�/�3�a�!�f�k�k�3�/�0�E�
�X�X�S�1�S��1�v�|�|�S�1�
2�F��H�H�3�/�3�a�!�f�k�k�3�/�0�E�/2�3�s�!�I�c�f�n�n�%�s�D�3�

�*�*�Z�S�*�
1�C�	������	.�B��J�J�u�e�q���J�C��M�M�,���M�M�(���M�M�(���L�L�D�6����X�a�L� 5�a��U�;+�,�-�	�
�
�A�3���C�s�G��|�	�	5��
�
�A�3���C�s�G��z�	�	3��
�
�A�3���C�s�G��{�	�	4��N��I�I�n�,�4�RS�I�T�����	�#�*�+��I�I�c�N��30��1��/��3s�I�I�	I�/$Ic�(�V^8�dQhRRRRRRRR/#r�r*)r8s"r2r9r9�s(��/�/�c�/�
�/�D�/�T�/r1c��^RIHp^RIHp\	V4pVeVP
^8XgV\9dR#\V,wrgp\V4p	V	^8XdR#\W�P^,4p
\^V
R,4p\\^W�44pVPRRR7p
V
P^oRR7pR^R	^R
^/pVFlpW�V,P,p\!VV,P4p\V4F$pVP#VVVVV3,V^R^R7K&	?Kn	VP%R
4VP'R4VP)V4VP+VRVRVR24VP-^.^.RR\.^RR7VP-^.^.RR\0^R	R7VP-^.^.RR\2^R
R7.pVP5VRR^	R7VP7\\V444V
P94\;W�R4VP=V
4R#)u\T1.4 + T1.4.5: per-joint (τ_meas, τ_pred, residual) 3D scatter for arms.

Since we only have the per-joint *residuals* in the processed CSV (not
the raw τ_meas/τ_pred), we instead render per-joint (k, joint_residual,
grammar_severity) as a 3-D scatter — the joint-axis-resolved analogue
that shows which joint carries the residual at each k.
Nr�i�r�r�r�r�rNrPrOg�������?r�r�zjoint indexu' — per-joint residual decomposition
(z, z  joints; colour = grammar state)r�r�r�r�r�r��per_joint_3d)g������ @g������@)r�r�rr�r�r@�ARM_DATASETSr<�min�shaper=rrrrr)r�rr�r�rr�rr�r�r�r��
set_yticksr�r�r�)rqr\r�r�r��pjr��n_joints�unitsrD�n_user�r	r�r��severityre�sev�col�jr�s&&&                  r2�render_per_joint_3dr�s*��$�+�	��	�B�	�z�R�W�W��\�T��%=��)�$�/��E�U��C��A��A�v����8�8�A�;��E�
��E�T�M�
"�F�
�u�Q��&�
'�C�

�*�*�Z�S�*�
1�C�	������	.�B��a��Q��Q�?�H�
���1�v�~�~�&����A����'���x��A��J�J�q�!�R��1��X����!�J�D�!����M�M�"�#��M�M�-� ��M�M�%���L�L�D�6���G�2�h�Z�'G�I�J�	�
�
�A�3���C�s�G��|�	�	5��
�
�A�3���C�s�G��z�	�	3��
�
�A�3���C�s�G��{�	�	4��N��I�I�n�,�4�RS�I�T��M�M�$�u�X��'�(�����	�#�N�#��I�I�c�Nr1c�$�V^8�dQhRRRRRR/#)r4�reports�dictr�rr7r�r*)r8s"r2r9r9�s!����$��T��d�r1c���^RIHpV'gR#\VP44pVUu.uFq@V,R,NK	ppVUu.uFp\PVR4NK	ppVUu.uFp\PVR4NK	ppVPRRR7wr�\P!\V44pV
PW�V\RR7V
PV4V
PV^*R	^R
7V
PRR4V
P!R
4V
P#R\V4R24\P%4UU
u.uFwr�VP'R^^W�R7NK	ppp
V
P)VRR^	R7V
P+RRR7V	P-4\/W�R4VP1V	4R#uupiuupiuupiuup
pi)r�N�compression_ratio�Unknownz#9e9e9er�r�r�)r��	edgecolorr��right)�rotation�har�rMr�z-compression ratio  (reviewed / total samples)z@per-dataset review-surface compression on real-world residuals (z
 datasets))r�r�zupper rightr�r��yr�)�axisr��_all_compression_histogram)g&@g@r�)r�r��sorted�keys�DATASET_FAMILY�get�FAMILY_COLORr�r>r�r<�barr��
set_xticks�set_xticklabels�set_ylimr�r��itemsr�r�r�r�r�r�)r r�r��slugsr��ratios�familiesr�r
r�r��xs�kr��proxiess&&             r2�render_compression_histogramr<�s���#����7�<�<�>�"�E�7<�
=�u�!�a�j�,�-�-�u�F�
=�:?�@�%�Q��"�"�1�i�0�%�H�@�4<�=�H�q�L���Q�	�*�H�D�=��l�l�;�C�l�8�G�C�	���3�u�:�	�B��F�F�2�T�X�#�F�>��M�M�"�����u�r�g���B��K�K��S���M�M�A�B��L�L����Z�L�
�,�-�FR�FX�FX�FZ�[�FZ�d�a�s�}�}�V�Q��a�}�9�FZ�G�[��I�I�g�=�S�1�I�M��G�G��D�G�!�����	�#�0�1��I�I�c�N��%>��@��=��\s�G�G�1G!� G&c�$�V^8�dQhRRRRRR/#)r4�out_dirr�namer(r7r�r*)r8s"r2r9r9�s!��8�8��8�C�8�D�8r1c��VPRRR7WR2,pWR2,pVPVRRR7VPV^�RR7R#)T��parents�exist_okz.pdfz.pngr��tight)r��bbox_inchesN)�mkdir�savefig)r�r>r?�pdf_path�png_paths&&&  r2r�r��sR���M�M�$��M�.��6���&�H��6���&�H��K�K��c�w�K�7��K�K��c�w�K�7r1c� �V^8�dQhRRRR/#)r4r\r�r7r!r*)r8s"r2r9r9�s��
�
�}�
��
r1c���\V4p\RV44p\RV44p\RV44pW4,pRTRTRTRTRV^8�d	WQ,MRR	\R
V4RR7/#)c3�J"�TFqPR8XgK^x�K	R#5i)rNNr���.0�es& r2�	<genexpr>� aggregate_eps.<locals>.<genexpr>�s���
:��A�	�	�\� 9�a�a����#�
#c3�J"�TFqPR8XgK^x�K	R#5i)rPNr�rMs& r2rPrQ�s���
8��A�	�	�Z� 7�a�a��rRc3�J"�TFqPR8XgK^x�K	R#5i)rONr�rMs& r2rPrQ�s���
9��A�	�	�[� 8�a�a��rR�
total_samples�
admissible�boundary�	violationr#rM�max_residual_norm_sqc3�F"�TFqP^,x�K	R#5i)r4N)r%rMs& r2rPrQs���$>�#�Q�V�V�q�[�[�#�s�!)�default)r<ror=)r\rD�adm�bnd�vio�revieweds&     r2�
aggregate_epsr`�s����C��A�

�
:��
:�
:�C�

�
8��
8�
8�C�

�
9��
9�
9�C��y�H����c��C��S��q�1�u�h�l�#���$>�#�$>�� L�
�r1c� �V^8�dQhRRRR/#)r4�argvzlist[str] | Noner7r"r*)r8s"r2r9r9s��E
�E
��E
�3�E
r1c�z�\P!\R7pVPRRRRR7VPR\\
R\
R2R	7VPR
RRR
7VP
V4p^RIp^RIpTPR4TP'd
TPM\pTPP!RRR7.p/pTEFgpT\9d"\RTR2\PR7K0\#T4pTP$^8Xd"\RTR2\PR7Km\'T4wr�\)T4wr�\+T	4p
Y�T&TPT,p\RTRT
R,R
RT
R,R
RT
R,R
RT
R ,R
R!T
R",R#
2\PR7\-YxY�T4\/YxY�Y�4TR69d\1YxY�T4TP2'dEKA\5YyT4T\69gEK[\9YyT4EKj	\;YbP4R$R%R&R'R(R)R*\=TP?44R+R,\@R-\BR.\DR/\F/R0T/pTPR1,PI\JPL!T^RR27R3,4\R4\OT4R5TP2\PR7^# \d \R\PR7^@#i;i)7)�descriptionz--only�+NzSubset of slugs.)�nargsr[�helpz--outzOutput directory (default: z).)�typer[rgz--no-3d�
store_truezSkip 3D scatter plots (faster).)�actionrgzJmatplotlib required: pip install --user --break-system-packages matplotlib)�file�AggTrAz  skip z: not in SLUGS listz: no residualsz[figures_real] z: n=rUz>6dz adm=rVz>5dz bnd=rWz vio=rXz
 compression=r#z.3f�figures_manifest_version�2�sourcezscripts/figures_real.py�modez	real-data�datasets�paramsrTrQ�
boundary_frac�delta_s�
aggregateszFIGURES_MANIFEST.json)�indent�	sort_keys�
z![figures_real] wrote figures for z
 datasets to >rrr)(�argparse�ArgumentParser�__doc__�add_argumentr�DEFAULT_OUT_DIR�
parse_args�
matplotlib�ImportError�print�sys�stderr�use�only�SLUGSr�rFr�r@rkrJr`r�r�r��no_3drrrr<r,r-rTrQrWrX�
write_text�json�dumpsr<)rb�parser�argsrr6�writtenr rqr5r\rZr[rE�aggr>�manifests&               r2�mainr�s���
�
$�
$��
9�F�
�����T�@R��S�
����d�O�:�?�:K�2�N��P�
���	�,�>��@����T�"�D���
��N�N�5������D�I�I��E��H�H�N�N�4�$�N�/��G��G����u���G�D�6�!4�5�C�J�J�G��"�4�(�	��>�>�Q���G�D�6��0�s�z�z�B���I�&���%�i�0����C� ����
��(�(�T�/��
��d�V�4��O�(<�S�'A�B��|�$�S�)��s�:��s�.C�D��{�#�C�(�
�c�:M�6N�s�5S�
U����		
�	 ���7�C����5�B��<�<��d�s��A��z�z�z�$�T��8��|�#�#�D�w�7�7�<!��(�(�3�	#�C��+����F�7�<�<�>�*��3��3��?�M�9�g�V��g�
�H�
�X�X�'�'�3�3��
�
�8�A��6��=��
�-�c�'�l�^�=����
�
S��z�z����u��
�Z��:�:�	���s�<L�&L:�9L:�__main__)r	r
rrr
rrrrrrrrrrrrrrr)zKUKA LWR-IV+ (Simionato 7R)�ujoint accel residual (m/s²))zFranka Panda (Gaz 2019)r��torque deviation (N·m))z!Panda DLR-class (Giacomuzzo 2024)r�uτ_meas − τ_interp (N·m))zUR10 (Polydoros 2015)�r�)N)1r{�
__future__rryr|r�r��dataclassesr�pathlibr�numpyr>�__file__�resolve�parent�
CRATE_ROOTrwr}rTrQrWrXr�rr�r�r�r�r0r.r!rJrkrYr�r�r�r�r�r�rrr<r�r`r�r+�exitr*r1r2�<module>r�s;��(�T#��
��
�!����(�^�
#�
#�
%�
,�
,�
3�
3�
��V�#�k�1�
��w�&��2�������
�
��	��4�R��J��Z��K�	����
��
����
�9��)�����	��L�	�">��	���	�/B�L�	��k�	�$.�{�	�=C�E�	��,�		�!(��		�8B�5�		�
��	�
&9�+�	�
�5�
	��l�
	�-;�L�
	��\�	�'��	�7>�|��+�~�|�	�������#�@�F�+�4I��!�H�6-�`#�L/�d�48�
�&E
�P�z���H�H�T�V��r1