Skip to content

Commit 3a1919a

Browse files
author
Aadarsh
committed
adding fake parking space detector
1 parent 130a555 commit 3a1919a

2 files changed

Lines changed: 120 additions & 3 deletions

File tree

GEMstack/onboard/perception/parking_detection.py

Lines changed: 77 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from sensor_msgs.msg import PointCloud2
44
from typing import Dict
55
from ..component import Component
6-
from ...state import AgentState, ObjectPose, ObjectFrameEnum, Obstacle, ObstacleMaterialEnum
6+
from ...state import AgentState, ObjectPose, ObjectFrameEnum, Obstacle, ObstacleMaterialEnum, VehicleState, AllState
77
from ..interface.gem import GEMInterface
88
from .utils.detection_utils import *
99
from .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

launch/parking_detection.yaml

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ variants:
9292
# route_planning_component:
9393
# type: RoutePlanningComponent
9494

95-
sim: # full pipeline
95+
sim: # full pipeline, sim, real perception
9696
run:
9797
mode: simulation
9898
vehicle_interface:
@@ -178,6 +178,48 @@ variants:
178178
trajectory_tracking:
179179
type: pure_pursuit.PurePursuitTrajectoryTracker
180180
print: False
181+
182+
real_sim: # real on-board planning w/ fake perception
183+
run:
184+
mode: hardware
185+
vehicle_interface:
186+
type: gem_hardware.GEMHardwareInterface
187+
188+
drive:
189+
perception:
190+
state_estimation : GNSSStateEstimator
191+
agent_detection : OmniscientAgentDetector
192+
parking_detection: parking_detection.FakeParkingSpaceDetector
193+
194+
195+
planning:
196+
parking_component:
197+
type: ParkingSim
198+
route_planning_component:
199+
type: RoutePlanningComponent
200+
dubins:
201+
integrator:
202+
timestep: 1
203+
dt: .25
204+
max_velocity: 0.75
205+
max_turning_rate: 0.3
206+
tolerance: 0.25
207+
astar:
208+
iterations: 200 # We should have some sort of max iterations/timeout
209+
heuristic: reeds_shepp
210+
211+
motion_planning:
212+
type: longitudinal_planning.YieldTrajectoryPlanner
213+
# type: yield_spline_planner.SplinePlanner
214+
largs:
215+
acceleration: 1
216+
deceleration: 2
217+
desired_speed: 1
218+
219+
trajectory_tracking:
220+
type: pure_pursuit.PurePursuitTrajectoryTracker
221+
print: False
222+
181223
log_ros:
182224
log:
183225
ros_topics : !include "../GEMstack/knowledge/defaults/standard_ros_topics.yaml"

0 commit comments

Comments
 (0)