
    ni                         S r SSKrSSKJrJrJrJr  SSKJr  SSK	r	SSK
Jr  SSK
Jr  SSK
Jr  SSK
Jr  \	R                   " S	 S
\R                   5      5       rg)z&Pybullet simulation of Minitaur robot.    N)DictTupleUnionText)logging)minitaur_constants)quadruped_base)robot_config)robot_urdf_loaderc                   X    \ rS rSrSrS rS r  S
S\\\	   \
\\	4   4   S\4S jjrS	rg)Minitaur   z&Minitaur simulation model in pyBullet.c                     [         R                  " S5      nU(       a  [        R                  " S5        [
        R                  " U R                  S[        R                  [        R                  [        R                  [        R                  [        R                  [        R                  [        R                  [        R                   [        R"                  [        R$                  S9U l        g ! [         a    Sn Nf = f)Nz2robot_urdf_loader.RobotUrdfLoader.constrained_baseFzQuse_constrained_base is currently not compatible with Minitaur's leg constraints.T)pybullet_clientenable_self_collision	urdf_pathinit_base_position init_base_orientation_quaternioninit_base_orientation_rpyinit_joint_anglesjoint_offsetsjoint_directionsmotor_namesend_effector_names
user_group)ginquery_parameter
ValueErrorr   warnr   RobotUrdfLoader_pybullet_clientr   MINITAUR_URDF_PATHINIT_POSITIONINIT_ORIENTATION_QUATINIT_ORIENTATION_RPYINIT_JOINT_ANGLESJOINT_OFFSETSJOINT_DIRECTIONSMOTOR_NAMESEND_EFFECTOR_NAMESMOTOR_GROUP_urdf_loader)selfuse_constrained_bases     c/home/james-whalen/.local/lib/python3.13/site-packages/pybullet_envs/minitaur/robots/minitaur_v2.py	_pre_loadMinitaur._pre_load   s    # 00
>@ ll
 *99--"$77-;;);		"4"I"I,>>(66+<<&22-@@%11D  #"#s   C0 0C?>C?c                    [         R                  S-  nSn[        [        R                  5       GH  u  p4U R
                  R                  U R                  R                  U R                  SU-   S-      U R                  SU-     U-  SS9  U R
                  R                  U R                  R                  U R                  SU-   S-      U R                  SU-     U-  SS9  U R
                  R                  U R                  R                  U R                  SU-   S	-      U R                  SU-  S
-      U-  SS9  U R
                  R                  U R                  R                  U R                  SU-   S	-      U R                  SU-  S
-      U-  SS9  US:  a  U R
                  R                  U R                  R                  U R                  SU-   S	-      U R                  R                  U R                  SU-   S-      U R
                  R                  / SQ[        R                  [        R                  5        GM  U R
                  R                  U R                  R                  U R                  SU-   S	-      U R                  R                  U R                  SU-   S-      U R
                  R                  / SQ[        R                  [        R                  5        GM     U R                  5         g)zEAdd hinge constraint for Minitaur's diamond shaped leg after loading.g       @gPkwmotor_L_joint   r   )targetVelocityknee_R_joint   )r   r   r   N)mathpi	enumerater   	LEG_ORDERr!   resetJointStater,   robot_id_joint_id_dict_motor_directionscreateConstraintJOINT_POINT2POINTKNEE_CONSTRAINT_POINT_SHORTKNEE_CONSTRAINT_POINT_LONGreceive_observation)r-   half_pi
knee_angleleg_idleg_positions        r/   _on_loadMinitaur._on_load/   s   ggmGJ"+,>,H,H"I
++



$
$


h5	A
B

 
 V
,w
6	 , 
 ++



$
$


g4y@
A

 
 V
,z
9	 , 
 ++



$
$


h5	A
B

 
 Va
07
:	 , 
 ++



$
$


g4y@
A

 
 Va
0:
=	 ,  
!..&&, 6 BC&&, 6 BC!!33Y::99	; 	..&&, 6 BC&&, 6 BC!!33Y99::	<A #JP 	    Njoint_anglesnum_reset_stepsc                 n   Uc  [         R                  nUn[        U[        5      (       a"  [         R                   Vs/ s H  nX   PM	     nn[        U5       HU  nU R                  U[        R                  R                  S9  U R                  R                  5         U R                  5         MW     gs  snf )af  Resets joint angles of the robot.

Note that since Minitaur has additional leg constraints on the end
effectors, directly setting joint angles will lead to constraint violation.
Instead, we apply motor commands to move the motors to the desired position.

Args:
  joint_angles: the desired joint angles to reset to.
  num_reset_steps: number of reset steps.
N)motor_control_mode)r   r&   
isinstancedictJOINT_NAMESrangeapply_actionr
   MotorControlModePOSITIONr!   stepSimulationrF   )r-   rN   rO   actions
joint_name_s         r/   _reset_joint_anglesMinitaur._reset_joint_angles]   s     '99lG,%% /:::j 
":   ?#

l&C&C&L&L  N
**,
 	 $s   B2)r,   )Nd   )__name__
__module____qualname____firstlineno____doc__r0   rK   r   r   floatr   r   intr]   __static_attributes__ rM   r/   r   r      s\    .8,` LP14!(-eElDAFBG =H /H )I! ,/! !rM   r   )rd   r:   typingr   r   r   r   abslr   r   pybullet_envs.minitaur.robotsr   r	   r
   r   configurableQuadrupedBaser   rh   rM   r/   <module>rn      sM    ,  + +  
 < 8 6 ; j!~++ j! j!rM   