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_speedcondition(): cond = OSC.SpeedCondition(1, 'lessThan') OSC.prettyprint(cond.get_element())
25, pyoscx.TransitionDynamics(pyoscx.DynamicsShapes.sinusoidal, pyoscx.DynamicsDimension.time, 8)) egostart = pyoscx.TeleportAction(pyoscx.LanePosition(25, 0, -3, 0)) targetspeed = pyoscx.AbsoluteSpeedAction(15, step_time) targetstart = pyoscx.TeleportAction(pyoscx.RoadPosition(30, -5, 0)) init.add_init_action(egoname, egospeed) init.add_init_action(egoname, egostart) init.add_init_action(targetname, targetspeed) init.add_init_action(targetname, targetstart) ### create an event trigcond = pyoscx.SpeedCondition(24, pyoscx.Rule.greaterThan) trigger = pyoscx.EntityTrigger('mytesttrigger', 0.2, pyoscx.ConditionEdge.none, trigcond, egoname) event = pyoscx.Event('myfirstevent', pyoscx.Priority.overwrite) event.add_trigger(trigger) sin_time = pyoscx.TransitionDynamics(pyoscx.DynamicsShapes.linear, pyoscx.DynamicsDimension.time, 5) action = pyoscx.AbsoluteSpeedAction(30, sin_time) event.add_action('newspeed', action) ## create the maneuver man = pyoscx.Maneuver('my_maneuver') man.add_event(event)