main content

approximate high-凯发k8网页登录

simulation models often need different levels of fidelity during different development stages. during the rapid-prototyping stage, we would like to quickly experiment and tune parameters to test different autonomous algorithms. during the production development stage, we would like to validate our algorithms against models of increasing fidelities. in this example, we demonstrate a method to approximate a high-fidelity model with the block and use it to prototype and tune a waypoint following navigation system. see . the same navigation system is tested against a high-fidelity model to verify its performance.

the example model uses a high-fidelity unmanned aerial vehicle (uav) model consisting of a plant model and a mid-level built-in autopilot. this model contains close to a thousand blocks and it is quite complicated to work with. as a first step in the development process, we created a variant system that can switch between this high-fidelity model and the uav guidance model block. the high-fidelity model is extracted from a file exchange entry, .

uav model of different fidelity

uavmodel = 'fixedwingmodel.slx';
open_system(uavmodel);

you can switch between the low and high-fidelity models by changing a matlab® variable value stored in the data dictionary associated with this model.

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);

approximate high-fidelity fixed-wing model with low-fidelity guidance model

to approximate the high-fidelity model with the uav guidance model block, create step control signals to feed into the model and observe the step response to rollangle, height, and airspeed commands.

stepmodel = 'stepresponse';
open_system(stepmodel)

first, command a change in roll angle.

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 26.147s
highfidelityrollangle = rollangle.data(:);
highfidelitytime = rollangle.time;
figure()
plot(highfidelitytime, highfidelityrollangle,'--r');
title('roll angle step response')

zooming into the simulation result above, you see the characteristics of the roll angle controller built into the high-fidelity model. the settling time for the roll angle is close to 2.5 seconds.

xlim([75 80])
ylim([-0.1 0.548])

for a second-order pd controller, to achieve this settling time with a critically damped system, the following gains should be used to configure the uav guidance model block inside the low-fidelity variant of the uav model. for this example, the uav guidance model block is simulated using code generation to increase speed for multiple runs. see the block parameters.

zeta = 1.0; % critically damped
ts = 2.5; % 2 percent settling time
wn = 5.8335/(ts*zeta);
newrollpd = [wn^2 2*zeta*wn];

set the new gains and simulate the step response for the low-fidelity model. compare it to the original response.

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 changed.  
1 of 1 models built (0 models already up to date)
build duration: 0h 0m 17.902s
lowfidelityrollangle = rollangle.data(:);
lowfidelitytime = rollangle.time;
hold on;
plot(lowfidelitytime, lowfidelityrollangle,'-b');
legend('high-fidelity response', 'low-fidelity response', 'location','southeast');

the low-fidelity model achieves a similar step response. similarly, we can tune the other two control channels: height and airspeed. more sophisticated methods can be used here to optimize the control gains instead of visual inspection of the control response. consider using system identification toolbox® to perform further analysis of the high-fidelity uav model behavior.

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 3.2493s
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 == 1 value changed from false to true.  
1 of 2 models built (1 models already up to date)
build duration: 0h 0m 27.812s
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 changed from true to false.  
1 of 1 models built (0 models already up to date)
build duration: 0h 0m 15.583s
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 == 1 value changed from false to true.  
1 of 2 models built (1 models already up to date)
build duration: 0h 0m 28.522s
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])

test navigation algorithm with low-fidelity model

now that we have approximated the high-fidelity model with the uav guidance model block, we can try to replace it with the uav guidance model block in the example. test the effect of the lookahead distance and heading control gains against these models of different fidelities.

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 changed from true to false.  
1 of 1 models built (0 models already up to date)
build duration: 0h 0m 14.166s
figure
visualizesimstates(simstates);

validate with high-fidelity model

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 == 1 value changed from false to true.  
1 of 2 models built (1 models already up to date)
build duration: 0h 0m 27.998s
figure
visualizesimstates(simstates);

conclusion

this example shows how we can approximate a high-fidelity model with a low-fidelity abstraction of a fixed-wing uav. the opposite approach can be used as well to help with choosing autopilot control gains for the high-fidelity model. you can first decide acceptable characteristics of an autopilot control response by simulating a low-fidelity model in different test scenarios and then tune the high-fidelity model autopilot accordingly.

discardchanges(plantdatadictionary);
clear plantdataset
clear plantdatadictionary
close_system(uavmodel, 0);
close_system(stepmodel, 0);
close_system(navigationmodel, 0);

see also

| |

related topics

  • (simulink)
网站地图