Main Content

copy

Create deep copy of EKF SLAM object

    Description

    example

    newSlamObj = copy(slamObj) creates a deep copy of slamObj with the same properties. Any changes made to newSlamObj are not reflected in slamObj.

    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.

    Output Arguments

    collapse all

    Copy of the EKF SLAM object, returned as an ekfSLAM object.

    Extended Capabilities

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

    Version History

    Introduced in R2021b