+
    =Rj                         R t ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIH	t	H
t
 ^ RIHtHt ^<tR t]R8X  d
   ]! 4        R# R# )u  Back-drive calibrated Feetech servos and mirror them live in the MuJoCo viewer.

Drives only the servos that are BOTH calibrated (in calib/<config>.json) AND currently
responding on the bus — so a partially-connected/partially-calibrated arm just works,
with a note on what's live vs missing. Torque is disabled so you can move the joints by
hand and watch the sim follow. Read-only: it never commands the servos.

Usage:
  python live_mirror.py --config arm [--port /dev/tty...] [--rate 40] [--model PATH]
N)Busticks_to_rad)CONFIGS
calib_pathc                  \   \         P                  ! 4       p V P                  R RR7       V P                  RRR7       V P                  R\        RR7       V P                  RRR	R
7       V P	                  4       p\
        VP                  ,          pVP                  ;'       g
    VR,          p\        VP                  4      p \        P                  ! \        V4      4      pX'       g   \        P                  ! V R24       \        P                   P#                  V4      p\        P$                  ! V4      p. p. p	\'        VP)                  4       R R7       F  w  r\        P*                  ! V\        P,                  P.                  VR,          4      pV^ 8  d   V	P1                  WR,          34       K^  VP1                  \3        V
4      \3        VP4                  V,          4      \3        VR,          4      VR,          34       K  	  V'       g8   \        P                  ! R\6        P8                  P;                  V4       R24       VP<                  '       d   \?        VP<                  4      M	\?        4       p. . rV F4  pVPA                  V^ ,          4      '       d   TMTP1                  V4       K6  	  \C        VPD                  4       Uu. uFn  p\3        VPF                  V,          4      \        PH                  PJ                  8X  g   K>  \        PL                  ! V\        P,                  P.                  V4      NKp  	  ppV Uu0 uF  pV^,          kK  	  ppV Uu. uF  pVV9  g   K  VNK  	  pp\O        R\6        P8                  P;                  V4       24       \O        R\Q        V4       R24       V F  w  p
ppp\O        RV
R RV RVR R24       K!  	  V'       d9   \O        R\Q        V4       R24       V F  w  p
 pp\O        RV
R RV 24       K  	  V'       d   \O        R V 24       V	'       d   \O        R!V	 24       V'       g'   VPS                  4        \        P                  ! R"4       V F  w  p
  pVPU                  V
R#4       K  	  R$VPV                  ,          p^ p \        PX                  P[                  Wg4      ;_uu_ 4       p\O        R%4       VP]                  4       '       Ed;   \^        P`                  ! 4       pV F8  w  p
pppVPc                  V
4      pVf   K  \e        VV4      VPf                  V&   K:  	  \        Ph                  ! Wg4       VPk                  4        V\3        \m        ^VPV                  4      4      ,          ^ 8X  dH   V FA  w  p
 ppVPo                  V
4      pVf   K  V\p        8  g   K,  \O        R&V
 R'V R(V R)24       KC  	  V^,          p\^        P`                  ! 4       V,
          p V V8  g   EK1  \^        Pr                  ! VV ,
          4       EKQ   RRR4       VPS                  4        R#   \         d    \        P                  ! RT R24        ELi ; iu upi u upi u upi   + '       g   i     L]; i  TPS                  4        i ; i)*z--configgripper)defaultz--portNz--rateg      D@)typer   z--modelz'Override the config's MuJoCo model path)r   helpmodelzNo calibration at z. Run calibrate_servo.py first.z( is empty. Run calibrate_servo.py first.c                 &    \        V ^ ,          4      # )    )int)kvs   &live_mirror.py<lambda>main.<locals>.<lambda>2   s    s2a5z    )keyjointsignz'None of the calibrated joints exist in .zModel: zLIVE + calibrated (u   ) — driven by hand:z
    servo z>2z -> z  (sign z+d)z	MISSING (u2   ) — calibrated but not responding, held at rest:u!   NOT CALIBRATED — held at rest: u'   IN CALIB BUT NOT IN MODEL — ignored: u:   No calibrated servos are responding — nothing to mirror.Fg      ?uS   
Move a live joint by hand — the sim follows. Close the viewer or Ctrl-C to stop.z  warning: servo z (z) = C):argparseArgumentParseradd_argumentfloat
parse_argsr   configr   r   jsonloadopenFileNotFoundErrorsysexitmujocoMjModelfrom_xml_pathMjDatasorteditems
mj_name2idmjtObjmjOBJ_JOINTappendr   jnt_qposadrospathbasenameportr   pingrangenjntjnt_typemjtJointmjJNT_HINGE
mj_id2nameprintlenclosetorquerateviewerlaunch_passive
is_runningtimeperf_counterread_posr   qpos
mj_forwardsyncmax	read_tempTEMP_WARN_Csleep)!apacfg
model_pathr2   calibr   dataentriesnot_in_modelsidcjidbuslivemissingei
all_hingescoveredjuncalibrated_sgnjnperiodframerA   t0adrpostmpdts!                                    r   mainrl      sJ   		 	 	"BOOJ	O2OOHdO+OOH5$O7OOIt2[O\
A
!((
C((CLJahhDM		$t*% D6ABCNN((4E==D GL,ABv}}'@'@!G*M7j 12C#e&7&7&<"=s1V9~qQXzZ[ C :277;K;KJ;W:XXYZ[ #aff+SUC'!A$W44Q7  !,g,aENN14E0F&//JeJe0e I&##E6==+D+DaH,  g$%WqttWG%)>z!Qg-=AAzL>	GBGG$$Z01
23	D	{*?
@AQR
3r($rd(3r(!<=  	#g,'YZ[$MCArJs2hd2$/0 %1,@A7~FG		MNQ1

3  166\FE]]))%66&hi##%%&&((,$Cc1,,s+C{ %1#s%;DIIcN	 )-
 !!%.3s1aff~..!3)-Q2!mmC0?sk/A!$5cU"RDSE"KL *. 
&&(2-;JJv{+# & 7* 			U  M%dV+JKLM4g%>0 76* 			sn   Y ;Y74Y7Y<	Z,Z,'Z "Z6C Z;ZAZ Z1Z %Y43Y4Z	Z Z+__main__)__doc__r   r    r1   r$   rD   r&   mujoco.viewerfeetech_busr   r   configsr   r   rL   rl   __name__ r   r   <module>rt      sG   	   	 
    ) 'Wt zF r   