33from sensor_msgs .msg import PointCloud2
44from typing import Dict
55from ..component import Component
6- from ...state import AgentState , ObjectPose , ObjectFrameEnum , Obstacle , ObstacleMaterialEnum
6+ from ...state import AgentState , ObjectPose , ObjectFrameEnum , Obstacle , ObstacleMaterialEnum , VehicleState , AllState
77from ..interface .gem import GEMInterface
88from .utils .detection_utils import *
99from .utils .parking_utils import *
@@ -189,4 +189,79 @@ def update(self, agents: Dict[str, AgentState]):
189189 )
190190
191191 new_state = [goal_pose , parking_obstacles ]
192- return new_state
192+ return new_state
193+
194+
195+ class FakeParkingSpaceDetector (Component ):
196+ def __init__ (self , vehicle_interface : GEMInterface ):
197+ self .vehicle_interface = vehicle_interface
198+
199+ # Hard-coded goal position for the parking spot
200+ self .goal_parking_spot = (8.0 , 20.0 , 0.0 ) # (x, y, yaw)
201+
202+ # Hard-coded obstacles blocking the side paths only (not the mouth of the parking)
203+ self .parking_obstacles_pose = [
204+ (6.0 , 18.0 , 0.0 , 0.0 ), # Left obstacle (x, y, z, yaw)
205+ (10.0 , 18.0 , 0.0 , 0.0 ) # Right obstacle (x, y, z, yaw)
206+ ]
207+
208+ # Obstacle dimensions (width, length, height)
209+ self .parking_obstacles_dim = [
210+ [0.5 , 0.5 , 1.0 ],
211+ [0.5 , 0.5 , 1.0 ]
212+ ]
213+
214+ def rate (self ):
215+ return 4.0
216+
217+ def state_inputs (self ):
218+ return ['agents' ]
219+
220+ def state_outputs (self ):
221+ return ['goal' , 'obstacles' ]
222+
223+ def update (self , state : AllState ):
224+ # Current timestamp
225+ current_time = self .vehicle_interface .time ()
226+
227+ # Constructing goal pose
228+ x , y , yaw = self .goal_parking_spot
229+ goal_pose = ObjectPose (
230+ t = current_time ,
231+ x = x ,
232+ y = y ,
233+ z = 0.0 ,
234+ yaw = yaw ,
235+ pitch = 0.0 ,
236+ roll = 0.0 ,
237+ frame = ObjectFrameEnum .CURRENT
238+ )
239+
240+ # Constructing obstacles for only the two side walls
241+ obstacle_id = 0
242+ parking_obstacles = {}
243+ for o_pose , o_dim in zip (self .parking_obstacles_pose , self .parking_obstacles_dim ):
244+ x , y , z , yaw = o_pose
245+ obstacle_pose = ObjectPose (
246+ t = current_time ,
247+ x = x ,
248+ y = y ,
249+ z = z ,
250+ yaw = yaw ,
251+ pitch = 0.0 ,
252+ roll = 0.0 ,
253+ frame = ObjectFrameEnum .START
254+ )
255+ new_obstacle = Obstacle (
256+ pose = obstacle_pose ,
257+ dimensions = o_dim ,
258+ outline = None ,
259+ material = ObstacleMaterialEnum .BARRIER ,
260+ collidable = True
261+ )
262+ parking_obstacles [f"parking_obstacle_{ obstacle_id } " ] = new_obstacle
263+ obstacle_id += 1
264+
265+ # Returning the hard-coded goal and obstacles
266+ new_state = [goal_pose , parking_obstacles ]
267+ return new_state
0 commit comments