def test_trajectory():
    positionlist = []
    positionlist.append(OSC.RelativeLanePosition(10, 0.5, -3, 'Ego'))
    positionlist.append(OSC.RelativeLanePosition(10, 1, -3, 'Ego'))
    prettyprint(positionlist[0].get_element())
    polyline = OSC.Polyline([0, 0.5], positionlist)
    traj = OSC.Trajectory('my_trajectory', False)
    traj.add_shape(polyline)
    prettyprint(traj.get_element())
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'))
    prettyprint(positionlist[0].get_element())
    polyline = OSC.Polyline([0, 0.5, 1, 1.5], positionlist)
    prettyprint(polyline.get_element())
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'))
    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)
    prettyprint(trajact.get_element())
trigcond = xosc.TimeHeadwayCondition(targetname, 0.4, xosc.Rule.greaterThan)

trigger = xosc.EntityTrigger('mytesttrigger', 0.2, xosc.ConditionEdge.rising,
                             trigcond, egoname)

event = xosc.Event('myfirstevent', xosc.Priority.overwrite)
event.add_trigger(trigger)

positionlist = []
positionlist.append(xosc.RelativeLanePosition(0, 0, 0, targetname))
positionlist.append(xosc.RelativeLanePosition(20, 0.5, 0, targetname))
positionlist.append(xosc.RelativeLanePosition(40, -0.5, 0, targetname))
positionlist.append(xosc.RelativeLanePosition(60, -1, 0, targetname))

polyline = xosc.Polyline([0, 0.5, 1, 1.5], positionlist)

traj = xosc.Trajectory('my_trajectory', False)
traj.add_shape(polyline)

trajact = xosc.FollowTrajectoryAction(traj, xosc.FollowMode.position,
                                      xosc.ReferenceContext.relative, 1, 0)

event.add_action('newspeed', trajact)

## create the act
man = xosc.Maneuver('my_maneuver')
man.add_event(event)

mangr = xosc.ManeuverGroup('mangroup')
mangr.add_actor('$owner')