def test_trajectory(): positionlist = [] positionlist.append(OSC.RelativeLanePosition(10, 0.5, -3, 'Ego')) positionlist.append(OSC.RelativeLanePosition(10, 1, -3, 'Ego')) OSC.prettyprint(positionlist[0].get_element()) polyline = OSC.Polyline([0, 0.5, 1, 1.5], positionlist) traj = OSC.Trajectory('my_trajectory', 'False') traj.add_shape(polyline)
def test_follow_traj_action_polyline(): positionlist = [] positionlist.append(OSC.RelativeLanePosition(10, 0.5, -3, 'Ego')) positionlist.append(OSC.RelativeLanePosition(10, 1, -3, 'Ego')) positionlist.append(OSC.RelativeLanePosition(10, -1, -3, 'Ego')) positionlist.append(OSC.RelativeLanePosition(10, 0, -3, 'Ego')) OSC.prettyprint(positionlist[0].get_element()) polyline = OSC.Polyline([0, 0.5, 1, 1.5], positionlist) traj = OSC.Trajectory('my_trajectory', False) traj.add_shape(polyline) trajact = OSC.FollowTrajectoryAction(traj, OSC.FollowMode.position) OSC.prettyprint(trajact.get_element())
trigger = pyoscx.EntityTrigger('mytesttrigger',0.2,pyoscx.ConditionEdge.rising,trigcond,egoname) event = pyoscx.Event('myfirstevent',pyoscx.Priority.overwrite) event.add_trigger(trigger) positionlist = [] positionlist.append(pyoscx.RelativeLanePosition(0,0,0,targetname)) positionlist.append(pyoscx.RelativeLanePosition(20,0.5,0,targetname)) positionlist.append(pyoscx.RelativeLanePosition(40,-0.5,0,targetname)) positionlist.append(pyoscx.RelativeLanePosition(60,-1,0,targetname)) polyline = pyoscx.Polyline([0,0.5,1,1.5],positionlist) traj = pyoscx.Trajectory('my_trajectory',False) traj.add_shape(polyline) trajact = pyoscx.FollowTrajectoryAction(traj,pyoscx.FollowMode.position,pyoscx.ReferenceContext.relative,1,0) event.add_action('newspeed',trajact) ## create the act man = pyoscx.Maneuver('my_maneuver') man.add_event(event) mangr = pyoscx.ManeuverGroup('mangroup') mangr.add_actor('$owner')
trigger = pyoscx.EntityTrigger('mytesttrigger', 0.2, pyoscx.ConditionEdge.rising, trigcond, egoname) event = pyoscx.Event('myfirstevent', pyoscx.Priority.overwrite) event.add_trigger(trigger) positionlist = [] positionlist.append(pyoscx.RelativeLanePosition(0, 0, 0, targetname)) positionlist.append(pyoscx.RelativeLanePosition(20, 0.5, 0, targetname)) positionlist.append(pyoscx.RelativeLanePosition(40, -0.5, 0, targetname)) positionlist.append(pyoscx.RelativeLanePosition(60, -1, 0, targetname)) polyline = pyoscx.Polyline([0, 0.5, 1, 1.5], positionlist) traj = pyoscx.Trajectory('my_trajectory', 'False') traj.add_shape(polyline) trajact = pyoscx.FollowTrajectoryAction(traj, pyoscx.FollowMode.position, pyoscx.ReferenceContext.relative, 1, 0) event.add_action('newspeed', trajact) ## create the act man = pyoscx.Maneuver('my_maneuver') man.add_event(event) mangr = pyoscx.ManeuverGroup('mangroup') mangr.add_actor('$owner') mangr.add_maneuver(man) starttrigger = pyoscx.ValueTrigger(