File Exchange

image thumbnail

Optical flow based robot obstacle avoidance with Matlab

version 1.3 (213 KB) by

Navigate a virtual robot in a virtual environment to avoid obstacles by using optical flow field.

14 Downloads

Updated

View License

Matlab’s Virtual Reality toolbox makes it possible to not only visualize a virtual world, but also capture it into an image from a specified position, orientation and rotation. The virtual world was created in VRML with a plain text editor and it can be viewed in your internet browser if you have installed a VRML viewer.

For calculating the optical view field of two successive camera images, I used a C optimized version of Horn and Schunk’s optical flow algorithm.

Based on this optical flow field, the flow magnitudes of right and left half of each image is calculated. If the sum of the flow magnitudes of the view reaches a certain threshold, it is assumed there is an obstacle in front of the robot. Then the computed flow magnitude of right and left half image is used to formulate a balance strategy: if the right flow is larger than the left flow, the robot turns left - otherwise it turns right.

Requires Matlab (Windows, Mac or Linux).

Note: On Mac or Linux, first the Matlab wrapper needs to be compiled into a mex file using Matlab by going to the directory containing the library and running the following command within Matlab:

mex OpticalFlowMatlab.cpp

Start the robot simulation by typing in Matlab:

ofnav

Comments and Ratings (3)

Steven Wang

Mihai Chirca

??? Error using ==> vrsfunc
This operation is not permitted in the demonstration version of Simulink 3D
Animation.

Error in ==> vrworld.vrworld at 86
This.id = vrsfunc('VRT3LoadScene', foundname, strcmp(createmode,
'edit'));

Error in ==> ofnav at 30
glob.world = vrworld('obstacles.wrl');

any idea why i have this message?

Updates

1.3

Added additional Product Requirement "Image Processing Toolbox" , it was missing in the initial submit.

1.2

Deleted Mex file

MATLAB Release
MATLAB 7.6 (R2008a)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Win prizes and improve your MATLAB skills

Play today