Skip to content
Snippets Groups Projects
Commit 1d524264 authored by li213's avatar li213
Browse files

add empty controllerir

parent d6152fec
No related branches found
No related tags found
No related merge requests found
# Example agent.
from typing import Tuple, List
import numpy as np
import numpy as np
from pkg_resources import EmptyProvider
from scipy.integrate import ode
from dryvr_plus_plus.scene_verifier.agents.base_agent import BaseAgent
......@@ -11,10 +12,7 @@ from dryvr_plus_plus.scene_verifier.code_parser.parser import ControllerIR, Stat
class NPCAgent(BaseAgent):
def __init__(self, id):
self.id = id
controller = Lambda(args = [('ego', 'State'),('others', 'State')], body = {})
state_defs = {'State':StateDef(cont=[], disc=[], static=[])}
mode_defs = {'NullMode':ModeDef(modes=['Null'])}
self.controller = ControllerIR(controller, state_defs, mode_defs)
self.controller:ControllerIR = ControllerIR.EmptyControllerIR()
@staticmethod
def dynamic(t, state, u):
......
from dryvr_plus_plus.scene_verifier.agents.base_agent import BaseAgent
import numpy as np
from dryvr_plus_plus.scene_verifier.code_parser.pythonparser import EmptyAst
from dryvr_plus_plus.scene_verifier.code_parser.parser import ControllerIR
class SignAgent(BaseAgent):
def __init__(self, id):
self.id = id
self.controller = EmptyAst()
self.controller:ControllerIR = ControllerIR.EmptyControllerIR()
def TC_simulate(self, mode, init, time_horizon, time_step, map=None):
number_points = int(np.ceil(float(time_horizon)/time_step))
......
......@@ -84,7 +84,7 @@ class ReductionType(Enum):
}[self]
@dataclass(unsafe_hash=True)
class Reduction(ast.AST):
class Reduction(ast.expr):
"""A simple reduction. Must be a reduction function (see `ReductionType`) applied to a generator
with a single clause over a iterable"""
op: ReductionType
......@@ -169,6 +169,14 @@ class ControllerIR:
state_defs: Dict[str, StateDef]
mode_defs: Dict[str, ModeDef]
@classmethod
def EmptyControllerIR(cls):
controller = Lambda(args = [('ego', 'State'),('others', 'State')], body = {})
state_defs = {'State':StateDef(cont=[], disc=[], static=[])}
mode_defs = {'NullMode':ModeDef(modes=['Null'])}
return cls(controller, state_defs, mode_defs)
@staticmethod
def parse(code: Optional[str] = None, fn: Optional[str] = None) -> "ControllerIR":
return Env.parse(code, fn).to_ir()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment