66
77from .geometry import Vector , Transform , BoundingBox
88from .sensor import Sensor
9- from .utils import accepts
9+ from .utils import accepts , ObjectState as AgentState
1010
1111from enum import Enum
1212from collections .abc import Iterable , Callable
@@ -55,54 +55,6 @@ def __init__(self):
5555 self .turn_signal_left = None # bool
5656 self .turn_signal_right = None # bool
5757
58-
59- class AgentState :
60- def __init__ (self , transform = None , velocity = None , angular_velocity = None ):
61- if transform is None : transform = Transform ()
62- if velocity is None : velocity = Vector ()
63- if angular_velocity is None : angular_velocity = Vector ()
64- self .transform = transform
65- self .velocity = velocity
66- self .angular_velocity = angular_velocity
67-
68- @property
69- def position (self ):
70- return self .transform .position
71-
72- @property
73- def rotation (self ):
74- return self .transform .rotation
75-
76- @property
77- def speed (self ):
78- return math .sqrt (
79- self .velocity .x * self .velocity .x +
80- self .velocity .y * self .velocity .y +
81- self .velocity .z * self .velocity .z )
82-
83- @staticmethod
84- def from_json (j ):
85- return AgentState (
86- Transform .from_json (j ["transform" ]),
87- Vector .from_json (j ["velocity" ]),
88- Vector .from_json (j ["angular_velocity" ]),
89- )
90-
91- def to_json (self ):
92- return {
93- "transform" : self .transform .to_json (),
94- "velocity" : self .velocity .to_json (),
95- "angular_velocity" : self .angular_velocity .to_json (),
96- }
97-
98- def __repr__ (self ):
99- return str ({
100- "transform" : str (self .transform ),
101- "velocity" : str (self .velocity ),
102- "angular_velocity" : str (self .angular_velocity ),
103- })
104-
105-
10658class Agent :
10759 def __init__ (self , uid , simulator ):
10860 self .uid = uid
@@ -335,3 +287,4 @@ def follow(self, waypoints, loop = False):
335287 def on_waypoint_reached (self , fn ):
336288 self .remote .command ("agent/on_waypoint_reached" , {"uid" : self .uid })
337289 self .simulator ._add_callback (self , "waypoint_reached" , fn )
290+
0 commit comments