How to get height sensor and ground feedback when UAV Simulink and UE joint simulation

4 visualizzazioni (ultimi 30 giorni)
Hello, I'm conducting joint simulation of UAV using MATLAB/Simulink 2023b and UE4.27.
I couldn't find any sensors related to UAV altitude in Simulink. I want to obtain the height data between the current position of the UAV and the road directly beneath it.
Additionally, I'd like to know if there are any functional modules related to ground feedback during the UAV simulation process.

Risposte (1)

Altaïr
Altaïr il 6 Gen 2025
Hello,
The following documentation provides describes the different sensors available for co-simulation with Unreal Engine:
The elevation of a UAV from the ground can be determined using a couple of methods:
  1. Downward-Facing Simulation 3D Camera: This camera, located on the UAV, can output its location, which corresponds to the UAV's elevation. An example of this approach can be found here: https://www.mathworks.com/help/releases/R2023b/uav/ug/survey-urban-environment-using-uav.html#SurveyUrbanEnvironmentUsingUAVExample-3.
  2. Downward-Facing LIDAR: By using the point cloud data from a LIDAR sensor, the elevation of the UAV can be calculated. Below is a short script demonstrating how to calculate UAV elevation from point cloud data.
% Generate dummy point cloud data
[X, Y] = meshgrid(1:20, 1:20);
X = X(:) * 5;
Y = Y(:) * 5;
Z = randi([10, 50], 20^2, 1);
% Create point cloud
ptCloud = pointCloud([X, Y, Z]);
% Define UAV position
uavPosition = [60 60 100];
% Define radius and filter points
radius = 20;
distances = sqrt((ptCloud.Location(:,1) - uavPosition(1)).^2 + (ptCloud.Location(:,2) - uavPosition(2)).^2);
indices = distances < radius;
filteredPtCloud = select(ptCloud, indices);
% Calculate elevation
distUAVFilteredCloud = sqrt((uavPosition(1)-filteredPtCloud.Location(:,1)).^2 +...
(uavPosition(2)-filteredPtCloud.Location(:,2)).^2 +...
(uavPosition(3)-filteredPtCloud.Location(:,3)).^2);
approxUAVElevation = mean(distUAVFilteredCloud);
% Create a mesh grid for the plane
[xGrid, yGrid] = meshgrid(linspace(min(filteredPtCloud.Location(:,1)), max(filteredPtCloud.Location(:,1)), 10), ...
linspace(min(filteredPtCloud.Location(:,2)), max(filteredPtCloud.Location(:,2)), 10));
zGrid = repmat(uavPosition(3) - approxUAVElevation, size(xGrid));
% Plot the point cloud
figure;
% pcshow(ptCloud);
pcshow(filteredPtCloud);
hold on;
% Plot the UAV location
plot3(uavPosition(1), uavPosition(2), uavPosition(3), 'ro', 'MarkerSize', 10, 'DisplayName', 'UAV Position');
% Plot the plane
surf(xGrid, yGrid, zGrid, 'FaceAlpha', 0.5, 'EdgeColor', 'none', 'DisplayName', 'Fitted Plane');
% Plot the distance line
line([uavPosition(1), uavPosition(1)], [uavPosition(2), uavPosition(2)], [uavPosition(3), uavPosition(3) - approxUAVElevation], ...
'Color', 'g', 'LineWidth', 2, 'DisplayName', sprintf('Elevation: %.2f', approxUAVElevation));
% Set plot labels and legend
xlabel('X');
ylabel('Y');
zlabel('Z');
title('3D Visualization of Point Cloud, Plane, and UAV');
legend show;
grid on;
view(3);
hold off;
For further reading, please refer to these documentation links:
  2 Commenti
泽凯
泽凯 il 7 Gen 2025
Thanks for your solution!
I have another question is that if I can achieve the state like the car in the Simulation 3D Vehicle block when the height of UAV is zero, I want to make the UAV run like car when it is on the ground.
Nishan Nekoo
Nishan Nekoo il 30 Gen 2025
Hello,
I would also recommend the Simulation 3D Ray Tracer. This block can be attached to the UAV and will return the distance to the closest object when parametrized correctly. To achieve behavior like the Simulation 3D Vehicle with Ground Following, you can use feedback from the Simulation 3D Ray Tracer to update the height of the UAV based on its distance to the ground. The Simulation 3D Vehicle with Ground Following is essentially doing this, using ray tracers on each wheel to identify where the wheel should be positioned above the ground.
I hope that helps!
Nishan

Accedi per commentare.

Tag

Prodotti


Release

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by