Skip to content

Commit c970035

Browse files
committed
Add a yaml for summoning, SummoningRoutePlanner, a stadium shape roadgraph, and a roadgraph generator
1 parent 924f690 commit c970035

6 files changed

Lines changed: 369 additions & 5 deletions

File tree

GEMstack/knowledge/routes/summoning_roadgraph.json

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

GEMstack/onboard/planning/route_planning.py

Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
from typing import List
22
from ..component import Component
33
from ...utils import serialization
4-
from ...state import Route,ObjectFrameEnum
4+
from ...state import Route,ObjectFrameEnum, AllState, VehicleState, Roadgraph, MissionObjective
55
import os
66
import numpy as np
7+
import yaml
78

89
class StaticRoutePlanner(Component):
910
"""Reads a route from disk and returns it as the desired route."""
@@ -39,4 +40,64 @@ def rate(self):
3940

4041
def update(self):
4142
return self.route
42-
43+
44+
45+
def get_all_lane_points(roadgraph: Roadgraph) -> List:
46+
all_points = []
47+
for value in roadgraph.lanes.values():
48+
for pts in value.left.segments:
49+
for pt in pts:
50+
all_points.append(pt)
51+
return all_points
52+
53+
54+
# implement route planning method
55+
def generate_route(roadgraph, destination: List, vehicle: VehicleState, roadgraph_type='roadgraph'):
56+
if roadgraph_type == 'roadgraph':
57+
all_road_points = get_all_lane_points(roadgraph)
58+
elif roadgraph_type == 'point_list':
59+
all_road_points = roadgraph
60+
61+
waypoints = []
62+
waypoints.append(destination)
63+
return waypoints
64+
65+
66+
class SummoningRoutePlanner(Component):
67+
"""Reads a route from disk and returns it as the desired route."""
68+
def __init__(self, roadgraphfn : str, frame : str = 'global'):
69+
self.frame = frame
70+
base, ext = os.path.splitext(roadgraphfn)
71+
if ext in ['.json', '.yml', '.yaml']:
72+
with open(roadgraphfn, 'r') as f:
73+
self.roadgraph = serialization.load(f)
74+
self.all_lane_points = get_all_lane_points(self.roadgraph)
75+
elif ext == '.csv':
76+
self.roadgraph = np.loadtxt(roadgraphfn,delimiter=',',dtype=float)
77+
self.roadgraph_type = 'point_list'
78+
79+
def state_inputs(self):
80+
return ['vehicle', 'mission']
81+
82+
def state_outputs(self) -> List[str]:
83+
return ['route']
84+
85+
def rate(self):
86+
return 1.0
87+
88+
def update(self, vehicle: VehicleState, mission: MissionObjective):
89+
self.vehicle = vehicle
90+
91+
# TODO: get from the server
92+
self.destinations = [(23.0, 3.0, 0.0),(2.0, 6.0, 0.0)]
93+
94+
waypoints = generate_route(self.roadgraph, self.destinations, self.vehicle, self.roadgraph_type)
95+
96+
if self.frame == 'start':
97+
self.route = Route(frame=ObjectFrameEnum.START, points=waypoints.tolist())
98+
elif self.frame == 'global':
99+
self.route = Route(frame=ObjectFrameEnum.GLOBAL, points=waypoints.tolist())
100+
elif self.frame == 'cartesian':
101+
self.route = Route(frame=ObjectFrameEnum.ABSOLUTE_CARTESIAN, points=waypoints.tolist())
102+
103+
return self.route

