コード例 #1
0
def test_axels():
    fa = OSC.Axle(2, 2, 2, 1, 1)
    ra = OSC.Axle(1, 1, 2, 1, 1)
    aa = OSC.Axle(1, 1, 2, 1, 1)
    axels = OSC.Axles(fa, ra)
    axels.add_axle(aa)
    prettyprint(axels.get_element())
コード例 #2
0
def test_lane():
    lane = pyodrx.Lane()
    lane._set_lane_id(1)
    prettyprint(lane.get_element())
    lane = pyodrx.Lane(pyodrx.LaneType.driving,1,1,1,1,2)
    lane._set_lane_id(1)
    prettyprint(lane.get_element())
コード例 #3
0
def test_properties():
    prop = OSC.Properties()
    prop.add_file('myprops.xml')
    prettyprint(prop.get_element())
    prop.add_property('mything', '2')
    prettyprint(prop.get_element())
    prop.add_property('theotherthing', 'true')
コード例 #4
0
def test_maneuver():
    event = OSC.Event('myfirstevent', OSC.Priority.overwrite)
    event.add_trigger(trigger)
    event.add_action('newspeed', speedaction)
    man = OSC.Maneuver('my maneuver')
    man.add_event(event)
    prettyprint(man.get_element())
コード例 #5
0
def test_connection():
    con = pyodrx.Connection(1, 2, pyodrx.ContactPoint.start, 5)

    con.add_lanelink(1, -1)
    con.add_lanelink(2, -2)

    prettyprint(con.get_element())
コード例 #6
0
def test_links():

    links = pyodrx.links._Links()
    prettyprint(links.get_element())
    link = pyodrx.links._Link('successor', '1')
    links.add_link(link)
    prettyprint(links.get_element())
コード例 #7
0
def test_roadmark():
    mark = pyodrx.RoadMark(pyodrx.RoadMarkType.solid, 0.2)
    prettyprint(mark.get_element())
    mark = pyodrx.RoadMark(pyodrx.RoadMarkType.solid, 0.2, 1, 1, 1,
                           pyodrx.MarkRule.no_passing,
                           pyodrx.RoadMarkColor.standard)
    prettyprint(mark.get_element())
コード例 #8
0
def test_roadline():
    line = pyodrx.RoadLine()

    prettyprint(line.get_element())
    line = pyodrx.RoadLine(1, 2, 3, 5, 1, pyodrx.MarkRule.no_passing,
                           pyodrx.RoadMarkColor.standard)
    prettyprint(line.get_element())
コード例 #9
0
def test_controller():
    prop = OSC.Properties()
    prop.add_property('mything', '2')
    prop.add_property('theotherthing', 'true')

    cnt = OSC.Controller('mycontroler', prop)
    prettyprint(cnt.get_element())
コード例 #10
0
def test_lanelinker():

    lane = pyodrx.Lane(a=3)
    lane._set_lane_id(1)
    lane.add_link('successor', '2')

    prettyprint(lane.get_element())
コード例 #11
0
def test_environmentaction():
    tod = OSC.TimeOfDay(True,2020,10,1,18,30,30)
    weather = OSC.Weather(OSC.CloudState.free,100,0,1,OSC.PrecipitationType.dry,1)
    rc = OSC.RoadCondition(1)

    env = OSC.Environment(tod,weather,rc)
    ea = OSC.EnvironmentAction('myaction',env)
    prettyprint(ea.get_element())
コード例 #12
0
def test_poly3profileshape():
    profile = xodr.elevation._Poly3Profile(0, 0, 0, 0, 0, 0)

    prettyprint(profile.get_element('shape'))

    profile = xodr.elevation._Poly3Profile(0, 0, 0, 0, 0)
    with pytest.raises(ValueError):
        prettyprint(profile.get_element('shape'))
コード例 #13
0
def test_lanes():
    centerlane = pyodrx.Lane()
    ls = pyodrx.LaneSection(0,centerlane)
    lanes = pyodrx.Lanes()
    lanes.add_lanesection(ls)
    lo = pyodrx.LaneOffset(0,1,2,3,4)
    lanes.add_laneoffset(lo)
    prettyprint(lanes.get_element())
