Main Content

bpsEncoder

Basis point set encoder

Since R2024a

    Description

    The bpsEncoder object creates an encoder that uses a set of basis points to derive a compact and fixed representation of map environments for motion planning. You must use the encode method of the bpsEncoder object to encode the map. You can then use the encoded map for motion planning with deep learning based techniques such as the Motion Planning Networks (MPNet) and deep-learning-based Covariant Hamiltonian Optimization for Motion Planning (CHOMP). For information about how basis point set encoding is used with MPNet and deep-learning-based CHOMP, see Get Started with Motion Planning Networks (Navigation Toolbox) and dlCHOMP, respectively. The bpsEncoder object and its encode function implements the basis point set encoding algorithm specified in [1].

    Creation

    Description

    bpsObj = bpsEncoder creates a basis point set (BPS) encoder object with default properties.

    example

    bpsObj = bpsEncoder(arrangement) specifies the arrangement for basis point sets. This syntax sets the Arrangement property of the BPS encoder object to the specified value.

    bpsObj = bpsEncoder(arrangement,encodingSize) also specifies the encoding size in addition to the arrangement. The encoding size represents the number of basis points to use for encoding the map. This syntax sets the EncodingSize property of the BPS encoder object to the specified value.

    bpsObj = bpsEncoder(___,Name=Value) specifies additional properties and their values using one or more name-value arguments. Using this syntax, you can set Center, Radius, and Dimensions properties.

    For example, bpsEncoder(arragement,Center=[10 10]) sets the value of Center property to [10 10].

    Properties

    expand all

    This property is read-only.

    Basis point set arrangement, specified as any one of these values: "uniform-ball", "uniform-ball-3d", "rectangular-grid", or "rectangular-grid-3d".

    Data Types: char | string

    This property is read-only.

    Number of basis points to compute for encoding the map environment, specified as a positive integer scalar, 1-by-2 vector, or 1-by-3 vector.

    • For "uniform-ball-3d" and "uniform-ball" arrangements, encoding size must be specified as a positive integer scalar. The default value is 64.

    • For "rectangular-grid" arrangement, encoding size must be specified as a 1-by-2 vector of form [Ex, Ey]. Ex and Ey represent the encoding size along the x and y directions, respectively. The default value is [8, 8].

    • For "rectangular-grid-3d" arrangement, encoding size must be specified as a 1-by-3 vector of form [Ex, Ey, Ez]. Ex, Ey, and Ez represent the encoding size along the x, y, and z directions, respectively. The default value is [4, 4, 4].

    If encoding size is a scalar, number of basis points is equal to the scalar value itself. If encoding size is a vector, the number of basis points is the product of each element in the vector. For example, if the encoding size is [10 10], number of basis points is 100.

    Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

    This property is read-only.

    Center of the BPS arrangement, specified as a

    • 2-element vector for "uniform-ball" and "rectangular-grid" arrangements. The vector is of the form [Cx, Cy], which defines the x and y coordinates of the center, respectively. The default value is [0, 0].

    • 3-element vector for "uniform-ball-3d" and "rectangular-grid-3d" arrangements. The vector is of the form [Cx, Cy, Cz], which defines the x, y, and z coordinates of the center, respectively. The default value is [0, 0, 0].

    Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

    This property is read-only.

    Radius of the uniform ball arrangements, specified as a positive scalar. For "uniform-ball" and "uniform-ball-3d" arrangements, the default value is 1.

    The bpsEncoder object lists this property only if the BPS arrangement is "uniform-ball" or "uniform-ball-3d".

    Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

    This property is read-only.

    Dimensions of the rectangular grid arrangements, specified as a

    • 2-element vector for "rectangular-grid" arrangement. The vector is of the form [length, width], which defines the length and width of the two dimensional rectangular grid, respectively. The default value is [2, 2].

    • 3-element vector for "rectangular-grid-3d" arrangement. The vector is of the form [length, width, height], which defines the length, width, and height of the three dimensional rectangular grid, respectively. The default value is [2, 2, 2].

    The bpsEncoder object lists this property only if the BPS arrangement is "rectangular-grid" or "rectangular-grid-3d".

    This property is read-only.

    Basis points for encoding the map environment, returned as a

    • N-by-2 matrix for "uniform-ball" and "rectangular-grid" arrangements.

    • N-by-3 matrix for "uniform-ball-3d" and "rectangular-grid-3d" arrangements.

    N is the number of basis points.

    Object Functions

    encodeEncode map environment using basis point set encoder

    Examples

    collapse all

    Load an example map into the workspace, and use it to create an occupancy map with a resolution of 10 cells/meter.

    load("exampleMaps.mat","simpleMap");
    map = occupancyMap(simpleMap,10);

    Specify the basis point set arrangement for encoding as "rectangular-grid".

    arrangement = "rectangular-grid";

    Specify the encoding size as [10 10]. Therefore, the number of basis points returned for encoding the map environment will be 100.

    encodingSize = [10 10];

    Specify the dimensions of the rectangular grid. For correct results, the dimensions of the rectangular grid must be approximately same as that of the input environment.

    xLims = map.XLocalLimits;
    yLims = map.YLocalLimits;
    dims = [(xLims(2) - xLims(1)) (yLims(2) - yLims(1))];

    Specify the center of the map as the center of the rectangular grid.

    center = [sum(xLims)/2 sum(yLims)/2];

    Create a basis point set encoder using bpsEncoder object. This object computes the basis points and stores them in the Points property.

    bpsObj= bpsEncoder(arrangement,encodingSize,Center=center,Dimensions=dims);
    basisPoints = bpsObj.Points;

    Encode the input 2D map environment by using the encode function.

    [encodedValues,nearestPoint] = encode(bpsObj,map);

    Display the map and the basis points along with its nearest object points.

    show(map)
    hold on
    scatter(basisPoints(:,1),basisPoints(:,2),"filled",DisplayName="Basis Points")
    quiver(basisPoints(:,1),basisPoints(:,2),nearestPoint(:,1)-basisPoints(:,1),...
           nearestPoint(:,2)-basisPoints(:,2),0,Color='black',DisplayName='Nearest points')
    legend(Location="bestoutside")

    Figure contains an axes object. The axes object with title Occupancy Grid, xlabel X [meters], ylabel Y [meters] contains 3 objects of type image, scatter, quiver. These objects represent Basis Points, Nearest points.

    References

    [1] Prokudin, Sergey, Christoph Lassner, and Javier Romero. “Efficient Learning on Point Clouds With Basis Point Sets.” In 2019 IEEE/CVF International Conference on Computer Vision (ICCV), 4331–40. Seoul, Korea (South): IEEE, 2019. https://doi.org/10.1109/ICCV.2019.00443.

    Extended Capabilities

    C/C++ Code Generation
    Generate C and C++ code using MATLAB® Coder™.

    Version History

    Introduced in R2024a

    See Also

    (Navigation Toolbox) | (Navigation Toolbox) |