Contenido principal

Esta página se ha traducido mediante traducción automática. Haga clic aquí para ver la última versión en inglés.

stateTransition

Transición de estado del modelo de movimiento.

Desde R2022a

Descripción

statedot = stateTransition(model,filter,dt,varargin) devuelve las derivadas de los estados del modelo de movimiento utilizado con el filtro INS.

ejemplo

Ejemplos

contraer todo

Personalice un modelo de movimiento de velocidad constante 1-D utilizado con un objeto insEKF. Personalice el modelo de movimiento heredando de la clase de interfaz positioning.INSMotionModel e implemente los métodos modelstates y stateTranistion. También puede implementar opcionalmente el método stateTransitionJacobian. Estas secciones proporcionan una descripción general de cómo la clase ConstantVelocityMotion implementa los métodos positioning.INSMotionModel, pero para obtener más detalles sobre su implementación, consulte el archivo ConstantVelocityMotion.m adjunto.

Implementar el método modelstates

Para modelar un movimiento de velocidad constante unidimensional, es necesario devolver solo la posición unidimensional y el estado de velocidad como estructura. Cuando agrega un objeto ConstantVelocityMotion a un objeto de filtro insEKF, el filtro agrega los componentes Position y Velocity al vector de estado del filtro.

Implementar el método stateTransition

El método stateTransition devuelve las derivadas del estado definido por el modelo de movimiento como una estructura. La derivada de Position es Velocity, y la derivada de Velocity es 0.

Implementar el método stateTransitionJacobian

El método stateTransitionJacobian devuelve las derivadas parciales del método stateTransition, con respecto al vector de estado del filtro, como una estructura. Todas las derivadas parciales son 0, excepto la derivada parcial de la derivada del componente Position, que es Velocity, con respecto al estado Velocity, que es 1.

Crear y agregar objeto heredado

Cree un objeto ConstantVelocityMotion.

cvModel = ConstantVelocityMotion
cvModel = 
  ConstantVelocityMotion with no properties.

Crea un objeto insEKF con el objeto cvModel creado.

filter = insEKF(insAccelerometer,cvModel)
filter = 
  insEKF with properties:

                   State: [5×1 double]
         StateCovariance: [5×5 double]
    AdditiveProcessNoise: [5×5 double]
             MotionModel: [1×1 ConstantVelocityMotion]
                 Sensors: {[1×1 insAccelerometer]}
             SensorNames: {'Accelerometer'}
          ReferenceFrame: 'NED'

El estado del filtro contiene los componentes Position y Velocity.

stateinfo(filter)
ans = struct with fields:
              Position: 1
              Velocity: 2
    Accelerometer_Bias: [3 4 5]

Mostrar clase ConstantVelocityMotion personalizada

type ConstantVelocityMotion.m
classdef ConstantVelocityMotion < positioning.INSMotionModel
% CONSTANTVELOCITYMOTION Constant velocity motion in 1-D

%   Copyright 2021 The MathWorks, Inc.    

    methods 
        function m = modelstates(~,~)
            % Return the state of motion model (added to the state of the
            % filter) as a structure.
            % Since the motion is 1-D constant velocity motion,
            % retrun only 1-D position and velocity state.  
            m = struct('Position',0,'Velocity',0); 
        end
        function sdot = stateTransition(~,filter,~, varargin)
            % Return the derivative of each state with respect to time as a
            % structure.

            % Derivative of position = velocity.
            % Derivative of velocity = 0 because this model assumes constant
            % velocity.

            % Find the current estimated velocity
            currentVelocityEstimate = stateparts(filter,'Velocity');

            % Return the derivatives
            sdot = struct( ...
                'Position',currentVelocityEstimate, ...
                'Velocity',0); 
        end
        function dfdx = stateTransitionJacobian(~,filter,~,varargin)
            % Return the Jacobian of the stateTransition method with
            % respect to the state vector. The output is a structure with the
            % same fields as stateTransition but the value of each field is a
            % vector containing the derivative of that state relative to
            % all other states.

            % First, figure out the number of state components in the filter
            % and the corresponding indices
            N = numel(filter.State);  
            idx = stateinfo(filter);  


            % Compute the N partial derivatives of Position with respect to
            % the N states. The partial derivative of the derivative of the
            % Position stateTransition function with respect to Velocity is
            % just 1. All others are 0.
            dpdx = zeros(1,N);  
            dpdx(1,idx.Velocity) =  1;
            
            % Compute the N partial derivatives of Velocity with respect to
            % the N states. In this case all the partial derivatives are 0.
            dvdx = zeros(1,N);

            % Return the partial derivatives as a structure.
            dfdx = struct('Position',dpdx,'Velocity',dvdx);
        end
    end
end

Argumentos de entrada

contraer todo

Modelo de movimiento utilizado con un filtro INS, especificado como un objeto heredado de la clase abstracta positioning.INSMotionModel.

Filtro INS, especificado como un objeto insEKF.

Paso de tiempo del filtro, especificado como un escalar positivo.

Tipos de datos: single | double

Entradas adicionales que se pasan como entradas varargin de la función del objeto predict del objeto insEKF.

Argumentos de salida

contraer todo

Derivados de los estados, devueltos como estructura. Los nombres de los campos deben ser exactamente los mismos que los de la estructura devuelta por el método modelstates de model. Los valores de campo son las correspondientes derivadas temporales de los estados del sensor.

Historial de versiones

Introducido en R2022a