Симуляционные модели часто требуют различных уровней точности на разных стадиях разработки. На этапе быстрого прототипирования мы хотели бы быстро экспериментировать и настраивать параметры для тестирования различных автономных алгоритмов. На стадии разработки производства мы хотели бы проверить наши алгоритмы на соответствие моделям повышения точности. В этом примере мы демонстрируем метод аппроксимации модели высокой точности с блоком Guiding Model и используем его для прототипа и настройки ППМ после навигационной системы. См. раздел Настройка толкателя ППМ для БПЛА с фиксированным крылом. Эта же навигационная система тестируется на модели высокой точности для проверки ее производительности.
В примере модели используется высокоточная модель беспилотного летательного аппарата (БПЛА), состоящая из модели установки и встроенного автопилота среднего уровня. Эта модель содержит около тысячи блоков и работать с ней довольно сложно. В качестве первого шага в процессе разработки мы создали вариационную систему, которая может переключаться между этой моделью высокой точности и блоком модели наведения БПЛА. Модель высокой точности извлекается из записи File Exchange, Simulink Drone Reference Application.
uavModel = 'FixedWingModel.slx';
open_system(uavModel);Можно переключаться между моделями низкой и высокой точности, изменяя значение переменной MATLAB ®, хранящееся в словаре данных, связанном с этой моделью.
plantDataDictionary = Simulink.data.dictionary.open('pathFollowingData.sldd'); plantDataSet = getSection(plantDataDictionary,'Design Data'); % Switch to high-fidelity model assignin(plantDataSet,'useHighFidelity',1);

% Switch to low-fidelity model assignin(plantDataSet,'useHighFidelity',0);

Для аппроксимации модели высокой точности с блоком модели наведения БПЛА создайте сигналы шагового управления для подачи в модель и наблюдения за откликом шага на RollAngle, Height, и AirSpeed команды.
stepModel = 'stepResponse';
open_system(stepModel)
Сначала введите команду на изменение угла крена.
controlBlock = get_param('stepResponse/Step Control Input','Object'); controlBlock.StepControl = 'RollAngle Step Control'; assignin(plantDataSet,'useHighFidelity',1); sim(stepModel);
### Starting serial model reference simulation build ### Successfully updated the model reference simulation target for: PlantModel ### Successfully updated the model reference simulation target for: FixedWingModel Build Summary Simulation targets built: Model Action Rebuild Reason ======================================================================================== PlantModel Code generated and compiled PlantModel_msf.mexa64 does not exist. FixedWingModel Code generated and compiled FixedWingModel_msf.mexa64 does not exist. 2 of 2 models built (0 models already up to date) Build duration: 0h 1m 34.86s
highFidelityRollAngle = RollAngle.Data(:); highFidelityTime = RollAngle.Time; figure() plot(highFidelityTime, highFidelityRollAngle,'--r'); title('Roll Angle Step Response')

В результате моделирования, приведенном выше, отображаются характеристики контроллера угла крена, встроенного в модель высокой точности. Время отстаивания угла крена близко к 2,5 с.
xlim([75 80]) ylim([-0.1 0.548])

Для ПД-контроллера второго порядка для достижения этого времени установки с критически демпфируемой системой для конфигурирования блока модели наведения БПЛА в варианте с низкой точностью модели БПЛА следует использовать следующие коэффициенты усиления. В этом примере блок модели наведения БПЛА моделируется с использованием генерации кода для увеличения скорости для нескольких пробегов. См. параметры блока.
zeta = 1.0; % critically damped ts = 2.5; % 2 percent settling time wn = 5.8335/(ts*zeta); newRollPD = [wn^2 2*zeta*wn];
Задайте новые коэффициенты усиления и смоделируйте отклик шага для модели с низкой точностью. Сравните его с исходным ответом.
load_system(uavModel) set_param('FixedWingModel/FixedWingModel/LowFidelity/Fixed Wing UAV Guidance Model',... 'PDRollFixedWing',strcat('[',num2str(newRollPD),']')) save_system(uavModel) assignin(plantDataSet, 'useHighFidelity', 0); sim(stepModel);
### Starting serial model reference simulation build ### Successfully updated the model reference simulation target for: FixedWingModel Build Summary Simulation targets built: Model Action Rebuild Reason =========================================================================================== FixedWingModel Code generated and compiled Model or library FixedWingModel has changed. 1 of 1 models built (0 models already up to date) Build duration: 0h 0m 19.476s
lowFidelityRollAngle = RollAngle.Data(:); lowFidelityTime = RollAngle.Time; hold on; plot(lowFidelityTime, lowFidelityRollAngle,'-b'); legend('High-Fidelity Response', 'Low-Fidelity Response', 'Location','southeast');

