Example #1
0
def run():
    need_merge = False
    atlaas_tiles = glob.glob("atlaas.*x*.tif")
    for fatlaas in atlaas_tiles:
        fregion = "region.%s.png"%fatlaas.split('.')[1]
        need_convert = True
        file_exists = False
        if os.path.isfile(fregion):
            file_exists = True
            satlaas = os.stat(fatlaas)
            sregion = os.stat(fregion)
            if satlaas.st_mtime <= sregion.st_mtime:
                need_convert = False
        if need_convert:
            logger.debug(fregion)
            if file_exists:
                atlaas.tile_to_region(fatlaas, fregion+".tmp")
                merge(fregion+".tmp", fregion)
                os.unlink(fregion+".tmp")
            else:
                atlaas.tile_to_region(fatlaas, fregion)
            need_merge = True
    if need_merge:
        sys.stdout = devnull
        atlaas.merge("region.*x*.png", "region.png")
        sys.stdout = stdout
Example #2
0
def run():
    need_merge = False
    atlaas_tiles = glob.glob("atlaas.*x*.tif")
    for fatlaas in atlaas_tiles:
        fregion = "region.%s.png" % fatlaas.split('.')[1]
        need_convert = True
        file_exists = False
        if os.path.isfile(fregion):
            file_exists = True
            satlaas = os.stat(fatlaas)
            sregion = os.stat(fregion)
            if satlaas.st_mtime <= sregion.st_mtime:
                need_convert = False
        if need_convert:
            logger.debug(fregion)
            if file_exists:
                atlaas.tile_to_region(fatlaas, fregion + ".tmp")
                merge(fregion + ".tmp", fregion)
                os.unlink(fregion + ".tmp")
            else:
                atlaas.tile_to_region(fatlaas, fregion)
            need_merge = True
    if need_merge:
        sys.stdout = devnull
        atlaas.merge("region.*x*.png", "region.png")
        sys.stdout = stdout
Example #3
0
def main(argv=[]):
    if len(argv) == 2:
        bounds = int(argv[1])
        tilesrange = range(-bounds, bounds)
        tiles = ['%ix%i'%(x,y) for x in tilesrange for y in tilesrange]
    else:
        if len(argv) < 4:
            print(__doc__)
            return 1
        x0, y0, x1, y1 = [float(arg) for arg in argv[1:5]]
        cost, tiles = tiles_for_path((x0,y0), (x1, y1))
    data = process(tiles)
    print(data)
    if data:
        atlaas.merge("region.*x*.png", "region.png")
    return 0
Example #4
0
def main(argv=[]):
    if len(argv) == 2:
        bounds = int(argv[1])
        tilesrange = range(-bounds, bounds)
        tiles = ['%ix%i' % (x, y) for x in tilesrange for y in tilesrange]
    else:
        if len(argv) < 4:
            print(__doc__)
            return 1
        x0, y0, x1, y1 = [float(arg) for arg in argv[1:5]]
        cost, tiles = tiles_for_path((x0, y0), (x1, y1))
    data = process(tiles)
    print(data)
    if data:
        atlaas.merge("region.*x*.png", "region.png")
    return 0
Example #5
0
mtime = 0
jpg_pose = None
rospy.init_node("atlaas_grid")
atlaas_path = rospy.get_param("atlaas_path", os.environ.get("ATLAAS_PATH", "."))
filepath = os.path.join(atlaas_path, "atlaas.jpg")
mergedpath = os.path.join(atlaas_path, "out.tif")
pub = rospy.Publisher("/grid", OccupancyGrid, queue_size=5, latch=True)
pub_glob = rospy.Publisher("/grid_glob", OccupancyGrid, queue_size=5, latch=True)

while not rospy.is_shutdown():
    rospy.sleep(0.1)
    if not pub.get_num_connections() and not pub_glob.get_num_connections():
        continue  # skip if no client
    if not os.path.isfile(filepath):
        continue
    filestat = os.stat(filepath)
    if filestat.st_mtime == mtime:
        continue  # skip if not modified
    mtime = filestat.st_mtime
    grid = atlaas8u_grid(filepath, stamp=rospy.Time.now())
    pose = grid.info.origin.position.x, grid.info.origin.position.y
    pub.publish(grid)
    if not jpg_pose or pose != jpg_pose:
        jpg_pose = pose
        # if we did atlaas::slide (the internal tiles in memory moved)
        atlaas.merge(os.path.join(atlaas_path, "atlaas.*x*.tif"), mergedpath)
        if not os.path.isfile(mergedpath):
            continue  # skip if no tiles on disk
        pub_glob.publish(atlaas_grid(mergedpath, stamp=rospy.Time.now()))
Example #6
0
    test.save_currents()
    del test

# 1st erase data in tiles so as to have same size in merge() without noise
for fatlaas in glob.glob("atlaas.*x*.tif"):
    g = gdal2(fatlaas)
    g.bands *= 0
    g.save()
    fregion = "region.%s.png"%fatlaas.split('.')[1]
    atlaas.tile_to_region(fatlaas, fregion)

for fregion in glob.glob("region.*x*.png"):
    zero(fregion) # empty data

pcd_id = 0
patern = 'cloud.%05i.pcd'

test = atlaas.Atlaas()
test.init(120.0, 120.0, 0.1, 377016.5, 4824342.9, 141.0, 31, True)

while os.path.isfile(patern%pcd_id):
    test.merge_file(patern%pcd_id)
    test.save_currents()
    atlaas.merge('atlaas.*x*.tif', 'merged.atlaas.%05i.tif'%pcd_id, compress=True)
    for fatlaas in glob.glob("atlaas.*x*.tif"):
        fregion = "region.%s.png"%fatlaas.split('.')[1]
        if os.stat(fatlaas).st_mtime > os.stat(fregion).st_mtime:
            atlaas.tile_to_region(fatlaas, fregion)
    atlaas.merge('region.*x*.png', 'merged.region.%05i.png'%pcd_id)
    pcd_id += 1
Example #7
0
jpg_pose = None
rospy.init_node("atlaas_grid")
atlaas_path = rospy.get_param("atlaas_path",
                              os.environ.get("ATLAAS_PATH", "."))
filepath = os.path.join(atlaas_path, "atlaas.jpg")
mergedpath = os.path.join(atlaas_path, "out.tif")
pub = rospy.Publisher("/grid", OccupancyGrid, queue_size=5, latch=True)
pub_glob = rospy.Publisher("/grid_glob",
                           OccupancyGrid,
                           queue_size=5,
                           latch=True)

while not rospy.is_shutdown():
    rospy.sleep(0.1)
    if not pub.get_num_connections() and not pub_glob.get_num_connections():
        continue  # skip if no client
    filestat = os.stat(filepath)
    if filestat.st_mtime == mtime:
        continue  # skip if not modified
    mtime = filestat.st_mtime
    grid = atlaas8u_grid(filepath, stamp=rospy.Time.now())
    pose = grid.info.origin.position.x, grid.info.origin.position.y
    pub.publish(grid)
    if not jpg_pose or pose != jpg_pose:
        jpg_pose = pose
        # if we did atlaas::slide (the internal tiles in memory moved)
        atlaas.merge(os.path.join(atlaas_path, "atlaas.*x*.tif"), mergedpath)
        if not os.path.isfile(mergedpath):
            continue  # skip if no tiles on disk
        pub_glob.publish(atlaas_grid(mergedpath, stamp=rospy.Time.now()))