Skip to content

Commit 62f29c4

Browse files
committed
adapt global simulation, optimaized route planning, optimized parking lot finding
1 parent abbb25c commit 62f29c4

11 files changed

Lines changed: 205 additions & 93 deletions

File tree

GEMstack/knowledge/defaults/ReedsShepp_param.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ vehicle:
66
reeds_shepp_parking:
77
shift_from_center_to_rear_axis: 1.25 # in meter
88
search_step_size: 0.1 # in meter
9-
closest: True # If True, the closest parking spot will be selected, otherwise the farthest one will be selected
9+
closest: False # If True, the closest parking spot will be selected, otherwise the farthest one will be selected
1010
parking_lot_axis_shift_margin: 2.44 # in meter
1111
search_bound_threshold: 0.5
1212
clearance_step: 0.5
1313
clearance: 0
14-
add_static_vertical_curb_as_obstacle: True
15-
add_static_horizontal_curb_as_obstacle: True
14+
add_static_vertical_curb_as_obstacle: False
15+
add_static_horizontal_curb_as_obstacle: False
1616
static_horizontal_curb_size: [2.44, 0.5]
1717
static_vertical_curb_size: [2.44, 24.9]
1818
compact_parking_spot_size: [2.44, 4.88] # US Compact Space for parking (2.44, 4.88)

GEMstack/knowledge/routes/summoning_roadgraph_highbay.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

GEMstack/onboard/perception/agent_detection.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,45 @@ def update(self, vehicle : VehicleState) -> Dict[str, AgentState]:
5454
if ped_num > 0:
5555
print("\nDetected", ped_num, "pedestrians")
5656
return res
57+
58+
59+
class SummoningGlobalSimAgentDetector(Component):
60+
"""Obtains agent detections from a simulator"""
61+
62+
def __init__(self, vehicle_interface: GEMInterface):
63+
self.vehicle_interface = vehicle_interface
64+
self.agents = {}
65+
self.lock = threading.Lock()
66+
67+
self.start_pose = None
68+
69+
def rate(self):
70+
return 4.0
71+
72+
def state_inputs(self):
73+
return ['vehicle']
74+
75+
def state_outputs(self):
76+
return ['agents']
77+
78+
def initialize(self):
79+
self.vehicle_interface.subscribe_sensor('agent_detector', self.agent_callback, AgentState)
80+
81+
def agent_callback(self, name: str, agent: AgentState):
82+
with self.lock:
83+
self.agents[name] = agent
84+
85+
def update(self, vehicle : VehicleState) -> Dict[str, AgentState]:
86+
with self.lock:
87+
res = {}
88+
ped_num = 0
89+
90+
for n, a in self.agents.items():
91+
# Define in start frame.
92+
a.pose.frame = ObjectFrameEnum.START
93+
res[n] = a
94+
if a.type == AgentEnum.PEDESTRIAN:
95+
ped_num += 1
96+
if ped_num > 0:
97+
print("\nDetected", ped_num, "pedestrians")
98+
return res

GEMstack/onboard/perception/state_estimation.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from dataclasses import replace
22
import math
3-
from typing import List
3+
from typing import List, Optional
44
from ...utils import settings
55
from ...mathutils import transforms
66
from ...state.vehicle import VehicleState,VehicleGearEnum
@@ -75,7 +75,6 @@ def __init__(self, vehicle_interface : GEMInterface):
7575
if 'gnss' not in vehicle_interface.sensors():
7676
raise RuntimeError("GNSS sensor not available")
7777
vehicle_interface.subscribe_sensor('gnss',self.fake_gnss_callback)
78-
self.vehicle_state = None
7978

8079
# Get GNSS information
8180
def fake_gnss_callback(self, vehicle_state):

GEMstack/onboard/planning/mission_planning.py

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
from typing import List, Union
22
from klampt.vis import scene
33
from ..component import Component
4-
from ...utils import serialization
54
from ...state import Route, ObjectFrameEnum, AllState, VehicleState, Roadgraph, MissionObjective, MissionEnum, ObjectPose
65
import numpy as np
76
import requests
8-
import json
97
import time
8+
import yaml
109

1110

