Main Content

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

modelstates

Estados para el modelo de movimiento

Desde R2022a

Descripción

ejemplo

s = modelstates(filter,options) devuelve una estructura que describe los estados del modelo de movimiento rastreados por el objeto de filtro insEKF .

Sugerencia

Después de definir un objeto insEKF con un modelo de movimiento personalizado, puede acceder a los estados del modelo usando la función de objeto stateparts de insEKF.

Ejemplos

contraer todo

Personalice un modelo de movimiento de velocidad constante 1-D usado 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 . Opcionalmente, también puede implementar 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 ConstantVelocityMotion.m adjunto. $ archivo.

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 de filtro ConstantVelocityMotion a un objeto de filtro insEKF , el filtro agrega Position y Velocity componentes 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 estructura. La derivada del Position es el Velocity, y la derivada del Velocity es el 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 el Velocity, con respecto al Velocity estado, es 1.

Crear y agregar objeto heredado

Cree un objeto ConstantVelocityMotion .

cvModel = ConstantVelocityMotion
cvModel = 
  ConstantVelocityMotion with no properties.

Cree un objeto insEKF con el objeto cvModel creado.

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

                   State: [5x1 double]
         StateCovariance: [5x5 double]
    AdditiveProcessNoise: [5x5 double]
             MotionModel: [1x1 ConstantVelocityMotion]
                 Sensors: {[1x1 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.

            % Deriviative of position = velocity.
            % Deriviative 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

Filtro INS, especificado como un objeto insEKF .

Opciones para el filtro INS, especificado como un objeto insOptions .

Argumentos de salida

contraer todo

Estructura estatal, devuelta como estructura. Los nombres de los campos de la estructura son los nombres de los estados que desea estimar. El objeto de filtro insEKF utiliza el valor de cada campo como el valor predeterminado de su componente de estado correspondiente y utiliza el tamaño del valor como el tamaño del componente de estado correspondiente.

Sugerencia

Puede utilizar la función de objeto stateparts del objeto insEKF para acceder a los estados, guardados en el filtro.

Historial de versiones

Introducido en R2022a