www.gusucode.com > robotics 案例源码程序 matlab代码 > robotics/CreateAVectorFieldHistogramObjectExample.m

    %% Create a Vector Field Histogram Object
% This example shows how to create a Vector Field Histogram (VFH) object
% and calculate a steering direction based on input laser scan data.
%%
% Create VFH object
 vfh = robotics.VectorFieldHistogram;
 
%%
% Input laser scan data and target direction.
ranges = 10*ones(1,500);
ranges(1,225:275) = 1.0;
angles = linspace(-pi,pi,500);
targetDir = 0;
 
%%
% Compute obstacle-free steering direction
steeringDir = vfh(ranges,angles,targetDir)

%%
% Visualize the VectorFieldHistogram computation
h = figure;
set(h,'Position',[50 50 800 400])
show(vfh);