1211
def check_distance(goal_pose: Union[ObjectPose, list], current_pose : ObjectPose):
@@ -37,7 +36,7 @@ def next_state(self):
3736
class SummoningMissionPlanner(Component):
3837
def __init__(self, use_webapp, webapp_url, goal=None, state_machine=None):
3938
self.state_machine = StateMachine([eval(s) for s in state_machine])
40-
39+
4140
# if use_webapp is True, goal should be None
4241
self.goal_location = goal['location'] if not use_webapp else None
4342
self.goal_frame = goal['frame'] if not use_webapp else None
@@ -46,6 +45,7 @@ def __init__(self, use_webapp, webapp_url, goal=None, state_machine=None):
4645
self.start_pose = None
4746
self.start_time = time.time()
4847
self.end_of_driving_route = None
48+
self.search_count = 0
4949

5050
self.flag_use_webapp = use_webapp
5151
self.url_status = f"{webapp_url}/api/status"
@@ -113,6 +113,8 @@ def update(self, state: AllState):
113113
goal_location = self.goal_location
114114
goal_frame = self.goal_frame
115115

116+
start_vehicle_pose = state.start_vehicle_pose
117+
116118
if goal_frame == 'global':
117119
self.goal_pose = ObjectPose(t=time.time(), x=goal_location[0], y=goal_location[1],
118120
frame=ObjectFrameEnum.GLOBAL)
@@ -128,11 +130,15 @@ def update(self, state: AllState):
128130
raise ValueError("Invalid frame argument")
129131

130132
if self.goal_pose:
131-
# self.goal_pose = self.goal_pose.to_frame(ObjectFrameEnum.START, start_pose_abs=state.start_vehicle_pose)
132-
133-
# For global map test in simulation only
134-
start_pose_global = ObjectPose(frame=ObjectFrameEnum.GLOBAL, t=time.time(), x=-88.235252, y=40.0927516, yaw=-1.57079633)
135-
self.goal_pose = self.goal_pose.to_frame(ObjectFrameEnum.START, start_pose_abs=start_pose_global)
133+
if start_vehicle_pose.frame == ObjectFrameEnum.ABSOLUTE_CARTESIAN and goal_frame == 'global':
134+
# For global map simulation test
135+
with open("scenes/summoning_map_sim_setting.yaml", "r") as f:
136+
data = yaml.safe_load(f)
137+
start= data['start_pose_global']
138+
start_pose_global = ObjectPose(frame=ObjectFrameEnum.GLOBAL, t=start_vehicle_pose.t, x=start[0], y=start[1], yaw=start[2])
139+
self.goal_pose = self.goal_pose.to_frame(ObjectFrameEnum.START, start_pose_abs=start_pose_global)
140+
else:
141+
self.goal_pose = self.goal_pose.to_frame(ObjectFrameEnum.START, start_pose_abs=start_vehicle_pose)
136142
print("Goal pose:", self.goal_pose)
137143

138144
# Initiate state
@@ -159,6 +165,8 @@ def update(self, state: AllState):
159165
mission.type = self.state_machine.next_state()
160166
print("============== Next state:", mission.type)
161167
self.end_of_driving_route = route.points[-1]
168+
else:
169+
self.search_count += 1
162170

163171
# Finish parking, back to idle and wait for the next goal location
164172
elif mission.type == MissionEnum.PARALLEL_PARKING:
@@ -171,12 +179,24 @@ def update(self, state: AllState):
171179
mission.type = self.state_machine.next_state()
172180
self.new_goal = False
173181
self.goal_pose = None
182+
self.goal_location = None
183+
self.goal_frame = None
174184
mission.goal_pose = self.goal_pose
175185
print("============== Next state:", mission.type)
186+
else:
187+
self.search_count += 1
176188

177189
else:
178190
raise ValueError("Invalid mission type")
179191

192+
# Can not find a path, stop mission.
193+
if self.search_count > 10:
194+
mission.type = MissionEnum.IDLE
195+
self.goal_pose = None
196+
self.goal_location = None
197+
self.goal_frame = None
198+
self.search_count = 0
199+
180200

181201
if self.flag_use_webapp:
182202
data = {

0 commit comments

Comments
 (0)