Beispiel #1
0
def test_trafficswarmaction():

    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)

    source_action = OSC.TrafficSourceAction(10, 10, OSC.WorldPosition(),
                                            traffic, 100)

    OSC.prettyprint(source_action.get_element())

    swarm_action = OSC.TrafficSwarmAction(10, 20, 10, 2, 10, 'Ego', traffic)
    OSC.prettyprint(swarm_action.get_element())

    swarm_action = OSC.TrafficSwarmAction(10, 20, 10, 2, 10, 'Ego', traffic,
                                          10)
    OSC.prettyprint(swarm_action.get_element())
Beispiel #2
0
### create parameters
paramdec = pyoscx.ParameterDeclarations()

## loop to create cars, init and their reset actions

egoname = 'Ego'

targetname = 'Target'
entities = pyoscx.Entities()
init = pyoscx.Init()
act = pyoscx.Act('indef traffic')

for i in range(20):
    entities.add_scenario_object(
        targetname + str(i),
        pyoscx.CatalogReference('VehicleCatalog', 'car_yellow'))

    init.add_init_action(
        targetname + str(i),
        pyoscx.TeleportAction(pyoscx.LanePosition(100 + i * 20, 0, -1, 1)))
    init.add_init_action(
        targetname + str(i),
        pyoscx.AbsoluteSpeedAction(
            60,
            pyoscx.TransitionDynamics(pyoscx.DynamicsShapes.step,
                                      pyoscx.DynamicsDimension.time, 1)))

    event = pyoscx.Event('speedchange',
                         pyoscx.Priority.overwrite,
                         maxexecution=10)
    event.add_action('restart',
Beispiel #3
0
### create road
road = pyoscx.RoadNetwork(roadfile="../xodr/fabriksgatan.xodr",
                          scenegraph="../models/fabriksgatan.osgb")

### create parameters
paramdec = pyoscx.ParameterDeclarations()

## create entities

egoname = 'Ego'
targetname = 'Target'

entities = pyoscx.Entities()
entities.add_scenario_object(
    egoname, pyoscx.CatalogReference('VehicleCatalog', 'car_red'))

### create init

init = pyoscx.Init()

init.add_init_action(egoname,
                     pyoscx.TeleportAction(pyoscx.LanePosition(50, 0, 1, 0)))
init.add_init_action(
    egoname,
    pyoscx.AbsoluteSpeedAction(
        10,
        pyoscx.TransitionDynamics(pyoscx.DynamicsShapes.step,
                                  pyoscx.DynamicsDimension.time, 1)))

# create a router
Beispiel #4
0
def test_catalogreference():
    catref = OSC.CatalogReference('VehicleCatalog','S60')
    OSC.prettyprint(catref.get_element())
    catref.add_parameter_assignment('stuffs',1)
    OSC.prettyprint(catref.get_element())