def test_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)
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())
def test_laneposition(): pos = OSC.LanePosition(1, 2, lane_id='lane1', road_id='road1') OSC.prettyprint(pos.get_element()) pos = OSC.RelativeLanePosition(1, 2, lane_id=1, entity='Ego') OSC.prettyprint(pos.get_element())
init.add_init_action(egoname,egostart) init.add_init_action(targetname,targetspeed) init.add_init_action(targetname,targetstart) ### create an event trigcond = pyoscx.TimeHeadwayCondition(targetname,0.4,pyoscx.Rule.greaterThan) 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)