init.add_init_action(targetname, targetstart) ### create an event trigcond = pyoscx.RelativeSpeedCondition(0, pyoscx.Rule.lessThan, egoname) trigger = pyoscx.EntityTrigger('mytesttrigger', 0.2, pyoscx.ConditionEdge.none, trigcond, targetname) event = pyoscx.Event('myfirstevent', pyoscx.Priority.overwrite) event.add_trigger(trigger) sin_time = pyoscx.TransitionDynamics(pyoscx.DynamicsShapes.linear, pyoscx.DynamicsDimension.time, 5) action = pyoscx.RelativeLaneChangeAction( -8, targetname, pyoscx.TransitionDynamics(pyoscx.DynamicsShapes.linear, pyoscx.DynamicsDimension.time, 6), -10) event.add_action('newspeed', action) ## create the maneuver man = pyoscx.Maneuver('my_maneuver') man.add_event(event) mangr = pyoscx.ManeuverGroup('mangroup') mangr.add_actor(targetname) mangr.add_maneuver(man) starttrigger = pyoscx.ValueTrigger( 'starttrigger', 0, pyoscx.ConditionEdge.rising, pyoscx.SimulationTimeCondition(0, pyoscx.Rule.greaterThan)) act = pyoscx.Act('my_act', starttrigger) act.add_maneuver_group(mangr)
def test_lanechange_rel(): lanechange = OSC.RelativeLaneChangeAction(1,'Ego',TD,0.2) OSC.prettyprint(lanechange.get_element())
init.add_init_action(targetname, pyoscx.TeleportAction(pyoscx.LanePosition(50, 0, -2, 0))) init.add_init_action( targetname, pyoscx.AbsoluteSpeedAction( 10, pyoscx.TransitionDynamics(pyoscx.DynamicsShapes.step, pyoscx.DynamicsDimension.time, 1))) ## do lanechange lc_cond = pyoscx.ReachPositionCondition(pyoscx.LanePosition(40, 0, -4, 0), 1) lc_event = pyoscx.Event('lanechange', pyoscx.Priority.parallel) lc_event.add_action( 'lanechangeaction', 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(