Main Content

removeLandmark

Remove landmark from state vector

Since R2021b

    Description

    example

    removeLandmark(slamObj,landmarkIndex) removes the landmarks at the specified indices landmarkIndex from the state vector, along with associated covariances from the state covariance matrix.

    Examples

    collapse all

    Specify the initial vehicle state.

    initialState = [1; -2; 0.1];

    Specify the initial landmark positions.

    landmarkPosition = [15.8495; -12.9496;
                        25.2455; -15.4705;
                        37.5880;   3.1023;
                        16.5690;   2.7466];

    Specify the initial vehicle state covariance.

    initialStateCovar = diag([0.1*ones(1,3) 1.1*ones(1,8)]);

    Create an ekfSLAM object with initial state and initial state covariance.

    ekfSlamObj = ekfSLAM('State',[initialState; landmarkPosition], ...
                         'StateCovariance',initialStateCovar);
    landmarkInfo(ekfSlamObj)
    ans=4×3 table
        landmark number    landmark state index    landmark position
        _______________    ____________________    _________________
    
               1                  4     5           15.85    -12.95 
               2                  6     7          25.245    -15.47 
               3                  8     9          37.588    3.1023 
               4                 10    11          16.569    2.7466 
    
    

    Create a deep copy of the ekfSLAM object.

    newEkfSlamObj = copy(ekfSlamObj);

    Specify the landmark number to be removed.

    removeLandmark(newEkfSlamObj,3);
    landmarkInfo(newEkfSlamObj)
    ans=3×3 table
        landmark number    landmark state index    landmark position
        _______________    ____________________    _________________
    
               1                  4    5            15.85    -12.95 
               2                  6    7           25.245    -15.47 
               3                  8    9           16.569    2.7466 
    
    

    Input Arguments

    collapse all

    EKF SLAM object, specified as an ekfSLAM object.

    Indices of the landmarks to remove, specified as an N-element column vector of landmark numbers in the state vector or an N-by-2 matrix of the exact positions of landmarks in the state vector. N is the number of landmarks to remove.

    Data Types: single | double

    Extended Capabilities

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

    Version History

    Introduced in R2021b

    See Also

    Objects

    Functions