def test_conditiongroup(): condgr = OSC.ConditionGroup() trig1 = OSC.EntityTrigger('firsttrigger',1,OSC.ConditionEdge.rising,OSC.RelativeDistanceCondition(10,OSC.Rule.greaterThan,'Ego'),'Target') trig2 = OSC.EntityTrigger('secondtrigger',2,OSC.ConditionEdge.rising,OSC.SpeedCondition(2,OSC.Rule.equalTo),'Target') condgr.add_condition(trig1) condgr.add_condition(trig2) OSC.prettyprint(condgr.get_element())
def test_trigger(): condgr = OSC.ConditionGroup() trig1 = OSC.EntityTrigger('firsttrigger',1,OSC.ConditionEdge.rising,OSC.RelativeDistanceCondition(10,OSC.Rule.greaterThan,OSC.RelativeDistanceType.longitudinal,'Ego'),'Target') trig2 = OSC.EntityTrigger('secondtrigger',2,OSC.ConditionEdge.rising,OSC.SpeedCondition(2,OSC.Rule.equalTo),'Target') condgr.add_condition(trig1) condgr.add_condition(trig2) condgr2 = OSC.ConditionGroup() trig3 = OSC.EntityTrigger('thirdtrigger',1,OSC.ConditionEdge.rising,OSC.RelativeDistanceCondition(10,OSC.Rule.greaterThan,OSC.RelativeDistanceType.longitudinal,'Ego'),'Target') trig4 = OSC.EntityTrigger('forthtrigger',2,OSC.ConditionEdge.rising,OSC.SpeedCondition(2,OSC.Rule.equalTo),'Target') condgr2.add_condition(trig3) condgr2.add_condition(trig4) trig = OSC.Trigger() trig.add_conditiongroup(condgr) trig.add_conditiongroup(condgr2) OSC.prettyprint(trig.get_element())
def test_relativedistancecondition(): cond = OSC.RelativeDistanceCondition(1, 'equalTo', 'Ego', True, False) OSC.prettyprint(cond.get_element())
pyoscx.RelativeLaneChangeAction( -1, targetname, pyoscx.TransitionDynamics(pyoscx.DynamicsShapes.sinusoidal, pyoscx.DynamicsDimension.time, 3))) lc_event.add_trigger( pyoscx.EntityTrigger('lanechangetrigger', 0, pyoscx.ConditionEdge.none, lc_cond, egoname)) event = pyoscx.Event('speedchange', pyoscx.Priority.parallel) event.add_action( 'speedaction', pyoscx.AbsoluteSpeedAction( 10, pyoscx.TransitionDynamics(pyoscx.DynamicsShapes.linear, pyoscx.DynamicsDimension.time, 3))) trig_cond = pyoscx.RelativeDistanceCondition( 5, pyoscx.Rule.lessThan, pyoscx.RelativeDistanceType.lateral, targetname) event.add_trigger( pyoscx.EntityTrigger('trigger', 0, pyoscx.ConditionEdge.none, trig_cond, egoname)) man = pyoscx.Maneuver('mymaneuver') man.add_event(lc_event) man.add_event(event) ## create the storyboard sb = pyoscx.StoryBoard( init, pyoscx.ValueTrigger( 'stop_simulation', 0, pyoscx.ConditionEdge.rising, pyoscx.SimulationTimeCondition(20, pyoscx.Rule.greaterThan), 'stop'))
def test_relativedistancecondition(): cond = OSC.RelativeDistanceCondition(1,OSC.Rule.equalTo,OSC.RelativeDistanceType.longitudinal,'Ego',True,False) OSC.prettyprint(cond.get_element())