
    nit                        S r SSKrSSKrSSKrSSKJrJrJrJrJ	r	J
r
Jr  SSKJr  SSKrSSKrSSKrSrSr\
\R(                  \R(                  \\	\4   4   rSr " S S	\R.                  S
9r\R2                   " S S\5      5       r\R2                   " S S\5      5       r " S S\R8                  5      r\R<                   " S S5      5       r\R2                   " S S\5      5       r \R2                   " S S\ 5      5       r!\R2                   " S S\5      5       r"\R2                   " S S\5      5       r#\R2                   " S S\5      5       r$\R2                   " S S\5      5       r%g)z-Module for controllers of autonomous objects.    N)AnyDictOptionalSequenceTextTupleUnion)loggingg      g-C6?animation_frame_numberc                   V    \ rS rSrSr\R                  S\S\\	\
4   S\4S j5       rSrg)	ControllerBase   a%  Base class of object controllers.

Controller is similar to a policy in that its output controls autonomous
object just as policy output controls agent. To reflect this similarity,
get_action(), the function that "commands" to autonomous object, is named
similar to the counterpart in policy.
time_secobservationsreturnc                     g)aY  Returns position, orientation and pose based on time and observations.

Args:
  time_sec: Time since simulation reset in seconds. If time < 0, returns
    initial values and ignores observations.
  observations: A dict of all observations.

Returns:
  Position, orientation and an extra info dict for robot joints, human
    skeletal pose, etc.
N )selfr   r   s      i/home/james-whalen/.local/lib/python3.13/site-packages/pybullet_envs/minitaur/robots/object_controller.py
get_actionControllerBase.get_action#   s        r   N)__name__
__module____qualname____firstlineno____doc__abcabstractmethodfloatr   r   r   ControllerOutputr   __static_attributes__r   r   r   r   r      sA      #D#I3C r   r   )	metaclassc                   ^    \ rS rSrSr  SS\\   S\\   4S jjrS\S\\	\
4   S	\4S
 jrSrg)StationaryController4   z8Controller that keeps constant position and orientation.Npositionorientationc                     [         R                  " Ub  UOS5      U l        [         R                  " Ub  UOS5      U l        g )Nr   r   r   r   r   r      )nparray	_position_orientation)r   r'   r(   s      r   __init__StationaryController.__init__8   s7     XX(*>hINDN".LBDr   tr   r   c                 8    AAU R                   U R                  0 4$ )z&Returns constant position orientation.)r/   r0   r   r3   r   s      r   r   StationaryController.get_action?   s      	
<>>4,,b00r   )r0   r/   )NN)r   r   r   r   r   r   r    r1   r   r   r   r!   r   r"   r   r   r   r%   r%   4   sR    @ ,0.2B!%B$UOB11#D#I13C1r   r%   c            	       t    \ rS rSrSr\R                  S4S\\   S\S\S\	4S jjr
S	\S
\\\4   S\4S jrSrg)CircularMotionControllerG   zeController for circular motion.

