Why is my 3D Vector Field Histogram plot not displaying correctly??
3 次查看(过去 30 天)
显示 更早的评论
I am streaming in data from a Velodyne Puck Lidar and feeding it to the controllerVFH3D function. When i try to plot the histogram with show(vfh3D). The plot is completely filled in even outside the sensors field of vision so i cant see the UAV or steerring vectors as shown in the example.
This is the plot i get:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1577571/image.png)
This is the example plot:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1577576/image.png)
Here is my code:
clc, clear
% Initialize the Velodyne LiDAR
lidar = velodynelidar('VLP16');
%Set up the 3D VFH controller
vfh3D = controllerVFH3D('DistanceLimits', [0.2, 100], ...
'HorizontalSensorFOV', [-359, 360], ...
'VerticalSensorFOV', [-15, 15],...
'SensorOrientation', [-180, 0, 0], ...
'HistogramResolution', 10, ...
'WindowSize', 3, ...
'HistogramThreshold', 4, ...
'MaxAge', 0, ...
'TargetDirectionWeight',5);
% Create a figure outside the loop
fig = figure;
ax = axes(Parent=fig);
while true
% Check if the figure is still open
if ~isvalid(fig)
break; % Exit the loop if the figure is closed
end
% Read data from the LiDAR sensor
ptCloud = read(lidar);
x = ptCloud.Location(:,:,1); % X coordinates
y = ptCloud.Location(:,:,2); % Y coordinates
z = ptCloud.Location(:,:,3); % Z coordinates
%Get rid of NaN values
validIndices = ~isnan(x) & ~isnan(y) & ~isnan(z);
X = x(validIndices);
Y = y(validIndices);
Z = z(validIndices);
sensorPoints = [X Y Z];
% Update the VFH3D controller with new data
uavPosition = [1; 0; 0];
uavOrientation = [1; 0; 0; 0]; % Example values, replace with actual data
targetPosition = [-1.5; 1; 0]; % Example values, replace with actual data
% Process data with VFH3D
[desiredDirection, desiredYaw, status] = vfh3D(uavPosition, ...
uavOrientation, ...
sensorPoints, ...
targetPosition)
% Plot on the dedicated axes
show(vfh3D, "Parent",ax);
axis equal;
end
%Disconnect the LiDAR
disconnectLidar(lidar);
2 个评论
R
2024-1-3
Hi Gavin,
I am unble to reproduce the issue as I don't have access to a lidar sensor. Can you share the sensor data and the version of MATLAB you are using so that contributors can investigate the issue in detail?
采纳的回答
Dhananjay Narayanachar
2024-1-5
Hi Gavin,
Since the VehicleRadius + SafetyDistance is comparable to the UAV's distance to obstacles, the entire spherical region is considered as filled with obstacles. Please try to reduce the controllerVFH3D object's 'VehicleRadius' and 'SafetyDistance' propeties to a smaller value like 0.1.
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!