주요 콘텐츠

copy

R2026b

Create deep copy of control path object

    Description

    pathObj2 = copy(pathObj1) creates a deep copy of the specified control path object.

    example

    Examples

    collapse all

    Create a default object of type mobileRobotPropagator, a subclass of nav.StatePropagator.

    Load a ternary map matrix from the exampleMaps file, and use the map matrix to create an occupancyMap object. Create the state propagator using the map. By default, the state propagator uses a bicycle kinematic model.

    load("exampleMaps","ternaryMap")
    map = occupancyMap(ternaryMap,10);
    
    propagator = mobileRobotPropagator(Environment=map); % Bicycle model

    Use the mobile robot state propagator object to create a default navPathControl object.

    pathObj1 = navPathControl(propagator)
    pathObj1 = 
      navPathControl with properties:
    
        StatePropagator: [1×1 mobileRobotPropagator]
                 States: [0×3 double]
               Controls: [0×2 double]
              Durations: [0×1 double]
           TargetStates: [0×3 double]
              NumStates: 0
            NumSegments: 0
    
    

    Create a copy of pathObj1 and verify that it has the same property values.

    pathObj2 = copy(pathObj1)
    pathObj2 = 
      navPathControl with properties:
    
        StatePropagator: [1×1 mobileRobotPropagator]
                 States: [0×3 double]
               Controls: [0×2 double]
              Durations: [0×1 double]
           TargetStates: [0×3 double]
              NumStates: 0
            NumSegments: 0
    
    

    Verify that the copy is a deep copy by checking that the StatePropagator handle properties point to distinct objects in memory. A result of logical 0 confirms they do not share the same underlying data.

    pathObj1.StatePropagator == pathObj2.StatePropagator
    ans = logical
       0
    
    

    Input Arguments

    collapse all

    Control path object to be copied, specified as an navPathControl object.

    Output Arguments

    collapse all

    Copy of path object, returned as a navPathControl object.

    Version History

    Introduced in R2021b