How to play Multiple Fixed-Wings UAV Animations in UAV animation block

Greeting everyone!!!
I am trying to simulate waypoint following of Multiple fixed-wings UAVs in UAV Animation block which I found from example "Tuning Waypoint Follower for Fixed-Wing UAV" which can be using following command:
openExample('robotics/TuningWaypointFollowerForFixedWingSmallUAVExample')
this example shows way point following using single Fixed wing UAV having uav animation block...
for multiple UAVs i have duplicated the same model but with different waypoints and i want to simulate/animate this model...kindly guide how can i accomodate multple UAVs in single UAV animation block...

 Akzeptierte Antwort

Jianxin Sun
Jianxin Sun am 5 Okt. 2020
Hi Hussain,
The UAV Animation block can only visualize one UAV at a time. If you want to visualize multiple UAVs, consider create a MATLAB function block and use plotTransforms function to draw multiple UAVs. You would need to use coder.extrinsic('plotTransforms') to declare that the visualization code will be executed using MATLAB instead of code generation.
Thanks,
Jianxin

4 Kommentare

Hi Jianxin,
I am having the same issue, and I am not exactly sure how to proceed here. Can you be more explicit?
Also, can the original feature be added? I think it would be a good addition to the toolbox.
Thanks,
Anthony
Hi Anthony, Hussain,
You can use the following example code in a MATLAB function block. The block would take two inputs: positions and orientations of your UAV. You can further customize the visualization with different options in plotTransforms function.
function plotUAVs(positions, orientations)
% plotUAVs plot mulitple UAVs
% positions is a Nx3 matrix, with each row for one UAV's position
% orientations is a Nx4 matrix, with each row for one UAV's orientation
% as a quaternion
% Both position and orientation are defined using NED reference frame
persistent axHandle
coder.extrinsic('figure');
coder.extrinsic('newplot');
coder.extrinsic('plotTransforms');
if isempty(axHandle)
figureHandle = figure();
axHandle = newplot(figureHandle);
end
cla(axHandle);
for idx = 1:size(positions,1)
plotTransforms(positions(idx, :), orientations(idx, :), ...
"MeshFilePath", "multirotor.stl", "InertialZDirection", "down", "Parent", axHandle);
end
xlabel(axHandle, 'North');
ylabel(axHandle, 'West');
zlabel(axHandle, 'Up');
end
Thanks,
Jianxin
Hi Jianxin,
Thank you for this. Would you know how to show the path of the UAVs? I would like to show a plot similar to the UAV toolbox plotter. Also do you think you can integrate this code in the main toolbox?
Best regards,
Anthony
Hi Anthony,
You can use a plot3 to visualize the UAV trajectory. But you would need to keep recording the UAV's pose during simulation inside the MATLAB function block. You can create a persistent variable and use it to store the last N poses of the UAV.
Best regards,
Jianxin

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Giuseppe Silano
Giuseppe Silano am 2 Mär. 2022
I've been working on a built-in example using MATLAB/Simulink 3D Animation Toolbox for object detection and tracking with an Unmanned Aerial Vehicle. Below there are the links to the GitHub repository and the open-access paper. The code is also available on MathWorks File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by