예제 #1
0
def test_MapProperties():
    planeLevels = gnssShadowing.PlaneLevelList()
    planeLevels.append(1.0)
    mapProperties = gnssShadowing.MapProperties()
    min_x = 10.0
    min_y = 20.0
    width = 5
    height = 3
    res_x = res_y = 2.0
    mapProperties = gnssShadowing.MapProperties(min_x, min_y, width, height,
                                                res_x, res_y, planeLevels)
    assert mapProperties.m_min_x == min_x
    assert mapProperties.m_min_y == min_y
    assert mapProperties.m_num_cols == width
    assert mapProperties.m_num_rows == height
    assert mapProperties.m_x_resolution == res_x
    assert mapProperties.m_y_resolution == res_y
    assert mapProperties.m_plane_levels[0] == planeLevels[0]

    assert mapProperties.X(0) == min_x
    assert mapProperties.Y(0) == min_y
    assert mapProperties.X(width - 1) == min_x + (width - 1) * res_x
    assert mapProperties.Y(height - 1) == min_y + (height - 1) * res_y

    assert 0 == mapProperties.I(min_x)
    assert 0 == mapProperties.J(min_y)
    assert width - 1 == mapProperties.I(min_x + (width - 1) * res_x)
    assert height - 1 == mapProperties.J(min_y + (height - 1) * res_y)
예제 #2
0
def test_OccupancyMap():
    world = gnssShadowing.World("data/2017-03-28.tle", "data/uni.obj",
                                "Building")
    planeLevels = gnssShadowing.PlaneLevelList()
    planeLevels.extend([56.0])
    width_m = 800
    height_m = 400
    res_x = res_y = 2.0
    width = (int)(width_m / res_x)
    height = (int)(height_m / res_y)
    min_x = -width_m / 2.
    min_y = -height_m / 2.
    mapProperties = gnssShadowing.MapProperties(min_x, min_y, width, height,
                                                res_x, res_y, planeLevels)
    minimumElevation = gnssShadowing.deg2rad(5)
    mapper = gnssShadowing.Mapper(world, mapProperties, minimumElevation)
    occupancyMap = mapper.m_occupancyMap
    z = 0  # planeLevelIndex
    sumOccupied = 0
    for x in range(0, width):
        for y in range(0, height):
            if occupancyMap.isOccupied(x, y, z):
                sumOccupied += 1
    assert sumOccupied == 7557
    npMap = occupancyMap.getMapForLevel(z)
    assert type(npMap) == np.ndarray
    assert npMap.sum() == sumOccupied
def test_MapProblem():
    world = gnssShadowing.World("data/2017-03-28.tle", "data/uni.obj",
                                "Building")
    planeLevels = gnssShadowing.PlaneLevelList()
    planeLevels.extend([56.0])
    width_m = 800
    height_m = 400
    res_x = res_y = 10.0
    width = (int)(width_m / res_x)
    height = (int)(height_m / res_y)
    min_x = -width_m / 2.
    min_y = -height_m / 2.
    mapProperties = gnssShadowing.MapProperties(min_x, min_y, width, height,
                                                res_x, res_y, planeLevels)
    minimumElevation = gnssShadowing.deg2rad(5)
    mapper = gnssShadowing.Mapper(world, mapProperties, minimumElevation)
    dopMap = mapper.computeDOPMap(
        gnssShadowing.mkSeconds(2017, 3, 28, 12, 0, 0))

    maxHorizontalDOP = 5
    start = gnssShadowing.MapNode(0, 0)
    target = gnssShadowing.MapNode(1, 1)

    problem = gnssShadowing.MapProblem(maxHorizontalDOP, dopMap, start, target)

    assert type(problem.m_map) == gnssShadowing.DOPMap
    assert type(problem.m_maxHorizontalDOP) == float
    assert problem.targetReached(target) == True
    assert problem.targetReached(start) == False
    problem.computeCost(start, target)
    neighbors = problem.computeNeighbors(start)
    assert type(neighbors) == gnssShadowing.MapNodeList
    problem.computeHeuristic(start)
