Skip to content

Commit 131a301

Browse files
Integrating state machine in inspection yaml
1 parent de4d6d0 commit 131a301

16 files changed

Lines changed: 540 additions & 1102 deletions

GEMstack/knowledge/defaults/computation_graph.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ components:
4343
- route_planning:
4444
inputs: [vehicle, roadgraph, mission]
4545
outputs: route
46+
- api_call:
47+
inputs: all
48+
outputs: all
4649
- driving_logic:
4750
inputs: all
4851
outputs: intent
@@ -55,3 +58,4 @@ components:
5558
- signaling:
5659
inputs: [intent]
5760
outputs:
61+
File renamed without changes.

GEMstack/onboard/execution/execution.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,11 @@ def validate_components(components : Dict[str,ComponentExecutor], provided : Lis
168168
assert i in possible_inputs, "Component {} is not supposed to receive input {}".format(k,i)
169169
outputs = c.c.state_outputs()
170170
for o in required_outputs:
171+
print(c.c.state_outputs())
171172
if o == 'all':
172173
assert outputs == ['all'], "Component {} outputs are not provided by previous components".format(k)
174+
elif c.c == "api_cal":
175+
pass
173176
else:
174177
assert o in outputs, "Component {} doesn't output required output {}".format(k,o)
175178
for o in outputs:
@@ -235,6 +238,7 @@ def __init__(self, c : Component, essential : bool = True):
235238
self.num_overruns = 0
236239
self.overrun_amount = 0.0
237240
self.do_update = None
241+
self.api_call = False
238242

239243
def set_debugger(self, debugger):
240244
if self.do_debug:
@@ -541,6 +545,7 @@ def run(self):
541545
if not self.validate_sensors(1):
542546
self.event("Sensors in desired pipeline {} are not working, switching to recovery".format(self.current_pipeline))
543547
self.current_pipeline = 'recovery'
548+
544549
except KeyboardInterrupt:
545550
if self.current_pipeline == 'recovery':
546551
executor_debug_print(1,"\
@@ -633,7 +638,7 @@ def run_until_switch(self):
633638
"""Runs a pipeline until a switch is requested."""
634639
if self.current_pipeline == 'recovery':
635640
self.state.mission.type = MissionEnum.RECOVERY_STOP
636-
641+
637642
(perception_components,planning_components,other_components) = self.pipelines[self.current_pipeline]
638643
components = list(perception_components.values()) + list(planning_components.values()) + list(other_components.values()) + list(self.always_run_components.values())
639644
dt_min = min([c.dt for c in components if c.dt != 0.0])
@@ -677,6 +682,9 @@ def run_until_switch(self):
677682
if c.essential and self.current_pipeline != 'recovery':
678683
executor_debug_print(1,"Other component {} not working, entering recovery mode",name)
679684
return 'recovery'
685+
elif c.api_call:
686+
executor_debug_print(1,"No information received by API",name)
687+
continue
680688
else:
681689
executor_debug_print(1,"Warning, other component {} not working",name)
682690

@@ -736,3 +744,5 @@ def done(self):
736744
executor_debug_print(1,"Vehicle has disengaged, exiting execution loop.")
737745
return True
738746
return False
747+
748+

GEMstack/onboard/other/api_call.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
from pydantic import BaseModel, Field
2+
from typing import List, Tuple, Union
3+
from ..component import Component
4+
from ...state import AllState, VehicleState, EntityRelation, EntityRelationEnum, Path, Trajectory, Route, ObjectFrameEnum, AgentState, MissionObjective
5+
import requests
6+
import copy
7+
8+
9+
### MODELS ###
10+
def check_point_exists(server_url="http://localhost:8000"):
11+
try:
12+
response = requests.get(f"{server_url}/point")
13+
response.raise_for_status()
14+
points = response.json().get("points", [])
15+
16+
for point in points:
17+
return True, [point["x"], point["y"]]
18+
return False, []
19+
20+
except requests.exceptions.RequestException as e:
21+
print("Error contacting server:", e)
22+
return False, []
23+
24+
class GetPoint(Component):
25+
"""Follows the given route. Brakes if you have to yield or
26+
you are at the end of the route, otherwise accelerates to
27+
the desired speed.
28+
"""
29+
30+
def __init__(self, endpoint, type):
31+
self.api_endpoint = endpoint
32+
self.bounding_box = None
33+
34+
def state_inputs(self):
35+
return ['all']
36+
37+
def state_outputs(self) -> List[str]:
38+
return ['all']
39+
40+
def rate(self):
41+
return 0.2
42+
43+
def update(self, state: AllState):
44+
# request the bounding box, if found then update and then switch the state
45+
points_found = False
46+
points_found, pts = check_point_exists()
47+
if points_found:
48+
state.goal = pts
49+
print(state.mission.state_list[state.mission.index+1])
50+
state.mission.type = state.mission.state_list[state.mission.index+1]
51+
state.mission.index += 1
52+
print("CHANGING STATES", state.mission.type)
53+
return copy.deepcopy(state)

GEMstack/onboard/other/api_client.py

Lines changed: 0 additions & 39 deletions
This file was deleted.

GEMstack/onboard/planning/inspection_plan.py

Lines changed: 0 additions & 74 deletions
This file was deleted.

0 commit comments

Comments
 (0)