Avoid obstacles using vector field histogram

The `controllerVFH`

System object™enables your vehicle to avoid obstacles based on range sensor data
using vector field histograms (VFH) . Given laser scan readings and a target direction to
drive toward, the object computes an obstacle-free steering direction.

`controllerVFH`

specifically uses the VFH+ algorithm to compute an
obstacle-free direction. First, the algorithm takes the ranges and angles from laser scan data
and builds a polar histogram for obstacle locations. Then, the input histogram thresholds are
used to calculate a binary histogram that indicates occupied and free directions. Finally, the
algorithm computes a masked histogram, which is computed from the binary histogram based on
the minimum turning radius of the vehicle.

The algorithm selects multiple steering directions based on the open space and possible driving directions. A cost function, with weights corresponding to the previous, current, and target directions, calculates the cost of different possible directions. The object then returns an obstacle-free direction with minimal cost. Using the obstacle-free direction, you can input commands to move your vehicle in that direction.

To use this object for your own application and environment, you must tune the properties of the algorithm. Property values depend on the type of vehicle, the range sensor, and the hardware you use.

To find an obstacle-free steering direction:

Create the

`controllerVFH`

object and set its properties.Call the object with arguments, as if it were a function.

To learn more about how System objects work, see What Are System Objects? (MATLAB).

returns a vector field
histogram object that computes the obstacle-free steering direction using the
`VFH`

= controllerVFH`VFH+`

algorithm.

returns a vector field histogram object with additional options specified by one or more
`VFH`

= controllerVFH(`Name`

,`Value`

)`Name,Value`

pairs. Name is the property name and Value is the
corresponding value. Name must appear inside single quotes (`' '`

). You
can specify several name-value pair arguments in any order as
`Name1,Value1,...,NameN,ValueN`

. Properties not specified retain their
default values.

finds an obstacle-free steering direction using the VFH+ algorithm for the input `steeringDir`

= vfh(`scan`

,`targetDir`

)`lidarScan`

object,
`scan`

. A target direction is given based on the target
location.

To enable this syntax, you must set the `UseLidarScan`

property to
`true`

. For example:

mcl = monteCarloLocalization('UseLidarScan',true); ... [isUpdated,pose,covariance] = mcl(odomPose,scan);

defines the lidar scan with two vectors: `steeringDir`

= vfh(`ranges`

,`angles`

,`targetDir`

)`ranges`

and
`angles`

.

To use an object function, specify the
System
object as the first input argument. For
example, to release system resources of a System
object named `obj`

, use
this syntax:

release(obj)

[1] Borenstein, J., and Y. Koren. "The Vector Field Histogram - Fast Obstacle Avoidance for Mobile Robots." IEEE Journal of Robotics and Automation. Vol. 7, Number 3, 1991, pp.278–88.

[2] Ulrich, I., and J. Borenstein. "VFH : Reliable Obstacle Avoidance for Fast Mobile
Robots." *Proceedings. 1998 IEEE International Conference on Robotics and
Automation*. (1998): 1572–1577.