コード例 #14
0
def test_paramdeclaration():

    pardec = OSC.ParameterDeclarations()
    pardec.add_parameter(
        OSC.Parameter('myparam1', OSC.ParameterType.integer, '1'))
    pardec.add_parameter(
        OSC.Parameter('myparam1', OSC.ParameterType.double, '0.01'))
    prettyprint(pardec.get_element())
コード例 #15
0
def test_conditiongroup():
    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)

    prettyprint(condgr.get_element())
コード例 #16
0
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())
コード例 #17
0
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())
コード例 #18
0
def test_route():
    route = OSC.Route('myroute')

    route.add_waypoint(OSC.WorldPosition(0, 0, 0, 0, 0, 0),
                       OSC.RouteStrategy.shortest)
    route.add_waypoint(OSC.WorldPosition(1, 1, 0, 0, 0, 0),
                       OSC.RouteStrategy.shortest)

    prettyprint(route.get_element())
コード例 #19
0
def test_storyboard_act_input():

    egoname = "Ego"
    targetname = "target"

    init = OSC.Init()
    step_time = OSC.TransitionDynamics(OSC.DynamicsShapes.step,
                                       OSC.DynamicsDimension.time, 1)

    egospeed = OSC.AbsoluteSpeedAction(0, step_time)
    egostart = OSC.TeleportAction(OSC.LanePosition(25, 0, -3, 0))

    targetspeed = OSC.AbsoluteSpeedAction(0, step_time)
    targetstart = OSC.TeleportAction(OSC.LanePosition(15, 0, -2, 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 = OSC.TimeHeadwayCondition(targetname,0.1,OSC.Rule.greaterThan)

    # trigger = OSC.EntityTrigger('mytesttrigger',0.2,OSC.ConditionEdge.rising,trigcond,egoname)
    trigger = OSC.ValueTrigger(
        'starttrigger', 0, OSC.ConditionEdge.rising,
        OSC.SimulationTimeCondition(3, OSC.Rule.greaterThan))
    event = OSC.Event('myfirstevent', OSC.Priority.overwrite)
    event.add_trigger(trigger)

    # sin_time = OSC.TransitionDynamics(OSC.DynamicsShapes.linear,OSC.DynamicsDimension.time,3)
    action = OSC.LongitudinalDistanceAction(-4,
                                            egoname,
                                            max_deceleration=3,
                                            max_speed=50)
    event.add_action('newspeed', action)

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

    mangr = OSC.ManeuverGroup('mangroup')
    mangr.add_actor(targetname)
    mangr.add_maneuver(man)

    starttrigger = OSC.ValueTrigger(
        'starttrigger', 0, OSC.ConditionEdge.rising,
        OSC.SimulationTimeCondition(0, OSC.Rule.greaterThan))
    act = OSC.Act('my_act', starttrigger)
    act.add_maneuver_group(mangr)

    ## create the storyboard
    sb = OSC.StoryBoard(init)
    sb.add_act(act)

    prettyprint(sb.get_element())
コード例 #20
0
def test_road_type():
    rt = pyodrx.opendrive._Type(pyodrx.RoadType.motorway, 0, 'SE')
    prettyprint(rt.get_element())

    rt = pyodrx.opendrive._Type(pyodrx.RoadType.motorway,
                                0,
                                'SE',
                                speed='no limit')
    prettyprint(rt.get_element())
コード例 #21
0
def test_miscobj():
    bb = OSC.BoundingBox(2, 5, 1.5, 1.5, 0, 0.2)
    veh = OSC.MiscObject('mycar', 100, OSC.MiscObjectCategory.obstacle, bb)

    prettyprint(veh.get_element())
    veh.add_property_file('propfile.xml')
    veh.add_property('myprop', '12')
    param = OSC.Parameter('mypar', OSC.ParameterType.integer, '1')
    veh.add_parameter(param)
    prettyprint(veh.get_element())
コード例 #22
0
def test_assign_controller_action():
    prop = OSC.Properties()
    prop.add_property('mything','2')
    prop.add_property('theotherthing','true')

    cnt = OSC.Controller('mycontroller',prop)
    
    
    aca = OSC.AssignControllerAction(cnt)
    prettyprint(aca.get_element())
コード例 #23
0
def test_arc():
    arc = pyodrx.Arc(1,length = 1)
    
    p = arc.get_element()
    prettyprint(p)

    arc = pyodrx.Arc(1,angle = 1)
    
    p = arc.get_element()
    prettyprint(p)
コード例 #24
0
def test_link():
    link = pyodrx.links._Link('successor', '1')

    prettyprint(link.get_element())

    link = pyodrx.links._Link('successor',
                              '1',
                              element_type=pyodrx.ElementType.road,
                              contact_point=pyodrx.ContactPoint.start)

    prettyprint(link.get_element())
コード例 #25
0
def test_relativeobjectposition():

    pos = OSC.RelativeObjectPosition('Ego', 1, 2, 0)
    prettyprint(pos.get_element())

    pos = OSC.RelativeObjectPosition('Target',
                                     1,
                                     2,
                                     0,
                                     orientation=OSC.Orientation(h=0.2))
    prettyprint(pos.get_element())
コード例 #26
0
def test_repeated_object():
    object1 = pyodrx.Object(s=10.0,
                            t=-2,
                            dynamic=pyodrx.Dynamic.no,
                            orientation=pyodrx.Orientation.positive,
                            zOffset=0.00,
                            height=1.0,
                            Type=pyodrx.ObjectType.pole)
    object1.repeat(100, 50)
    road = pyodrx.create_straight_road(0)
    road.add_object(object1)
    prettyprint(road.get_element())
コード例 #27
0
def test_nurbs():
    cp1 = OSC.ControlPoint(OSC.WorldPosition(), 1, 0.1)
    cp2 = OSC.ControlPoint(OSC.WorldPosition(), 2, 0.2)
    cp3 = OSC.ControlPoint(OSC.WorldPosition(), 3, 0.3)

    nurb = OSC.Nurbs(2)
    nurb.add_control_point(cp1)
    nurb.add_control_point(cp2)
    nurb.add_control_point(cp3)
    nurb.add_knots([5, 4, 3, 2, 1])

    prettyprint(nurb.get_element())
コード例 #28
0
def test_pedestrian():
    bb = OSC.BoundingBox(2, 5, 1.5, 1.5, 0, 0.2)
    veh = OSC.Pedestrian('myped', 'ped', 100,
                         OSC.PedestrianCategory.pedestrian, bb)

    prettyprint(veh.get_element())
    veh.add_property_file('propfile.xml')
    veh.add_property('myprop', '12')
    param = OSC.Parameter('mypar', OSC.ParameterType.integer, '1')
    veh.add_parameter(param)

    prettyprint(veh.get_element())
コード例 #29
0
def test_entities():
    bb = OSC.BoundingBox(2, 5, 1.5, 1.5, 0, 0.2)
    fa = OSC.Axle(2, 2, 2, 1, 1)
    ba = OSC.Axle(1, 1, 2, 1, 1)
    veh = OSC.Vehicle('mycar', OSC.VehicleCategory.car, bb, fa, ba, 150, 10,
                      10)

    entities = OSC.Entities()
    entities.add_scenario_object('Ego', veh)
    entities.add_scenario_object('Target_1', veh)
    entities.add_entity_bytype('Target_2', OSC.ObjectType.vehicle)
    entities.add_entity_byref('Target_3', 'something')
    prettyprint(entities.get_element())
コード例 #30
0
def test_trafficdefinition():
    prop = OSC.Properties()
    prop.add_file('mycontrollerfile.xml')
    controller = OSC.Controller('mycontroller', prop)

    traffic = OSC.TrafficDefinition('my traffic')
    traffic.add_controller(controller, 0.5)
    traffic.add_controller(
        OSC.CatalogReference('ControllerCatalog', 'my controller'), 0.5)

    traffic.add_vehicle(OSC.VehicleCategory.car, 0.9)
    traffic.add_vehicle(OSC.VehicleCategory.bicycle, 0.1)

    prettyprint(traffic.get_element())