def test_MapProblemSolver():
    world = gnssShadowing.World("data/2017-03-28.tle", "data/uni.obj",
                                "Building")
    planeLevels = gnssShadowing.PlaneLevelList()
    planeLevels.extend([56.0])
    width_m = 800
    height_m = 400
    res_x = res_y = 10.0
    width = (int)(width_m / res_x)
    height = (int)(height_m / res_y)
    min_x = -width_m / 2.
    min_y = -height_m / 2.
    mapProperties = gnssShadowing.MapProperties(min_x, min_y, width, height,
                                                res_x, res_y, planeLevels)
    minimumElevation = gnssShadowing.deg2rad(5)
    mapper = gnssShadowing.Mapper(world, mapProperties, minimumElevation)
    dopMap = mapper.computeDOPMap(
        gnssShadowing.mkSeconds(2017, 3, 28, 12, 0, 0))

    maxHorizontalDOP = 5
    start = gnssShadowing.MapNode(0, 0)
    target = gnssShadowing.MapNode(1, 1)

    problem = gnssShadowing.MapProblem(maxHorizontalDOP, dopMap, start, target)

    solver = gnssShadowing.MapProblemSolver()
    path = solver.findShortestPath(problem)
    assert type(path) == gnssShadowing.MapNodeList
    assert path.size() == 3
    assert path.at(0).x == start.x
    assert path.at(0).y == start.y
    assert path.at(path.size() - 1).x == target.x
    assert path.at(path.size() - 1).y == target.y
def test_MapTimeProblem():
    world = gnssShadowing.World("data/2017-03-28.tle", "data/uni.obj",
                                "Building")
    planeLevels = gnssShadowing.PlaneLevelList()
    planeLevels.extend([56.0])
    width_m = 800
    height_m = 400
    res_x = res_y = 10.0
    width = (int)(width_m / res_x)
    height = (int)(height_m / res_y)
    min_x = -width_m / 2.
    min_y = -height_m / 2.
    mapProperties = gnssShadowing.MapProperties(min_x, min_y, width, height,
                                                res_x, res_y, planeLevels)
    minimumElevation = gnssShadowing.deg2rad(5)
    time = gnssShadowing.mkSeconds(2017, 3, 28, 12, 0, 0)
    timePerStep = 5  # in seconds
    mapper = gnssShadowing.MapperLazyTimesteps(world, mapProperties, time,
                                               timePerStep, minimumElevation)

    maxHorizontalDOP = 5
    start = gnssShadowing.MapTimeNode(0, gnssShadowing.MapNode(0, 0))
    target = gnssShadowing.MapTimeNode(0, gnssShadowing.MapNode(1, 1))
    maxHorizontalDOP = 5.
    costPerHorizontalDOP = 1.
    costPerGridStep = 1.
    costPerTimeStep = 1.
    costPerTimeTotal = 0.
    timeStepsPerStep = 1
    problem = gnssShadowing.MapTimeProblem(maxHorizontalDOP,
                                           costPerHorizontalDOP,
                                           costPerGridStep, costPerTimeStep,
                                           costPerTimeTotal, timeStepsPerStep,
                                           mapper, start, target)
    assert type(problem.m_maps) == gnssShadowing.MapperLazyTimesteps
    assert type(problem.m_maxHorizontalDOP) == float
    assert type(problem.m_costPerHorizontalDOP) == float
    assert type(problem.m_costPerGridStep) == float
    assert type(problem.m_costPerTimeStep) == float
    assert type(problem.m_costPerTimeTotal) == float
    assert type(problem.m_timeStepsPerStep) == int
    assert problem.targetReached(target) == True
    assert problem.targetReached(start) == False
    problem.computeCost(start, target)
    neighbors = problem.computeNeighbors(start)
    assert type(neighbors) == gnssShadowing.MapTimeNodeList
    problem.computeHeuristic(start)
예제 #6
0
def test_Mapper():
    world = gnssShadowing.World("data/2017-03-28.tle", "data/uni.obj",
                                "Building")
    planeLevels = gnssShadowing.PlaneLevelList()
    planeLevels.extend([56.0])
    min_x = 10.0
    min_y = 20.0
    width = 5
    height = 3
    res_x = res_y = 2.0
    mapProperties = gnssShadowing.MapProperties(min_x, min_y, width, height,
                                                res_x, res_y, planeLevels)
    minimumElevation = gnssShadowing.deg2rad(5)
    mapper = gnssShadowing.Mapper(world, mapProperties, minimumElevation)
    assert type(mapper.m_world) == gnssShadowing.World
    assert type(mapper.m_sats) == gnssShadowing.AvailableSats
    assert type(mapper.m_mapProperties) == gnssShadowing.MapProperties
    assert type(mapper.m_occupancyMap) == gnssShadowing.OccupancyMap
    assert type(mapper.m_visibilityMap) == gnssShadowing.VisibilityMap
    assert type(mapper.m_dopMap) == gnssShadowing.DOPMap

    # not initialized yet
    assert mapper.m_sats.getNumSats() == 0

    mapper.updateSats(gnssShadowing.mkSeconds(2017, 3, 28, 12, 0, 0))
    assert mapper.m_sats.getNumSats() == 21

    # not initialized yet
    sumVisible = 0
    z = 0
    for x in range(0, width):
        for y in range(0, height):
            sumVisible += mapper.m_visibilityMap.getItem(x, y, z).size()
    assert sumVisible == 0

    # not initialized yet
    hdop = mapper.m_dopMap.getHDOPMap(z)
    sumNotInvalidHDOP = 0
    for x in range(0, width):
        for y in range(0, height):
            if mapper.m_dopMap.getItem(x, y, z).getHorizontal() != -1:
                sumNotInvalidHDOP += 1
    assert np.sum(hdop != -1) == 0
    assert sumNotInvalidHDOP == 0
