Project Report on
Ball Follower Robot using Image Processing
No. 1 2 3 4 5 6 7 TOPIC Introduction Introduction to robots and robotics Requisites : Software tools Hardware tools Introduction to Image processing Introduction to Project Codes for basic and matlab Explanation and implementation
. The robot specified uses a Atmel microcontroller ATMega16 with a web camera mounted on it which is having video stream in a running mode where actually it sees the ball and where ever the ball is moving it just follows it automatically without any external control. it helps in taking images in current stream and allows camera to locate the ball and follow it using the concept of threshold. For using a web cam we need to include a software which is MATLAB.Introduction
About Ball Follower Robot
The project deals with a robot that locates and follows a ball across mounted with a web camera above and being controlled by a pc.
Introduction to Robot and Robotics:
Robotics . movable structure under some form of autonomous control. and their design. biomechanics). all robots share the features of a mechanical. mechanics and software. are comparatively rare. such as the Stewart platform. Some robots. Other structures. Robots used as manipulators have an end effector mounted on the last link. The chain is formed of links (its bones). it is usually an electro-mechanical system. the development and use of such structures in robots is an active area of research (e. use closed parallel kinematic chains. The structure of a robot is usually mostly mechanical and can be called a kinematic chain (its functionality being similar to the skeleton of the human body). This end effector can be anything from a welding device to a mechanical hand used to manipulate the environment. In practice. These robots are called serial robots and often resemble the human arm. Robotics is related to electronics. and application. such as those that mimic the mechanical structure of humans. mechanics. manufacture. and is usually accompanied by a large working knowledge of many subjects. actuators (its muscles) and joints which can allow one or more degrees of freedom. A robot is a virtual or mechanical artificial agent. However.g. and software. Robotics requires a working knowledge of electronics. various animals and insects. Most contemporary robots use open serial chains in which each link connects the one before to the one after it.
Although the appearance and capabilities of robots vary vastly.Robotics is the science and technology of robots.
Components of robots
A robot leg in the form of wheels with the help of motors
Some have a fixed manipulator which cannot be replaced. while others use chemicals. By far the most popular actuators are electric motors. but there are many others. spin rapidly when an electric current is passed through them. some of which are powered by electricity. which are familiar to many people. while the arm is referred to as a manipulator. DC motors. destroy or otherwise have an effect. for example a humanoid hand. Most robot arms have replaceable effectors. See End effectors. This information is then processed to calculate the appropriate signals to the actuators (motors) which move the mechanical structure.
Control and sensing
The mechanical structure of a robot must be controlled to perform tasks.The actuators are the 'muscles' of a robot. They will spin backwards if the current is made to flow in the other direction.g. as the controller knows exactly how far they have rotated. In its simplest manifestation
it consists of just two fingers which can open and close to pick up and let go of a range of small objects. while a few have one very general purpose manipulator.
Motors: By far the vast majority of robots use electric motors. without having to use a sensor. Thus the 'hands' of a robot are often referred to as end effectors. of which
there are several kinds. pick up. Stepper motors: As the name suggests. Therefore they are used on many robots and CNC machining centres. under the command of a controller.
Robots which must work in the real world require some way to manipulate objects. processing and action (robotic paradigms). stepper motors do not spin freely like DC motors. or compressed air. each allowing them to perform some small range of tasks. the parts which convert stored energy into movement. the position of its joints or its end effector). The control of a robot involves three distinct phases .perception.
. modify. they rotate in steps of a few degrees at a time. This makes them easier to control. Sensors give information about the environment or the robot itself (e.
A simple gripper
Grippers: A common effector is the gripper.
This information can be used to improve the control algorithms of a robot. it may translate raw sensor information directly into actuator commands.The processing phase can range in complexity.
. velocity and acceleration when the corresponding joint values are known. Some special aspects of kinematics include handling of redundancy (different possibilities of performing the same movement). Direct dynamics refers to the calculation of accelerations in the robot once the applied forces are known. Inverse dynamics refers to the calculation of the actuator forces necessary to create prescribed end effector acceleration. An immediate task (such as moving the gripper in a certain direction) is inferred from these estimates. Sensor fusion may first be used to estimate parameters of interest (e. collision avoidance and singularity avoidance. orientation. Direct kinematics refers to the calculation of end effector position. Techniques from control theory convert the task into commands that drive the actuators. Inverse kinematics refers to the opposite case in which required joint values are calculated for given end effector values. Once all relevant positions. the position of the robot's gripper) from noisy sensor data.
Dynamics and kinematics
The study of motion can be divided into kinematics and dynamics. as done in path planning. velocities and accelerations have been calculated using kinematics.g. At a reactive level. Direct dynamics is used in computer simulations of the robot. methods from the field of dynamics are used to study the effect of forces upon these movements.
plotting of functions and data. and Microsoft Excel
Hardware used: Nextsapiens basic robot with atmega16 microcontroller and all other features like:
. and interfacing with programs in other languages. and numerical integration 2-D and 3-D graphics functions for visualizing data Tools for building custom graphical user interfaces Functions for integrating MATLAB based algorithms with external applications and languages. COM. and data Interactive tools for iterative exploration. design. an optional toolbox uses the MuPAD symbolic engine. and problem solving Mathematical functions for linear algebra. creation of user interfaces. Fortran. filtering. files. Although it is numeric only. implementation of algorithms. statistics. allowing access to computer algebra capabilities. optimization. MATLAB allows matrix manipulation. such as C. Java. C++. Developed by The MathWorks.Requisites of Project
BASCOM-AVR MATLAB Programming language: Basic language in BASCOM: BASIC (an acronym for Beginner's Allpurpose Symbolic Instruction Code) is a family of high-level programming languages
Matlab: MATLAB is a numerical computing environment and fourth generation
• • • • • • •
High-level language for technical computing Development environment for managing code. Fourier analysis.
16/32 KB Flash RAM memory for programs ½ KB of SRAM 512/1024 Bytes of EEPROM Dual 7805 Voltage regulator Dual power input options Two programmable LEDs Lcd for display
Development board of nextsapiens with lcd DC geared motor Chassis 2 Tyres Web Camera
Specifications of Development board :
• • • • • • •
40 pin Atmel ATmega16/32 microcontroller with internal system clock upto 8 MHz and externally upto 16 MHz.
6 . E = Portb.6 = 0 Waitms 180 Pwm1b = 0
. Reference = Avcc Config Timer1 = Pwm .5 .
' generated.7 .3 .4 . Prescale = 1 . Compare A Pwm = Clear Down . Db5 = Portl = B. Prescaler = Auto . Db4 = Portb. Take care that the
Config Lcd = 16 * 2 Config Porta = Input Config Portb = Output Config Portd = Output Config Lcdpin = Pin . Db6 = Portb.Code in BASIC language for Ball follower robot in pc control
$regfile = "m16def.3 = 0 Pwm1a = 200 Portd. Db7 = Portb.dat" $crystal = 4000000 $baud = 9600 $prog &HFF . Compare B Pwm = Clear Down Dim A As String * 10 Start Adc Start Timer1 Cls Do A = Waitkey() If A = "l" Then Cls Print " moving left " Lcd "left" Lowerline Lcd "NEXTSAPIENS" Pwm1b = 0 Portd. &H00 chip supports all fuse bytes. Rs = Portb. &HD9 . Pwm = 8 .2 Config Adc = Single . &HC3 .
6 = 0
Elseif A = "r" Then Print " moving right " Cls Lcd "right" Lowerline Lcd "NEXTSAPIENS" Pwm1b = 200 Portd.3 = 0 Pwm1a = 0 Portd.3 = 0 Pwm1a = 00 Portd.6 = 0
Elseif A = "s" Then Cls Lcd "stop" Lowerline Lcd "NEXTSAPIENS" Print " stop moving " Pwm1b = 0 Portd.3 = 0 Pwm1a = 0 Portd.3 = 0 Pwm1a = 0 Portd.6 = 0 Waitms 180 Cls Elseif A = "f" Then Cls Lcd "forward" Lowerline Lcd "NEXTSAPIENS" Print " moving forward " Pwm1b = 200
.6 = 0 Waitms 180 Pwm1b = 0 Portd.Portd.
Portd.6 = 0
Elseif A = "b" Then Cls Lcd "backward" Lowerline Lcd "NEXTSAPIENS" Print " moving backward" Pwm1b = 0 Portd.6 = 0 Waitms 180 Pwm1b = 0 Portd.3 = 1 Pwm1a = 0 Portd.3 = 0 Pwm1a = 0 Portd.3 = 0 Pwm1a = 200 Portd.3 = 0 Pwm1a = 0 Portd.6 = 1 Waitms 180 Pwm1b = 0 Portd.6 = 0 End If Loop End
.n)=1. Ymax=Y+40.Code for making a ballfollower robot using color recognition principle
function ballfollower pause(1) Vid=video input(‘winvideo’). v%fm('preview'). [a b c]=size(im).n)=0.n)>80 && im1(m. for m=1:a for n=1:b if(im1(m. Im=get snapshot(vid). else I(m. ser=serial('com6'). Ymin=Y-40.y]=centroid(I) X=160. end end end [x. Y=120.n)<160 && im2(m.:.1).n)<75 && im3(m.2).3). Xmin=X-40. im1=im(:. im2=im(:.n)<80 && im3(m. fopen(ser).n)>40 && im2(m.n)>40) I(m. if (x<Xmax && x>Xmin) if(y<Ymax && y>Ymin) fprintf(ser.'s').:. Xmax=X+40. im3=im(:. %Im=vfm('grab'). %in case you are using matlab R13 or below % use %vfm('show').
else if(y<Ymin) fprintf(ser. Next we determine the centroid of the image so that robot moves towards the centroid as found out. end end end fclose(ser).'l').'f'). else if(x>Xmax) fprintf(ser. This is done by capturing the image of ball and checking the value of its pixels at various points bu using command imview Imview(i) Shows the image just like imshow But it also displays the value of pixel where the cursor is currently located at the bottom of the screen. For more accuracy take atleast ten images at different angles and find minimum and maximum pixel value for the ball and put it in the code given.disp('success!!!').
.e. The algorithm for finding the centroid is self explanatory . Now the function moves as follows The camera attached to the robot takes images at frequent intervals and processes it by converting the image to binary image such that image is white if pixel value lies in desired range and black otherwise. end end end else if(x<Xmin) fprintf(ser.'r'). know the exact values of pixel elements of the ball to be followed. Explanation First of all for running the function it is necessary to calibrate I. Next after finding the centroid we open the serial port for communication with the robot. This is achieved by command Ser(’com1’). else if(y>Ymax) fprintf(ser.'b').
Fopen(ser). When the serial port is open and we know the centroid. Note:. we send the direction to be followed by robot over the serial port and the robot follows accordingly when programmed as a simple pc controlled algorithm.after your work with serial port is over always close the port using command fclose(ser).