How can I change the map and start location in the UAV Package Delivery Example?
43 views (last 30 days)
Show older comments
MathWorks Support Team
on 29 Jul 2022
Answered: MathWorks Support Team
on 15 Sep 2022
I am looking at the following example from the MathWorks documentation:
I want to modify the map and start location in the model accessed via the command:
>> openExample('uav/UAVPackageDeliveryExample');
How can this be achieved?
Accepted Answer
MathWorks Support Team
on 29 Jul 2022
This can most easily be achieved with a MATLAB script. The example code below changes the map to a location in London.
%% Change lat-lon used by QGroundControl map
dict = Simulink.data.dictionary.open('uavPackageDeliveryDataDict.sldd');
sect = getSection(dict, 'Design Data');
latlon = getEntry(sect, 'uavIC_latLon');
% Set lat-lon to London, then when you simulate with QGroundControl
% connection, it will show London map. You can then use QGroundControl
% to create and upload new mission in London
setValue(latlon, [51.5072 0]);
%% Change initial world position used by low-fidelity model during Simulation
lowFiPlant = 'MultirotorModel/Inner Loop and Plant Model/Low-FidelityModel/Quadrotor Plant';
% Check the world position parameter in block mask
open_system(lowFiPlant);
% Change initial position
set_param(lowFiPlant, "InitialWorldPositionMultirotor", [-60 -182 0]);
%% Change initial world position used by high-fidelity model during Simulation
highFidelityInitialConditions = getEntry(sect, 'initialConditions');
ic = getValue(highFidelityInitialConditions);
ic.posNED(:) = [-60 -105 0];
setValue(highFidelityInitialConditions, ic);
In the above script we modified the parameter "latlon" to select another location with a different [latitude longitude].
Additionally, we modified "InitialWorldPositionMultirotor" and "ic.posNed(:)" to choose a different starting position during simulation.
0 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!