Skip to content

Atif-Anwer/QRCode_Following_LegoEV3_Robot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

QR Code Following Robot Using Lego Mindstorms EV3, Matlab, Arduino and a Webcam

What is this code for?

The repository is the Matlab code for controlling a robot made with Lego Mindstorms EV3 and controlled with Matlab over a USB cable/Bluetooth dongle. Right now, the code uses a single ultrasonic sensor from the EV3 brick. The support and code for arduino is included, but was commented out while getting the results posted in the video below.

Video Results

Video Tracking Results

The above video is the result of the matlab code and moving the robot in real time. It can also be seen at my youtube channel

Hardware and Software requirements?

The following hardware are required for use

  • 1x LEGO EV3
  • 2x Lego Large Motors (EV3)
  • 1x Lego Ultrasonic Transeiver (EV3)
  • 1x Webcam (Logitech C270 used)
  • 1x Arduino MEGAADK
  • 5x HC-SR04 Ultrasonic Sensors
  • Tested on Matlab 2016a and later

Lego Robot Assebly and design

Lego Robot Design.

The QR code used for testing is given below.

QR Code

The design was based on the Ultrasonic sensor driving base design from lego. The PDF design instructions can be downloaded from Lego Website

Basic Code Flow

The code flow can be generalized as follows:

  1. Get Deviation from center and Direction from KLT tracking

    (a) Find Region of Interest and its center (4x Red Circles in a square)
    (b) Find SURF Feature points (QR Code with 4x Red Circles at the corners)
    (c) Match SURF features with QR Code template in file
    (d)Continue if QR code found else stop moving

  2. Get Values of 5x Ultrasonic sensors from Arduino

  3. Get value from 1x front LEGO ultrasonic sensor

  4. Calculate Direction to turn based on the position of QR code in the field of view

  5. Calculate speed of turn for both motors using PID feedback control

  6. Save values to pass on to cartTurn function to execute the values

  7. Check if the main window is open. If its closed; exit the program.

About

QR Code Following Robot made with Lego Mindstorms EV3 and Matlab

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published