The tools module reference

Data Manager

class tools.data_manager.DataManager(date)[source]

This class handles downloading, extracting and storing data to be used by the main application.

get_data(key=None)[source]

This function gets data from the data manager’s data dictionary.

Returns:value of data at key
load_all()[source]

This function loads both the GPS and lidar data.

Returns:None
load_gps()[source]

This function loads data into the data manager’s data dictionary.

Returns:None
load_lidar(num_samples, pickled=None, delete_pickle=None)[source]

This function loads lidar, with the option to use a pickled file.

Parameters:
  • num_samples (int.) – Number of samples to load
  • pickled (str.) – If pickled=’pickled’, load from existing pickle of lidar, otherwise use existing and save a pickle of the data.
  • delete_pickle (str.) – If delete_pickle=’delete’, delete any existing pickle of lidar.
setup_data_files(data_type)[source]

This function sets up data files by downloading and extracting them into the data directory.

Parameters:data_type (str.) – Selects lidar or GPS data.
Returns:None

Data Loader

This class is responsible for precessing data correctly corresponding to the user’s choice.

class tools.data_loader.DataLoader(choose)[source]

A class to load data according to user’s choose, and do some preprocess to data. It can be usedin this way:

dataloader = Dataloader(choose) dataloader.get_gps_dictionary() dataloader.get_gps_range()

get_gps_dictionary()[source]
Returns:A dictionary contains three gps coordinate.
get_gps_range()[source]

This function return a tuple contains three tuples like(tuple1, tuple2, tuple3) tuple1 is a tuple contains range of latitude(min, max) tuple2 is a tuple contains range of longitude(min, max) tuple3 is a tuple contains range of altitude(min, max) :return: A tuple contains three tuples contains range of three GPS coordinate

load_data()[source]

Load the data chosen by user, and get the gps’s three coordinate from data file. :return: A dictionary contains three gps coordinate.

Downloading compressed files

This script downloads a tar file from the UMich robotics dataset

code referenced from: http://blog.ppkt.eu/2014/06/python-urllib-and-tarfile/

tools.download_tar.download_tar(base_name, date, data_type)[source]

This function downloads the tar file and puts it in the data directory.

Parameters:
  • base_name (str.) – Base url
  • date (str.) – Date to select in the data set.
  • data_type (str.) – Selects the type of data to download (lidar or GPS).
Returns:

str. – name of file that was downloaded

tools.download_tar.ensure_data_dir_exists()[source]

This function makes sure that there is a data directory in which to put the downloaded files.

Returns:None

Extracting compressed files

tools.tar_extract.tar_extract(file_name)[source]

This function extracts a compressed .tar or .tar.gz file.

Parameters:file_name (str.) – File name to extract.
Returns:None

Filtering NaN values

tools.filter_nan.filter_nan(file_name)[source]

This function filters out NaN values from a csv file.

Parameters:file_name (str.) – Name of csv file to filter.
Returns:None

Getting selectable dates for the UMich data set

dates referenced from: http://robots.engin.umich.edu/nclt/downloader.py

tools.get_dates_umich.get_dates_umich()[source]

These are all the selectable dates in the UMich long term robotics dataset.

Returns:list – all of the available dates that can be downloaded

Reading data from the Hokuyo lidar scanner

code referenced from: http://robots.engin.umich.edu/nclt/python/read_hokuyo_30m.py

tools.read_hokuyo_30m.convert(x_s)[source]

This function converts the raw hokuyo data into meters.

Parameters:x_s – scaled data
Returns:float64 – distance in meters
tools.read_hokuyo_30m.read_hokuyo(filename, max_samples=1000000)[source]

This function reads the hokuyo data from a binary file.

Parameters:
  • filename (str.) – Binary file to read.
  • max_samples – Maximum number of samples that will be read.
Returns:

list – lidar data in cartesian coordinates

Staticmap API function overrides

Modification to the original staticmaps API, which can be found at https://github.com/komoot/staticmap/blob/master/staticmap/staticmap.py

class tools.static_map_base_layer.StaticMapBaseLayer(width, height, padding)[source]

This is a overide class inherited from StaticMap. We overide some functions there to get something we want.

extract_line_points()[source]

This method is not in the original API This function extract line features. :return: points((px, py),(),…)

render_without_features(zoom=None, center=None)[source]

render static map with all map features that were added to map before :param zoom: optional zoom level, will be optimized automatically if not given. :type zoom: int :param center: optional center of map, will be set automatically from markers if not given. :type center: list :return: PIL image instance :rtype: Image.Image

Using GPS data with the staticmap API

This file is used to generate all points needed for plot in real-time.

tools.staticmap_for_gps.divide_coordinates(coordinates)[source]

Divide coordinates into about 50 pieces for following use. :param coordinates: coordinates contains gps data. :return: divided coordinates

tools.staticmap_for_gps.generate_coordinates(data_dict)[source]

This function preprocess gps data to make it useful for future use. :param data_dict: input gps data from dataManager :return: coordinates[[lng, lat], [], …]

tools.staticmap_for_gps.map_for_gps(data_dict, data_dir)[source]

This function is used to generate essential (px_x, px_y) coordinates to draw path. :param data_dict: where to get data :param data_dir: where to put output picture :return: x_coordinates and y_coordinates in pixels for gps data

tools.staticmap_for_gps.map_for_gps_gif()[source]

This function is used to generate 48 pictures to generate gif.