Модель низкой точности достигает аналогичной реакции шага. Аналогично, мы можем настроить два других канала управления: Height и AirSpeed. Здесь могут быть использованы более сложные методы для оптимизации усиления управления вместо визуального контроля реакции управления. Рассмотрите возможность использования System Identification Toolbox ® для дальнейшего анализа поведения модели БПЛА высокой точности.
controlBlock.StepControl = 'AirSpeed Step Control'; assignin(plantDataSet, 'useHighFidelity', 0); sim(stepModel);
### Starting serial model reference simulation build ### Model reference simulation target for FixedWingModel is up to date. Build Summary 0 of 1 models built (1 models already up to date) Build duration: 0h 0m 2.8818s
lowFidelityAirSpeed = AirSpeed.Data(:);
lowFidelityTime = AirSpeed.Time;
assignin(plantDataSet, 'useHighFidelity', 1);
sim(stepModel);### Starting serial model reference simulation build ### Model reference simulation target for PlantModel is up to date. ### Successfully updated the model reference simulation target for: FixedWingModel Build Summary Simulation targets built: Model Action Rebuild Reason ========================================================================================================================= FixedWingModel Code generated and compiled Variant control useHighFidelity == 0 value has changed from true to false. 1 of 2 models built (1 models already up to date) Build duration: 0h 0m 31.251s
highFidelityAirSpeed = AirSpeed.Data(:); highFidelityTime = AirSpeed.Time; figure() plot(lowFidelityTime, lowFidelityAirSpeed,'-b'); hold on; plot(highFidelityTime, highFidelityAirSpeed,'--r'); legend('Low-Fidelity Response', 'High-Fidelity Response', 'Location','southeast'); title('Air Speed Step Response') xlim([70 80]) ylim([17.5 19.2])

controlBlock.StepControl = 'Height Step Control'; assignin(plantDataSet, 'useHighFidelity', 0); sim(stepModel);
### Starting serial model reference simulation build ### Successfully updated the model reference simulation target for: FixedWingModel Build Summary Simulation targets built: Model Action Rebuild Reason ========================================================================================================================= FixedWingModel Code generated and compiled Variant control useHighFidelity == 1 value has changed from true to false. 1 of 1 models built (0 models already up to date) Build duration: 0h 0m 17.761s
lowFidelityHeight = Height.Data(:);
lowFidelityTime = Height.Time;
assignin(plantDataSet, 'useHighFidelity', 1);
sim(stepModel);### Starting serial model reference simulation build ### Model reference simulation target for PlantModel is up to date. ### Successfully updated the model reference simulation target for: FixedWingModel Build Summary Simulation targets built: Model Action Rebuild Reason ========================================================================================================================= FixedWingModel Code generated and compiled Variant control useHighFidelity == 0 value has changed from true to false. 1 of 2 models built (1 models already up to date) Build duration: 0h 0m 33.54s
highFidelityHeight = Height.Data(:); highFidelityTime = Height.Time; figure() plot(lowFidelityTime, lowFidelityHeight,'-b'); hold on; plot(highFidelityTime, highFidelityHeight,'--r'); legend('Low-Fidelity Response', 'High-Fidelity Response', 'Location','southeast'); title('Height Step Response') xlim([70 150]) ylim([49 56])

Теперь, когда мы аппроксимировали модель высокой точности с блоком модели наведения БПЛА, мы можем попытаться заменить его на блок модели наведения БПЛА в примере Tuning Waypoint Follower for Fixed-Wing. Протестируйте эффект усиления контроля за расстоянием и курсом на этих моделях различной точности.
navigationModel = 'pathFollowing';
open_system(navigationModel);assignin(plantDataSet,'useHighFidelity',0);
sim(navigationModel);### Starting serial model reference simulation build ### Successfully updated the model reference simulation target for: FixedWingModel Build Summary Simulation targets built: Model Action Rebuild Reason ========================================================================================================================= FixedWingModel Code generated and compiled Variant control useHighFidelity == 1 value has changed from true to false. 1 of 1 models built (0 models already up to date) Build duration: 0h 0m 15.825s
figure visualizeSimStates(simStates);

assignin(plantDataSet,'useHighFidelity',1);
sim(navigationModel);### Starting serial model reference simulation build ### Model reference simulation target for PlantModel is up to date. ### Successfully updated the model reference simulation target for: FixedWingModel Build Summary Simulation targets built: Model Action Rebuild Reason ========================================================================================================================= FixedWingModel Code generated and compiled Variant control useHighFidelity == 0 value has changed from true to false. 1 of 2 models built (1 models already up to date) Build duration: 0h 0m 34.524s
figure visualizeSimStates(simStates);

Этот пример показывает, как мы можем аппроксимировать модель высокой точности с абстракцией низкой точности БПЛА. Противоположный подход также может быть использован для того, чтобы помочь в выборе коэффициентов усиления управления автопилотом для модели высокой точности. Сначала можно определить приемлемые характеристики реакции управления автопилотом, смоделировав модель с низкой точностью в различных тестовых сенариях, а затем соответствующим образом настроить модель с высокой точностью.
discardChanges(plantDataDictionary); clear plantDataSet clear plantDataDictionary close_system(uavModel, 0); close_system(stepModel, 0); close_system(navigationModel, 0);
fixedwing | multirotor | Модель наведения БПЛА