The motion trajectory goes around a center in a circle in xy-plane.
Fcenterradiusangular_velocityface_travel_directionc                 ^    [         R                  " U5      U l        X l        X0l        X@l        g)a,  Constructor.

Args:
  center: Center of circular motion, [x, y, z] in meters.
  radius: Radius of the circle in meters.
  angular_velocity: Angular velocity of motion, unit rad/s, e.g. pi means
    completing a circle in 2 sec.
  face_travel_direction: If True, object will face direction of motion.
N)r-   r.   _center_radius_angular_velocity_face_travel_direction)r   r:   r;   r<   r=   s        r   r1   !CircularMotionController.__init__N   s%     88F#DLL-"7r   r3   r   r   c           	      v   A[        SU5      n[        R                  " [        R                  " U R                  U-  5      [        R
                  " U R                  U-  5      S/5      U R                  -  U R                  -   nU R                  (       a  U R                  U-  [        R                  " U R                  5      [        R                  -  S-  -   n[        R                  " SS[        R
                  " US-  5      [        R                  " US-  5      45      nO[        R                  " S5      nX50 4$ )zFReturns position on the circle based on time and constant orientation.        r      r+   )maxr-   r.   cosrA   sinr@   r?   rB   signpi)r   r3   r   r'   yawr(   s         r   r   #CircularMotionController.get_actionb   s     	CAxx	&&*	+	&&*	+	
	 || #ll+H """"Q&
''$((
)BEE
1A
57cHHaBFF37ORVVC!G_EFkHH\*k"$$r   )rA   r?   rB   r@   N)r   r   r   r   r   r-   rK   r   r    boolr1   r   r   r   r!   r   r"   r   r   r   r8   r8   G   se     *,-2	888 "'8 '+	8(%%#D#I%3C%r   r8   c                   (    \ rS rSrSrSrSrSrSrSr	g)	PatrolRepeatModev   zEEnums that defines trajectory repeat mode for patrol type controller.r   r,   rF      r   N)
r   r   r   r   r   	NO_REPEATLOOP
BACK_TRACKRESETr"   r   r   r   rP   rP   v   s!    M ) 
$ *
 %r   rP   c                   ~    \ rS rSr% Sr\\S'   \R                  \S'   \R                  \S'   \R                  \S'   Sr	g)	PatrolSegmentData   z-A data class that describes a patrol segment.
start_timestart_positionvelocityr(   r   N)
r   r   r   r   r   r    __annotations__r-   ndarrayr"   r   r   r   rX   rX      s1    5  ** JJ zzr   rX   c                       \ rS rSrSrSS\R                  SS4S\\\      S\S	\	S
\
\\4   S\\   S\\\      4S jjrS rS rS rS rS\S\\\4   S\4S jrSrg)WayPointPatrolController   z1Controller for patrolling along define waypoints.r   T      ?Npoints	yaw_angler=   repeat_mode	speed_mpstime_pointsc                    [        U[        5      (       a  UO[        U   U l        X l        X0l        XPl        [        U5      S:  a  [        S[        U5       35      eUb(  U R                  [        R                  L a  [        S5      eU R                  [        R                  L d  U R                  [        R                  L a  UnUb  UnOU R                  [        R                  L a  [        U5      US   /-   nOU R                  [        R                  L ad  [        U5      [        [        USS 5      5      -   nUb=  [        U5      [        US   US   [        R                  " USSS2   5      -
  -   5      -   nO[!        SU R                   S	35      e[        R                  " U5      nUR"                  S   S:X  a:  [        R$                  " U[        R&                  " UR"                  S   S5      5      nOUR"                  S   S
:w  a  [        S5      eSn	/ U l        UcK  [+        USS USS 5       H4  u  pU R-                  XU	5      u  pU R(                  R/                  U5        M6     OY[+        USS USS WSS USS 5       H;  u  ppU R1                  XU	XU-
  -   5      u  pU R(                  R/                  U5        M=     U R(                   Vs/ s H  oR2                  PM     snU l        Xl        gs  snf )a}  Constructor.

Args:
  points: List of waypoints, shape Nx3 or Nx2, N is number of points.
  yaw_angle: Yaw angle of the object in radians.
  face_travel_direction: If True, yaw angle 'zero' will be redefined to be
    object's travel direction. Setting yaw_angle to zero with
    face_travel_direction == True will results in object always facing its
    travel direction. Non-zero yaw_angle will cause additional yaw offsets.
  repeat_mode: Behavior of object after reaching the last way point in list.
    If the value is Text, it is converted to PatrolRepeatMode.
  speed_mps: Speed in meters per second.
  time_points: List of times associated with points. These times
    represent when the object should arrive at the associated waypoint.
    Optional, but if provided it must have the same length as 'points'.
    If 'speed_mps' is None, then 'time_points' will be used as-is and there
    is no maximum segment speed. If 'speed_mps' is also defined, then it
    serves as a maximum speed value and time points which would result in a
    segment speed above this value will be altered such that the maximum
    segment speed is 'speed_mps'.
rF   z*Need at least two points in 'points', got Nz.Time points are not compatible with LOOP mode.r   r,   zRepeat mode z is not supported yet.rR   z!Expect 'points' to be Nx2 or Nx3.)
isinstancerP   _repeat
_yaw_anglerB   
_speed_mpslen
ValueErrorrT   rS   rV   listrU   reversedr-   r.   NotImplementedErrorshapehstackzeros	_segmentszip_get_patrol_segment_by_speedappend_get_patrol_segment_by_timerZ   _segment_times_cycle_time)r   rc   rd   r=   re   rf   rg   augmented_pointsaugmented_time_pointsr3   
from_pointto_pointsegment	from_timeto_timels                   r   r1   !WayPointPatrolController.__init__   s   : $.k;K#L#LK)+6 	LO"7O
6{Q6s6{m
DF F 4<<3C3H3H#HGHH(222(...		  +	)..	.f3	)44	4fXfSbk-B(CC		 
 !%[ 1RKObhh{15b5?Q6R$RST!U  &<
=? ? xx 01a A%
BHH%5%;%;A%>BD				"a	':;;	ADN"%
3B
!1!"!5#7
*66zQO
g&#7
 7:
3B
!1!"!5

$&;AB&?7A
2*	 55jA67Y;N6OQ
g&7A 26@A<<@D As   K8c                    U R                  X5      u  pVU R                  U5      n[        R                  " XC5      (       a  SnO6XdU-
  -  nU R                  b"  [        R
                  " U R                  U/5      n[        R                  " SU5      (       a  Un	O[        R                  " XCXh-  -   /5      n	[        U[        R                  " U5      XX-  US9n
X4$ )z;Returns a PatrolSegmentData for the given points and times.r   rZ   r[   r\   r(   )	_get_vector_get_orientationr-   iscloserm   minrG   rX   r.   )r   r   r   r   r   unit_vectorlengthr(   rf   new_to_timer   s              r   rz   4WayPointPatrolController._get_patrol_segment_by_time   s     **:@K''4K	zz'%%ii/0i		$FFDOOY78		zz!YkFFG&2D%EFGkxx
+(	!G r   c                     U R                  X5      u  pEU R                  U5      n[        U[        R                  " U5      X@R
                  -  US9nX5U R
                  -  -   nXx4$ )zFReturns a PatrolSegmentData for the given points and a constant speed.r   )r   r   rX   r-   r.   rm   )	r   r   r   current_timer   r   r(   r   times	            r   rx   5WayPointPatrolController._get_patrol_segment_by_speed  sf    **:@K''4Kxx
+.	!G
 4??22D=r   c                     [         R                  " U5      [         R                  " U5      -
  n[         R                  R                  U5      nUS:X  a  [	        SU SU S35      eX4-  nXT4$ )z8Gets the unit vector and length of a from/to point pair.r   z*Length of patrol segment equal to 0, from z to .)r-   r.   linalgnormro   )r   r   r   vectorr   r   s         r   r   $WayPointPatrolController._get_vector(  sk    XXh"((:"66FYY^^F#F{ )l$xj; < </Kr   c           	         U R                   (       a  [        R                  " US   US   5      OSU R                  -   n[        R                  " SS[        R
                  " US-  5      [        R                  " US-  5      45      nU$ )z4Gets the orientation quaternion given a unit vector.r,   r   rF   )rB   r-   arctan2rl   r.   rI   rH   )r   r   rL   r(   s       r   r   )WayPointPatrolController._get_orientation4  sm     )) ::k!nk!n5/0DOODC ((Aq"&&q/266#'?CDKr   r3   r   r   c                    A[        SU5      nXR                  :  aI  U R                  [        R                  L a  U R                  O[
        R                  " XR                  5      nU R                  [        R                  " U R                  U5      S-
     nUR                  UR                  XR                  -
  -  -   nXCR                  R                  5       0 4$ )z>Returns position on, and orientation along the patrol segment.r   r,   )rG   r|   rk   rP   rS   r-   fmodrv   bisectbisect_rightr{   r[   r\   rZ   r(   copy)r   r3   r   r   r'   s        r   r   #WayPointPatrolController.get_action=  s     	 	Aq	A#||/?/I/II4++,  nnV001D1DaH1LMG!1!1Q9K9K5K!LL  ((--/33r   )r|   rB   rk   r{   rv   rm   rl   )r   r   r   r   r   rP   rS   r   r    rN   r	   r   r   r1   rz   rx   r   r   r   r   r!   r   r"   r   r   r   r`   r`      s    9 #$-1-=-G-G,/8<Z0ZZ '+Z "#T)+	Z #5/Z %Xe_5Zx <
44#D#I43C4r   r`   c                   D   ^  \ rS rSrSrS\\   S\\   4U 4S jjrSrU =r	$ )LinearPatrolControlleriQ  z@Controller for patrolling along a line segment (back and forth).r   r   c                 J   > [         TU ]  " X/4S[        R                  0UD6  g)zConstructor.

Args:
  from_point: Starting point of motion, [x, y, z] in meters.
  to_point: Returning point of motion, [x, y, z] in meters.
  **kwargs: Keyword arguments to pass onto base class.
re   N)superr1   rP   rT   )r   r   r   kwargs	__class__s       r   r1   LinearPatrolController.__init__U  s-     
Gj+ !1!6!6r   r   )
r   r   r   r   r   r   r    r1   r"   __classcell__)r   s   @r   r   r   Q  s(    H#E?!% r   r   c                   r    \ rS rSrSr    SS\S\S\\   S\\   S\S\4S	 jjr	S
\S\
\\4   S\4S jrSrg)ChaseControllerif  zBController for an object to chase another object at certain speed.self_key
target_keyinitial_positioninitial_orientationrf   verbosec                     [         R                  " U5      U l        [         R                  " U5      U l        U R                  U l        US::  a  [        SU S35      eXPl        Xl        X l        X`l	        SU l
        g)a  Constructor.

Args:
  self_key: Observation dict key of position of object being controlled.
  target_key: Observation dict key of position of target object.
  initial_position: Initial position of the object.
  initial_orientation: Initial orientation of the object in xyzw quaternion.
  speed_mps: Speed in meters per second, always positive.
  verbose: If True, log details of get_action() calculation for debugging.
r   z,'speed_mps' should be a positive value, got r   N)r-   r.   _init_position_init_orientation_previous_orientationro   rm   	_self_key_target_key_verbose	_time_sec)r   r   r   r   r   rf   r   s          r   r1   ChaseController.__init__j  st    " ((#34DXX&9:D!%!7!7DA~81
EG GON!MDNr   r   r   r   c                    US:  a<  SU l         U R                  R                  5       U R                  R                  5       0 4$ X R                     nX R
                     nXC-
  S-  nXR                   -
  nXl         U R                  (       ap  [        R                  " SSS9   [        R                  " SU R                  U R                  X R                     U R
                  X R
                     XV5        SSS5        [        R                  R                  U5      nU[        :  a+  UR                  5       U R                  R                  5       0 4$ XW-  nU[!        U R"                  U-  U5      -  U-   n	[        R$                  " US   US   5      n
[        R&                  " SS[        R(                  " U
S	-  5      [        R*                  " U
S	-  5      45      nXl        XR                  5       0 4$ ! , (       d  f       GN= f)
zReturns position and orientation of the object being controlled.

Args:
  time_sec: Time since simulation reset in seconds. If time < 0, returns
    initial values and ignores observations.
  observations: A dict of all observations.
r   r,   r,   r   rR   T)	precisionsuppressz5t = %.1f, self %s: %s, target %s: %s, v: %s, dt %.1f.Nr,   rF   )r   r   r   r   r   r   r   r-   printoptionsr
   info_tr   r   _EPS_DISTANCEr   r   rm   r   r.   rI   rH   )r   r   r   self_positiontarget_positiondelta_vectordelta_tdistanceunit_delta_vectornew_positionnew_yawnew_orientations               r   r   ChaseController.get_action  s    !|dn  %%')?)?)D)D)FJJ 0M"#3#34O $3y@L'G N}}??Q6LWW^^\..%A%%|4D4D'E!		, 7 yy~~l+H-!!#T%?%?%D%D%FJJ$/%DOOg,Ex(PP#$L jj*1-/@/CDGhh1bffWq[&9266'A+;NOPO!0--/33) 76s    AG//
G>)r   r   r   r   rm   r   r   r   N)r*   r+   rb   F)r   r   r   r   r   r   r   r    rN   r1   r   r   r!   r   r"   r   r   r   r   r   f  s}    J
 4=6B"%$ "*% %-UO	
   >.4 .4#D#I.43C.4r   r   c                   f    \ rS rSrSr   SS\S\S\4S jjrS\4S jrS	\S
\	\
\4   S\4S jrSrg)AnimationFrameControlleri  zEAn extra action controller to control playback of animation sequence.fpspause_between_repeat_secstart_time_secc                 6    Xl         SU l        X l        X0l        g)zConstructor.

Args:
  fps: Frame per second of animation.
  pause_between_repeat_sec: Pause between repeat in second.
  start_time_sec: The time when animation starts to play.
N)_fps_total_length_pause_between_repeat_sec_start_time_sec)r   r   r   r   s       r   r1   !AnimationFrameController.__init__  s     ID%=")r   total_lengthc                 :    US::  a  [        SU S35      eXl        g)z"Sets total animation frame length.r   z(Total number of frame must be >= 0, got r   N)ro   r   )r   r   s     r   set_total_length)AnimationFrameController.set_total_length  s+    q4\N!
DF F%r   r   r   r   c                 |   [        SXR                  -
  5      n[        XR                  -  5      nU R                  (       aJ  UU R                  [        U R
                  U R                  -  5      -   -  n[        X0R                  S-
  5      n[        R                  " S5      [        R                  " S5      [        U04$ )zReturns animation frame number with default position and orientation.

Args:
  time_sec: Time since simulation reset in seconds. If time < 0, returns
    initial values and ignores observations.
  observations: A dict of all observations.
r   r,   r*   r+   )
rG   r   intr   r   r   r   r-   r^   ANIMATION_FRAME_NUMBER_KEY)r   r   r   frames       r   r   #AnimationFrameController.get_action  s     1h!5!556H99$%E


s4#A#ADII#MN
NPe%++a/0e::i "**\":"E=+ + +r   )r   r   r   r   N)g      $@rE   rE   )r   r   r   r   r   r    r1   r   r   r   r   r   r!   r   r"   r   r   r   r   r     s[    M"&14'**% *).*$*&3 &+ +#D#I+3C+r   r   c                       \ rS rSrSr     SS\S\S\\   S\\   S\\   S	\S
\4S jjrS r	S r
S rS rS\S\\\4   S\4S jrSrg)ConversationControlleri  af  Controller for an object that mimics conversational behavior.

A controlled object is arrayed in a conversation about a center point.
When a target object reaches a thresholded distance away from the center,
the controlled object will face the target object and move away from
the target's intended path along an orthogonal direction vector until it
passes.
Nr   r   r'   r(   conversation_centerproximity_thresholdrf   c                 (   Xl         X l        [        R                  " U=(       d    S5      U l        [        R                  " U=(       d    S5      U l        [        R                  " U=(       d    S5      U l        X`l        Xpl        SU l	        SU l
        g)a0  Constructor.

Args:
  self_key: Observation dict key of position of object being controlled.
  target_key: Observation dict key of position of target object.
  position: Initial position of the object.
  orientation: Initial orientation of the object in xyzw quaternion.
  conversation_center: Position of the center of the conversation group.
  proximity_threshold: The distance from the conversation center that the
    target must reach in order to prompt a response from the controlled
    object.
  speed_mps: Speed in meters per second, always positive.
r*   r+   N)r   r   r-   r.   r/   r0   _conversation_center_proximity_thresholdrm   _prev_target_position_wait_position)r   r   r   r'   r(   r   r   rf   s           r   r1   ConversationController.__init__  sl    * N!XXh3)4DN!<=D ")<)I	 JD 3O!%DDr   c                 l   [         R                  " X R                  -
  5      n[         R                  " XR                  -
  5      nU[         R                  R	                  U5      -  n[         R
                  " XE5      U-  nX`R                  -  nU R                  UUU R                  U R                  5      $ )a  Gets the waiting position for the controlled object.

This returns the position that the controlled object should move towards
to create physical space such that the target object may pass through
the conversation space.

Args:
  self_position: The current position of the controlled object.
  target_position: The current position of the target object.

Returns:
  An xyz position representing the waiting position that the controlled
  object should move towards to create space.
)r-   r.   r   r   r   dot_get_positionr   )r   r   r   target_path	self_pathunit_target_pathprojected_points          r   _get_wait_position)ConversationController._get_wait_position  s      ((?-G-GGHK)C)CCDI"RYY^^K%@@ffY9<LLO111O
 !!!!	# #r   c           	      ,   [         R                  " X5      (       a  U R                  $ X!-
  S-  n[         R                  " US   US   5      n[         R                  " SS[         R
                  " US-  5      [         R                  " US-  5      45      nU$ )a  Gets orientation required to face target_position from source_position.

Args:
  source_position: The source position where an object would be located.
  target_position: The target position that an object should face.

Returns:
  A xyzw quaternion indicating the orientation.
r   r,   r   rF   )r-   allcloser0   r   r.   rI   rH   )r   source_positionr   r   r   r   s         r   r   'ConversationController._get_orientation4  s     
{{?44#5BLjja,q/:Ghh	
Arvvgk"BFF7Q;$78:O r   c                     X!-
  S-  n[         R                  R                  U5      nXd:  a  XV-  U-  nOXc:  a  XV-  U-  nXQ-   nU$ )a(  Gets the next position along the vector from source to target.

This returns the position that should be moved to next which lies along
the direction vector from source -> target with a minimum length of
min_delta and a maximum distance of max_delta.

Args:
  source_position: The current position of the controlled object.
  target_position: The target position to move to.
  min_delta: The minimum amount of distance to move.
  max_delta: The maximum amount of distance to move.

Returns:
  An xyz position representing the next position to move to.
r   )r-   r   r   )r   r   r   	min_delta	max_deltar   r   r   s           r   r   $ConversationController._get_positionI  s[    ( $5BLyy~~l+H "-:l 
	"-:l 2Lr   c                 b    XR                   -
  S-  n[        R                  R                  U5      $ )zGets the distance from the target to the conversation center point.

Args:
  target_position: The target position.

Returns:
  The scalar distance from the target position to the conversation center.
r   )r   r-   r   r   )r   r   r   s      r   _get_target_distance_to_center5ConversationController._get_target_distance_to_centerm  s,     $&?&??9LL 99>>,''r   r3   r   r   c                 H   U R                   nU R                  nUS:  a  X R                     nX R                     nU R	                  U5      nXpR
                  :  aO  U R                  bB  U R                  XV5      nU R                  UU5      nU R                  UUSU R                  5      nODU R                  UU R                  5      nU R                  UU R                   SU R                  5      nX`l        [        R                  " US   US   U R                   S   /5      nX40 4$ )Gets the position and orientation of the controlled object.

Args:
  t: The current time step.
  observations: Dict containing sensor observations for current time step.

Returns:
  The new position and orientation for the controlled object.
r   rE   r,   rF   )r/   r0   r   r   r   r   r   r   r   r   rm   r   r-   r.   )	r   r3   r   r'   r(   r   r   target_distancewait_positions	            r   r   !ConversationController.get_action|  s.    ~~H##K 	Av">>2m$%5%56o;;OLo 
44	4		#	#	/ //O++ %%OO	 ++%%' %%NNOO	 $3  xx!hqk4>>!3DEFH"$$r   )	r   r0   r/   r   r   r   rm   r   r   )NNNrb   g?)r   r   r   r   r   r   r   r    r1   r   r   r   r   r   r   r!   r   r"   r   r   r   r   r     s     ,0.26:,/"% "% %UO	
 %-UO %*  @#B*"H(:%:%#D#I:%3C:%r   r   c                       \ rS rSrSrSr\SS4S\S\S\\   S\	\
\\
   4   S	\\   S
\\
   4S jjrS\
S\\\4   S\4S jrS\4S jrSrg)PauseIfCloseByWrapperi  zA controller wrapper that pauses controller if object is close to others.

This wrapper works best if the underlying controller is time based. It is
intended to be a simple way to stop agent when blocked and is not for
reliable collision avoidance.
rb   Nwrapped_controllerself_pos_keyothers_pos_keyspause_distanceself_yaw_keyactive_front_sectorc                 N   Xl         SU l        SU l        SU l        X l        [        U5      U l        [        U[        5      (       a  U/[        U5      -  n[        U5      [        U5      :w  a  [        S5      e[        U5      U l        Ub  Uc  [        S5      eXPl        X`l        g)a  Constructor.

Args:
  wrapped_controller: The controller being wrapped.
  self_pos_key: Observation key of self position.
  others_pos_keys: Observation keys of others' positions.
  pause_distance: The distance limit before the controller pauses in meters.
    Can be a float value which applies to all objects specified in
    others_pos_keys or a Sequence of float values with the same length
    as others_pos_keys denoting the pause distance for each individual
    object in the same order in others_pos_keys. Default pause distance is
    one meter.
  self_yaw_key: Observation key of self yaw. Required if active_front_sector
    is specified.
  active_front_sector: If specified, it defines pie-shaped active region in
    front of controlled object. The pie-shaped area is symmetric about the
    forward direction of controlled object with it angle defined by this
    arg in radians, Only when other objects shows up in this region and
    pause distance requirement is met, pause is actived.
ri   r   Nz=pause_distance and others_pos_keys must have the same length.zCself_yaw_key must be specified if active_front_sector is specified.)_controller_pause_start_t_shift_t_last_action_self_pos_keyrp   _others_pos_keysrj   r    rn   ro   _pause_distance_self_yaw_key_active_front_sector)r   r  r  r  r	  r
  r  s          r   r1   PauseIfCloseByWrapper.__init__  s    : *DDMD% 1D.%((&'#o*>>n
>c/22
IK K/D&<+?
OQ Q & 3r   r3   r   r   c                    US:  a:  SU l         SU l        U R                  R                  X5      U l        U R                  $ U R                  U5      (       a"  U R                   S:  a  Xl         U R                  $ U R                   S:  a(  U =R                  XR                   -
  -  sl        SU l         U R                  R                  XR                  -
  U5      U l        U R                  $ )r   r   ri   )r  r  r  r   r  _should_pauser5   s      r   r    PauseIfCloseByWrapper.get_action  s     	1uddm**55
d,''			q	 				!0000 **55
mm
\+dr   c           
      $   XR                      SS n[        U R                  U R                  5       H  u  p4X   SS nXR-
  n[        R
                  R                  U5      nU R                  c  Xt:*  s  $ XR                     S   n[        R                  " Xg-  [        R                  " [        R                  " U5      [        R                  " U5      /5      5      n	Xt:*  =(       a&    [        R                  " U	5      U R                  S-  :  s  $    g)z/Determines whether the controller should pause.NrF   r   F)r  rw   r  r  r-   r   r   r  r  r   r.   rH   rI   arccos)
r   r   self_position_2dpos_keyr	  position_2d	vector_2dr   rL   r   s
             r   r  #PauseIfCloseByWrapper._should_pause  s    #$6$67;#&t33$5 )"1-k0i	*h		"	"	*))--.q1ffY)288RVVC["&&+4N+OP* ?		#!:!:Q!>>	@$5 r   )	r  r  r  r  r  r  r  r  r  )r   r   r   r   r   _DEFAULT_PAUSE_DISTANCE_Mr   r   r   r	   r    r   r1   r   r   r!   r   rN   r  r"   r   r   r   r  r    s     " 7P%)-114(14 14  ~	14
 E8E?2314 TN14 $E?14f  #D#I 3C D4 r   r  )&r   r   r   enumtypingr   r   r   r   r   r   r	   abslr
   dataclassesginnumpyr-   	INIT_TIMEr   r^   r!   r   ABCMetar   configurabler%   r8   EnumrP   	dataclassrX   r`   r   r   r   r   r  r   r   r   <module>r-     s   3 
   D D D   
  	 RZZdCi@A 5 s{{ 4 1> 1 1$ +%~ +% +%\tyy *     q4~ q4 q4h 5  ( P4n P4 P4f *+~ *+ *+Z M%^ M% M%` pN p pr   