Category Archives: Virtual Reality

Creating 3D worlds for simulation.

Obstacle avoidance in flight via optical flow

This video shows our prototyped flight simulation and controller software that

  1. simulates the flight dynamics of an RC aircraft and
  2. automatically controls that aircraft so that it avoids obstacles (ground/mountains etc.), only by analysing the optical flow in front of the aircraft. For the optical flow sensor, an optical mouse CCD (20×20 pixels) with a lense is simulated.  

Also click here to see how the same technique is used in 2D to navigate a robot, only by optical flow. 

Optical flow based robot obstacle avoidance with Matlab

This is the result of a project where a virtual robot avoids obstacles in a virtual environment without knowing the environment – the robot navigates autonomously, only by analysing it’s virtual camera view.

In detail, this example project shows:

1. How to create a virtual environment for a virtual robot and display the robot’s camera view
2. Capture the robot’s camera view for analysing
3. Compute the optical flow field of the camera view
4. Estimate Focus of expansion (FOE) and Time-to-contact (TTC)
5. Detect obstacles and make a balance decision (turn robot right/turn left)

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 (you can install one here).

Virtual world for the robot

(Click here to view the VRML file with your 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 – see here for details).

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.

 Virtual robot GUI

Robot’s camera view at the same time:

Virtual robot camera view

Click here to see a video recording of a robot session. 

Click here to download Matlab code.