예제 #7
0
def test_DOPMap():
    world = gnssShadowing.World("data/2017-03-28.tle", "data/uni.obj",
                                "Building")
    planeLevels = gnssShadowing.PlaneLevelList()
    planeLevels.extend([56.0])
    width_m = 800
    height_m = 400
    res_x = res_y = 2.0
    width = (int)(width_m / res_x)
    height = (int)(height_m / res_y)
    min_x = -width_m / 2.
    min_y = -height_m / 2.
    mapProperties = gnssShadowing.MapProperties(min_x, min_y, width, height,
                                                res_x, res_y, planeLevels)
    minimumElevation = gnssShadowing.deg2rad(5)
    mapper = gnssShadowing.Mapper(world, mapProperties, minimumElevation)
    dopMap = mapper.computeDOPMap(
        gnssShadowing.mkSeconds(2017, 3, 28, 12, 0, 0))
    z = 0
    hdop = mapper.m_dopMap.getHDOPMap(z)
    assert type(hdop) == np.ndarray
    sumNotInvalidHDOP = 0
    for x in range(0, width):
        for y in range(0, height):
            if mapper.m_dopMap.getItem(x, y, z).getHorizontal() != -1:
                sumNotInvalidHDOP += 1
    assert np.sum(hdop != -1) == 79859
    assert sumNotInvalidHDOP == 79859

    hdop = dopMap.getHDOPMap(z)
    sumNotInvalidHDOP = 0
    for x in range(0, width):
        for y in range(0, height):
            if dopMap.getItem(x, y, z).getHorizontal() != -1:
                sumNotInvalidHDOP += 1
    assert np.sum(hdop != -1) == 79859
    assert sumNotInvalidHDOP == 79859

    sumHDOP = 0
    for x in range(0, width):
        for y in range(0, height):
            sumHDOP += mapper.m_dopMap.getItem(x, y, z).getHorizontal()
    assert int(sumHDOP * 10) == 526101
    assert int(np.sum(hdop)) == int(sumHDOP)
def test_MapTimeProblemSolver():
    world = gnssShadowing.World("data/2017-03-28.tle", "data/uni.obj",
                                "Building")
    planeLevels = gnssShadowing.PlaneLevelList()
    planeLevels.extend([56.0])
    width_m = 800
    height_m = 400
    res_x = res_y = 10.0
    width = (int)(width_m / res_x)
    height = (int)(height_m / res_y)
    min_x = -width_m / 2.
    min_y = -height_m / 2.
    mapProperties = gnssShadowing.MapProperties(min_x, min_y, width, height,
                                                res_x, res_y, planeLevels)
    minimumElevation = gnssShadowing.deg2rad(5)
    time = gnssShadowing.mkSeconds(2017, 3, 28, 12, 0, 0)
    timePerStep = 5  # in seconds
    mapper = gnssShadowing.MapperLazyTimesteps(world, mapProperties, time,
                                               timePerStep, minimumElevation)

    maxHorizontalDOP = 5
    start = gnssShadowing.MapTimeNode(0, gnssShadowing.MapNode(0, 0))
    target = gnssShadowing.MapTimeNode(0, gnssShadowing.MapNode(1, 1))
    maxHorizontalDOP = 5.
    costPerHorizontalDOP = 1.
    costPerGridStep = 1.
    costPerTimeStep = 1.
    costPerTimeTotal = 0.
    timeStepsPerStep = 1
    problem = gnssShadowing.MapTimeProblem(maxHorizontalDOP,
                                           costPerHorizontalDOP,
                                           costPerGridStep, costPerTimeStep,
                                           costPerTimeTotal, timeStepsPerStep,
                                           mapper, start, target)

    solver = gnssShadowing.MapTimeProblemSolver()
    path = solver.findShortestPath(problem)
    assert type(path) == gnssShadowing.MapTimeNodeList
    assert path.size() == 3
    assert path.at(0).position.x == start.position.x
    assert path.at(0).position.y == start.position.y
    assert path.at(path.size() - 1).position.x == target.position.x
    assert path.at(path.size() - 1).position.y == target.position.y
