o
    wi                     @   s^   d Z ddlZddlmZ ddlmZmZ dZdZ	e	 dZ
eG dd	 d	ZG d
d dZdS )z)Base exoskeleton configuration framework.    N)	dataclass)DictTuplez../../so100_blender_testingszrobot_models/so100_modelz/../board_imgsc                   @   sb   e Zd ZU dZeed< eed< eed< eed< ejed< ejed< eed< eed	< d
Z	e
ed< d
S )
LinkConfigz8Configuration for a single robot link with ArUco marker.mujoco_namepybullet_namerobot_mesh_pathexo_mesh_patharuco_offset_posaruco_offset_rotaruco_board_nameboard_lengthNplane_scale)__name__
__module____qualname____doc__str__annotations__npndarrayfloatr   tuple r   r   N/data/cameron/para/panda_streaming/hand_eye_calib/../ExoConfigs/exoskeleton.pyr      s   
 

r   c                   @   s   e Zd ZU dZdZeed< dZeed< dZeed< dZ	eed	< i Z
eeef ed
< dZeed< dZeed< i Zeeef ed< dZeed< dZeed< dZeed< dd ZdefddZdS )ExoskeletonConfigzCBase configuration class for robots with ArUco marker exoskeletons.ZRobotname base_xml_pathz'robot_models/so100_model/background.xmlbackground_xml_pathz./compiler_meshdiraruco_boardsg
ףp=
?board_length_smallgRQ?board_length_largelinksg333333?	exo_alphag?exo_link_alphag      ?aruco_alphac                 C   s   |   | _dS )zInitialize and generate XML.N)_generate_xmlxml)selfr   r   r   __init__0   s   zExoskeletonConfig.__init__returnc                 C   s  d| j  d| j d| j d}| j D ]$\}}|jdr dnd}|d| d|j d	| d
|j d| d7 }q|dt dt dt dt dt d7 }| j	 D ]\}}|d| d| d| d| d	7 }qR|d7 }| j D ]{\}}|j
dur|j
\}}| d}	|dd|	 dt d|dd |dd!	d"}n'|jd#krd$}
n|jd%krd&}
n|jd'krd(}
n
|jd)krd*}
nd+}
d,|
 }	|d-| d.| d/| d0| j d1| d2| d3| j d1| d4|	 d5|j d6| j d77 }qq|d87 }|S )9z@Generate complete MuJoCo XML with exoskeletons and ArUco planes.z?<mujoco>
                    <compiler angle="radian" meshdir="z'"/>
                    <include file="zq"/>
                    <visual> <global offheight="4100" offwidth="4100"/> </visual>
                    <asset>z.stlz scale=".001 .001 .001"r   z!
                    <mesh name="z_link_stl" file="z4" inertia="shell"/>
                    <mesh name="z_exo_stl" file=""z inertia="shell"/>z%<mesh name="aruco_plane_small" file="zm/plane.obj" scale="0.15 0.15 .001" inertia="shell"/>
                   <mesh name="aruco_plane_large" file="z}/plane.obj" scale="0.3166666 0.3166666 .001" inertia="shell"/>
                   <mesh name="aruco_plane_even_larger" file="zt/plane.obj" scale="0.475 0.475 .001" inertia="shell"/>
                   <mesh name="aruco_plane_5x5_larger" file="zt/plane.obj" scale="0.597 0.597 .001" inertia="shell"/>
                   <mesh name="aruco_plane_6x6_larger" file="z6/plane.obj" scale="0.718 0.718 .001" inertia="shell"/>z 
                <texture name="z_tex" type="2d" file="z$"/>
                <material name="z_mat" texture="z_tex" rgba="1 1 1 1"/>z </asset>
                <worldbody>
                    <camera name="estimated_camera" pos="0 0 0" quat="1 0 0 0" fovy="95"/>
                NZ_aruco_planez</asset>z<mesh name="z" file="z/plane.obj" scale="z.6f z4 .001" inertia="shell"/>
                   </asset>   gRQ?Z
6x6_largergףp=
?Z
5x5_largerg)\(?Zeven_largerg?largesmallZaruco_plane_z
                    <!-- z2 -->
                    <body mocap="true" name="z9_link_mesh">
                    <geom type="mesh" mesh="z3_link_stl" contype="0" conaffinity="0" rgba="0 0 1 zN" />
                    </body>
                    <body mocap="true" name="z8_exo_mesh">
                    <geom type="mesh" mesh="z2_exo_stl" contype="0" conaffinity="0" rgba="0 1 0 z9_exo_plane">
                    <geom type="mesh" mesh="z(" contype="0" conaffinity="0" material="z_mat" rgba="1 1 1 z1" />
                    </body>
                z  </worldbody> </mujoco>)r    r   r   r$   itemsr	   endswithr   BLENDER_STL_DIRr!   r   replacer   r&   r%   r   r'   )r*   r)   r   cfgZ	exo_scaleZ
board_nameZimg_pathsxsyZplane_mesh_nameZ
plane_sizer   r   r   r(   4   s   




&




			zExoskeletonConfig._generate_xmlN)r   r   r   r   r   r   r   r   r   r    r!   r   r"   r   r#   r$   r   r%   r&   r'   r+   r(   r   r   r   r   r      s   
 r   )r   numpyr   dataclassesr   typingr   r   r4   SO100_MODEL_DIRBOARD_IMG_DIRr   r   r   r   r   r   <module>   s    