GEMstack/state/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66
__all__ = ['PhysicalObject','ObjectPose','ObjectFrameEnum',
77
'Path','Trajectory',
88
'VehicleState',
9-
'Roadgraph',
9+
'Roadgraph', 'RoadgraphLane', 'RoadgraphLaneEnum', 'RoadgraphCurve', 'RoadgraphCurveEnum',
10+
'RoadgraphRegion', 'RoadgraphRegionEnum', 'RoadgraphSurfaceEnum', 'RoadgraphConnectionEnum',
1011
'Roadmap',
11-
'Obstacle',
12+
'Obstacle', 'ObstacleMaterialEnum',
1213
'Sign',
1314
'AgentState','AgentEnum','AgentActivityEnum',
1415
'SceneState',

launch/summoning.yaml

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
description: "Run the yielding trajectory planner on the real vehicle with real perception"
2+
mode: hardware
3+
vehicle_interface: gem_hardware.GEMHardwareInterface
4+
mission_execution: StandardExecutor
5+
6+
# Recovery behavior after a component failure
7+
recovery:
8+
planning:
9+
trajectory_tracking : recovery.StopTrajectoryTracker
10+
11+
# Driving behavior for the GEM vehicle. Runs real pedestrian perception, yield planner, but does not send commands to real vehicle.
12+
drive:
13+
perception:
14+
state_estimation : GNSSStateEstimator
15+
agent_detection : pedestrian_detection.PedestrianDetector2D
16+
perception_normalization : StandardPerceptionNormalizer
17+
planning:
18+
relations_estimation:
19+
type: pedestrian_yield_logic.PedestrianYielder
20+
args:
21+
mode: 'real'
22+
params: {
23+
'yielder': 'expert', # 'expert', 'analytic', or 'simulation'
24+
'planner': 'milestone', # 'milestone', 'dt', or 'dx'
25+
'desired_speed': 1.0, # m/s, 1.5 m/s seems max speed? Feb24
26+
'acceleration': 0.75 # m/s2, 0.5 is not enough to start moving. Feb24
27+
}
28+
route_planning:
29+
# type: StaticRoutePlanner
30+
# args: [!relative_path '../GEMstack/knowledge/routes/forward_15m.csv','start']
31+
type: SummoningRoutePlanner
32+
args: [!relative_path '../GEMstack/knowledge/routes/summoning_roadgraph.yaml','start']
33+
motion_planning: longitudinal_planning.YieldTrajectoryPlanner
34+
trajectory_tracking:
35+
type: pure_pursuit.PurePursuitTrajectoryTracker
36+
print: False
37+
38+
log:
39+
# Specify the top-level folder to save the log files. Default is 'logs'
40+
#folder : 'logs'
41+
# If prefix is specified, then the log folder will be named with the prefix followed by the date and time. Default no prefix
42+
#prefix : 'fixed_route_'
43+
# If suffix is specified, then logs will output to folder/prefix+suffix. Default uses date and time as the suffix
44+
#suffix : 'test3'
45+
# Specify which ros topics to record to vehicle.bag. Default records nothing. This records the "standard" ROS topics.
46+
ros_topics :
47+
# Specify options to pass to rosbag record. Default is no options.
48+
#rosbag_options : '--split --size=1024'
49+
# If True, then record all readings / commands of the vehicle interface. Default False
50+
vehicle_interface : True
51+
# Specify which components to record to behavior.json. Default records nothing
52+
components : ['state_estimation','agent_detection','motion_planning']
53+
# Specify which components of state to record to state.json. Default records nothing
54+
#state: ['all']
55+
# Specify the rate in Hz at which to record state to state.json. Default records at the pipeline's rate
56+
#state_rate: 10
57+
# If True, then make plots of the recorded data specifically from PurePursuitTrajectoryTracker_debug.csv and report metrics. Default False
58+
#auto_plot : True
59+
replay: # Add items here to set certain topics / inputs to be replayed from logs
60+
# Specify which log folder to replay from
61+
log:
62+
ros_topics : []
63+
components : []
64+
65+
#usually can keep this constant
66+
computation_graph: !include "../GEMstack/knowledge/defaults/computation_graph.yaml"
67+
68+
variants:
69+
detector_only:
70+
run:
71+
description: "Run the pedestrian detection code"
72+
drive:
73+
planning:
74+
trajectory_tracking:
75+
real_sim:
76+
run:
77+
description: "Run the pedestrian detection code with real detection and fake simulation"
78+
mode: hardware
79+
vehicle_interface:
80+
type: gem_mixed.GEMRealSensorsWithSimMotionInterface
81+
args:
82+
scene: !relative_path '../scenes/xyhead_demo.yaml'
83+
mission_execution: StandardExecutor
84+
require_engaged: False
85+
visualization: !include "klampt_visualization.yaml"
86+
drive:
87+
perception:
88+
state_estimation : OmniscientStateEstimator
89+
planning:
90+
relations_estimation:
91+
type: pedestrian_yield_logic.PedestrianYielder
92+
args:
93+
mode: 'sim'
94+
95+
fake_real:
96+
run:
97+
description: "Run the yielding trajectory planner on the real vehicle with faked perception"
98+
drive:
99+
perception:
100+
agent_detection : pedestrian_detection.FakePedestrianDetector2D
101+
102+
fake_sim:
103+
run:
104+
description: "Run the yielding trajectory planner in simulation with faked perception"
105+
mode: simulation
106+
vehicle_interface:
107+
type: gem_simulator.GEMDoubleIntegratorSimulationInterface
108+
args:
109+
scene: !relative_path '../scenes/xyhead_demo.yaml'
110+
visualization: !include "klampt_visualization.yaml"
111+
drive:
112+
perception:
113+
# agent_detection : pedestrian_detection.FakePedestrianDetector2D
114+
agent_detection : OmniscientAgentDetector #this option reads agents from the simulator
115+
state_estimation : OmniscientStateEstimator
116+
planning:
117+
relations_estimation:
118+
type: pedestrian_yield_logic.PedestrianYielder
119+
args:
120+
mode: 'sim'

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ dacite
1111
# Perception
1212
ultralytics
1313
open3d
14-
sklearn
14+
scikit-learn

0 commit comments

Comments
 (0)