예제 #9
0
def test_ShadowMap():
    world = gnssShadowing.World("data/2017-03-28.tle", "data/uni.obj",
                                "Building")
    shadowing = world.m_shadowing
    now = gnssShadowing.mkSeconds(2017, 3, 28, 12, 0, 0)

    idx = 57
    horizontal = world.m_satStore.getSat(idx).findECEF(now).toENU(
        world.m_origin).toHorizontal()
    transformation = shadowing.computeTransformation(horizontal)
    contour = shadowing.computeContourFromTransformation(transformation)
    planeLevel = 0
    eps = 1e-3
    vol = shadowing.computeShadowVolume(contour, transformation, planeLevel,
                                        eps)
    planeLevels = gnssShadowing.PlaneLevelList()
    planeLevels.extend([56.0])
    min_x = 10.0
    min_y = 20.0
    width = 5
    height = 3
    res_x = res_y = 2.0

    mapProperties = gnssShadowing.MapProperties(min_x, min_y, width, height,
                                                res_x, res_y, planeLevels)

    shadowMap1 = gnssShadowing.ShadowMap(mapProperties)
    assert type(shadowMap1.m_properties) == gnssShadowing.MapProperties
    z = 0  # planeLevelIndex
    for x in range(0, width):
        for y in range(0, height):
            assert shadowMap1.isShadowed(x, y, z) == False
    map1 = shadowMap1.getMapForLevel(0)
    assert np.sum(map1 != 0) == 0
    shadowMap2 = gnssShadowing.ShadowMap(mapProperties, vol)
    map2 = shadowMap2.getMapForLevel(0)

    # the reference value (11) was computed for sat #57 in "data/2017-03-28.tle","data/uni.obj" on commit 23e15ee656dcaf805d59ab68965718800f29f1fa
    assert np.sum(map2 != 0) == 11
예제 #10
0
def test_MapCoordinateConverter():
    world = gnssShadowing.World("data/2017-03-28.tle", "data/uni.obj",
                                "Building")
    planeLevels = gnssShadowing.PlaneLevelList()
    planeLevels.extend([56.0])
    width_m = 10
    height_m = 10
    res_x = res_y = 1.0
    width = (int)(width_m / res_x)
    height = (int)(height_m / res_y)
    min_x = -width_m / 2.
    min_y = -height_m / 2.
    mapProperties = gnssShadowing.MapProperties(min_x, min_y, width, height,
                                                res_x, res_y, planeLevels)

    conv = gnssShadowing.MapCoordinateConverter(mapProperties, world.m_origin)
    a = conv.gridCoordinateToGeodetic(gnssShadowing.MapNode(0, 0))
    b = conv.geodeticToGridCoordinate(a)
    c = conv.geodeticToGridCoordinateF(a)
    assert type(a) == gnssShadowing.Geodetic
    assert type(b) == gnssShadowing.MapNode
    assert type(c) == gnssShadowing.MapNodeF
예제 #11
0
def test_VisibilityMap():
    world = gnssShadowing.World("data/2017-03-28.tle", "data/uni.obj",
                                "Building")
    planeLevels = gnssShadowing.PlaneLevelList()
    planeLevels.extend([56.0])
    width_m = 800
    height_m = 400
    res_x = res_y = 2.0
    width = (int)(width_m / res_x)
    height = (int)(height_m / res_y)
    min_x = -width_m / 2.
    min_y = -height_m / 2.
    mapProperties = gnssShadowing.MapProperties(min_x, min_y, width, height,
                                                res_x, res_y, planeLevels)
    minimumElevation = gnssShadowing.deg2rad(5)
    mapper = gnssShadowing.Mapper(world, mapProperties, minimumElevation)
    mapper.computeDOPMap(gnssShadowing.mkSeconds(2017, 3, 28, 12, 0, 0))
    visibilityMap = mapper.m_visibilityMap
    sumVisible = 0
    z = 0
    for x in range(0, width):
        for y in range(0, height):
            sumVisible += mapper.m_visibilityMap.getItem(x, y, z).size()
    assert sumVisible == 1529510