-
Notifications
You must be signed in to change notification settings - Fork 0
Package documentation: terrain
The terrain package contains functions necessary for analyzing map data to identify choke points, split the map into logical zones, create potential fields etc.
- potential.py
- terrain_analysis.py
- zone.py
Contains implementation of potential functions.
Note: This function will be ported to mapworks.visualizer shortly.
view_potential(potential) displays the potential field indicated in potential as a color graded map with yellow for highest potential and blue for lowest. Here, potential is a 2D array of potential height values.
view_potential(potential, plot_type) displays the potential in a selected plot type. Plot type can be one of the following:
- 'colorgraded': Default type. Color graded map with yellow for highest potential and blue for lowest.
- '3d_surface': 3D surface plot for potential.
- 'contour': Contour plot.
coulomb(map_data) generates a potential field (2D array of potential heights) based on Coulomb repulsion or inverse r^2 rule. Requires scipy.
Shaping Parameters:
- d0: Fall off parameter.
- nu: Potential height parameter.
- scale: Scale. Similar to fall off.
coulomb(map_data, goal) generates an attractive paraboloidal potential field centred at the (x, y) tuple goal.
Shaping Parameters:
- xi: Attractive force parameter.
manhattan(map_data) creates a potential field that decays linearly with distance from the nearest map obstacle.
Shaping Parameters:
- max_depth: Maximum depth beyond which potential flattens out.
- return_depth_vector: If set to True, a list of depth vectors is also returned. The nth depth vector is a list of tuples(x, y) at depth n.
distance_transform(map_data) achieves exactly the same thing as manhattan at less than 1% of the time. Requires scipy however.
Implements the TerrainAnalyzer class that identifies choke points and splits the map into logical zones.
Note: This function will be ported to mapworks.visualizer shortly.
TerrainAnalyzer.view_terrain() displays the map split into logical zones.
- grid=False can be used to turn off the grid.
- gates=False if you don't want to see gate points marked in green.
- graph=False to turn off the connected graph of zones.
- TerrainAnalyzer.map_data: The passable map.
- TerrainAnalyzer.map_size: [m, n] as in map_data.shape.
- TerrainAnalyzer.height_map: manhattan potential field.
- TerrainAnalyzer.height_vector: list of lists. The nth list is a list of points at height n.
- TerrainAnalyzer.max_height: Maximum height of potential field.
- TerrainAnalyzer.zone_map: 2D array of same size as map_data. Contains zone id of each tile.
- TerrainAnalyzer.zone_no: Number of logical zones.
- TerrainAnalyzer.zones: List of zone type objects. See zone.py below.
- TerrainAnalyzer.gate_points: List of points at the boundaries to zones.
Implements Zone type objects for the TerrainAnalyzer.
Zone.update_center() is used by TerrainAnalyzer to calculate mean of all points in the zone.
Zone.add_gate_point(adj_zone_id, gate_point) is used by TerrainAnalyzer to add a gate point to an adjacent zone.
- Zone.zone_id: Identification number. Starts from 0.
- Zone.points: List of points in the zone.
- Zone.size: No. of points in the zone.
- Zone.center: Center point (mean) of zone.
- Zone.entry_points: Dictionary with keys being the adjacent zone ids. Values are corresponding gate_points to these zones.