DynamicMap¶
This is the main class of the map. It presents all the necessary methods
for updating and obtaining the map. It incorporates some utilities like a simple
visualizations of the map using matplotlib scatter plots and methods for
saving and loading maps.
This is a grid-based map, where each square cell represents some portion of the 3D space. The mapping from real world coordinates (represented by 3 floating point numbers: x, y, z) to the grid-cell coordinates (3 integer numbers) is done using the grid_size parameter. In this library we refer as point to a coordinate in the real world and as cell to the coordinate of a grid in the map.
The map is built using a hash table where the keys to are the cell coordinates
and the values are instances of the class DynamicNode. This data type
should be space efficient for sparse maps and provides fast access times for
the updating operations.
The following example shows how to create a map with two states and two possible observable symbols. The B matrix holds the emission probabilities, that is, how probable is to observe each symbols for every state the HMM can be. In most applications this will be the sensor model.
The highlighted lines create the map object dynmap and updates it with a set of points called some_data. The data is just a list of points where some symbol (in this case ‘hit’) was observed. The cells that form the ray from the camera to the observed symbol, are actually observed with the ‘miss’ symbol.
The example also saves the map to a file, some_file.map and then plots the resulting map as a 3D scatter plot.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | import DynamicMap
# Defines the size of the square boxes that form the grid
grid_size = 0.1
# Parameters of the HMM. Symbol and states names, with the
# A (transition probability) and B (emission) matrix.
symbols = ['hit', 'miss']
states = ['occ', 'empty']
A = array([[0.9, 0.1], [0.1, 0.9]])
B = array([[0.8, 0.2], [0.4, 0.6]])
# x, y, z, theta_x, theta_y, theta_z of the sensor.
cam_pose = (0, 0, 0, 0, 0, 0)
# Creates the map.
dynmap = DynamicMap(grid_size, symbols, states, A, B)
# Updates with same data.
dynmap.update_scan(some_data, 'hit', cam_pose, 'miss')
# Save the map to a file
dynmap.save_map(dynmap, 'some_file.map')
# Visualize the map
dynmap.plot_occupied_space()
|
API¶
Next, find the public API of the class, the full list of methods (including the _-prefixed ones) can be found in DynamicMap - All Members.