0% found this document useful (0 votes)
46 views93 pages

Robotech

1. The document provides a historical overview of robot development from 1801 to 1954, including important events and inventions such as Joseph Jacquerd's textile machine operated by punch cards, Isaac Asimov's introduction of the Three Laws of Robotics, and George Devol's invention of the first programmable robot. 2. It describes the typical components of a robot, including the communicator, control computer, end effectors, manipulator, power supply, sensors, and actuators. 3. It introduces the MATLAB software environment, describing the default window layout and the purpose of the command window, figure window, editor window, help window, command history window, workspace window, and current folder window.

Uploaded by

riotleague011
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views93 pages

Robotech

1. The document provides a historical overview of robot development from 1801 to 1954, including important events and inventions such as Joseph Jacquerd's textile machine operated by punch cards, Isaac Asimov's introduction of the Three Laws of Robotics, and George Devol's invention of the first programmable robot. 2. It describes the typical components of a robot, including the communicator, control computer, end effectors, manipulator, power supply, sensors, and actuators. 3. It introduces the MATLAB software environment, describing the default window layout and the purpose of the command window, figure window, editor window, help window, command history window, workspace window, and current folder window.

Uploaded by

riotleague011
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 93

Oct 15, 2022 Refer to Table 1.

1 for other Key Events in the History of


Robotics
INTRODUCTION TO ROBOTICS AND ROBOTICS CONCEPTS

Historical Overview of Robot Development

1801

Joseph Jacquerd invents the textile machine that is operated


by punch cards.

1892

In the US Seward Babbit designed a motorized crane with a


gripper to remove ingots from a furnace.

1921

First reference to the word robot appears in a play opening in


London entitled “Rossums Universal Robots”. The play was
written by Czechoslovakian Karel Capek and introduces the
word robot from the Czeck robota meaning serf or
subservient labor

1939

Isaac Asimovs science fiction writing introduces robots


designed for humanity and work safely. He formulates the
“Three Laws of Robotics”

1939

Isaac Asimovs science fiction writing introduces robots


designed for humanity and work safely. He formulates the
“Three Laws of Robotics”

1946

George David patents a general purpose playback device for


controlling machines.

1948

Norbert Wiener, a professor of Massachusetts Institute of


Technology (MIT) publishes Cybernetics, a book that
describes the concept of communications and control in
electronic, mechanical and biological systems.

1951

A tele-operator equipped articulated arm is designed by


Raymond Goertz for the Atomic Energy Commisison.

1954

The first programmable robot is designed by George Devol


who coined the term universal automation. Devol is joined by
Joseph Engelberger in 1956 and shorten the name to
Unimation and form the first successful robot manufacturing
company.
These multi-purpose machines are generally designed to
carry out the repetitive functions and be adapted to other
functions.

“Three Laws of Robotics”, Asimov

1. A Robot may not injure a human being, or through


inaction, allow a human being to come to harm
2. A robot must obey orders given to it by human
beings except where such orders would conflict with
the first law.
3. A robot must protect its own existence as long as
such protection does not conflict with the first and
second laws.

What is inside a robot?

We can start by looking at a robot as a physical system.


However, instead of looking at it all joined together, you
can see how a typical hobby rover looks when totally
disassembled.

COMPONENTS OF A ROBOT

Communicator
- A unit transmitting information and receiving
instructions from a remote operator

Control Computer/Controller (Brain)


- The central computer that integrates the activity of
several microprocessors

-the brain of the robot

End Effectors (Hands)

- The device at the end of the manipulator's arm that


performs the actual work.

-Gripper, hooks, scoops

Manipulator (Arm)

-A mechanism consisting of several segments or arms


which provide the necessary motion to move the tool or
part into the proper position.

Power Supply

-Generally, some energy storage devices such as


batteries for a mobile units otherwise hook up to the
power grid.

What is a Robot? Sensor (Eye)

A reprogrammable, multifunctional manipulator designed to -Usually a transducer of some kind whose inputs are
move parts, materials, tools, or special devices through physical phenomena and whose outputs consist of
variable programmed motions for the performance of a electronic signals.
variety of different tasks. Actuator
-Serves as the muscle of the system, and produces the 3. How to define scalar variables
motion with power supplied electrically, pneumatically,
4. Introduce the script files
or through hydraulics.
5. How to write, save, and execute simple MATLAB programs.

MATLAB Windows:

The layout has a Toolstrip at the top, the Current Folder


Toolbar below it, and four windows underneath.

At the top of the toolstrip, there are three tabs: HOME,


PLOTS, and APPS.

Commonly, MATLAB is used with the HOME tab selected.

The PLOTS tab can be used to create plots

APPS tab can be used for opening additional applications and


Toolboxes of MATLAB.

MATLAB Windows: The Default Layout

The default layout (Figure 1) consists of the following four


windows that are displayed under the Toolstrip:

the Command Window (larger window at the center),

the Current Folder Window (on the left) and

the Workspace and

Command History windows (on the right).

MATLAB Windows

–Command Window - Main window, enters variables, runs


programs.

–Figure Window - Contains output from graphic commands.

–Editor Window - Creates and debugs script and function


Starting with MATLAB
files.
Objectives:
–Help Window - Provides help information.
1. Purpose of different windows in MATLAB.
–Command History Window - Logs commands entered in the
2. How to use MATLAB for arithmetic operations with scalars Command Window.
–Workspace Window - Provides information about the executed. Everything executed previously (that might still be
variables that are stored. displayed) is unchanged.

–Current Folder Window - Shows the files in the current -Several commands can be typed in the same line. This is
folder. done by typing a comma between the commands. When the
Enter key is pressed, the commands are executed in order
from left to right

-It is not possible to go back to a previous line that is


displayed in the Command Window, make a correction, and
then re-execute the command.

-A previously typed command can be recalled to the


command prompt with the up arrow key ( ↑ ). When the
command is displayed at the command prompt, it can be
modified if needed and then executed. The down-arrow key
(↓) can be used to move down the list of previously typed
commands

-If a command is too long to fit in one line, it can be


continued to the next line by typing three periods ... (called
an ellipsis) and pressing the Enter key. The continuation of
the command is then typed in the new line. The command
can continue line after line up to a total of 4,096 characters.

The semicolon ( ; ):

-When a command is typed in the Command Window, and


the Enter key is pressed, the command is executed

-Any output that the command generates is displayed in the


Command Window.

-If a semicolon ( ; ) is typed at the end of a command, the


output of the command is not displayed.

-Typing a semicolon is useful when the result is obvious or


known, or when the output is very large.

Typing %:

-When the symbol% (percent) is typed at the beginning of a


line, the line is designated as a comment.

-This means that when the Enter key is pressed the line is not
executed.
Working in the Command Window
-The % character followed by text (comment) can also be
The Command Window is MATLAB's main window and can be
typed after a command (in the same line). This has no effect
used for executing commands, opening other windows,
on the execution of the command.
running programs written by the user, and managing the
software.

Notes for working in the Command Window: Comments are frequently used in a program to add
descriptions or to explain the program.
-To type a command, the cursor must be placed next to the
command prompt ( >> ). The clc command:
-Once a command is typed and the Enter key is pressed, the -The clc command (type clc and press Enter) clears the
command is executed. However, only the last command is Command Window.
Arithmetic Operations with Scalars

Go to the command window, and try the following examples:

Trigonometric Math Functions

• The inverse trigonometric functions are asin(x),


acos(x), a tan(x), acot(x) for the angle in radians; and
asind(x), acosd(x), atand(x), acotd(x) for the angle in
degrees.
• The hyperbolic trigonometric functions are sinh(x),
cosh(x), tanh(x), and coth(x) .
• The table above uses pi, which is equal to π
Rounding Functions

Rules About Variable Name


The Assignment Operator
A variable can be named according to the following rules:
In MATLAB the = sign is called the assignment operator. The
assignment operator assigns a value to a variable • Must begin with a letter.
• Can be up to 63 characters long.
• Can contain letters, digits, and the underscore
character.
• Cannot contain punctuation characters (e.g., period,
comma, semicolon).
• MATLAB is case-sensitive: it distinguishes between
uppercase and lowercase letters. For example, AA,
Aa, aA, and aa are the names of four different
variables.

If a semicolon is typed at the end of the command, then A variable can be named according to the following rules:
when the Enter key is pressed, MATLAB does not display the
• No spaces are allowed between characters (use the
variable with its assigned value (the variable still exists and is
underscore where space is desired).
stored in memory).
• Avoid using the name of a built-in function for a
If a variable already exists, typing the variable's name and variable (i.e., avoid using cos, sin, exp, sqrt, etc.).
pressing the Enter key will display the variable and its value in Once a function name is used for a variable name,
the next two lines. the function cannot be used.

Several assignments can be typed in the same line. The Predefined Variables and Keywords
assignments must be separated with a comma (spaces can be
There are 20 words, called keywords, that are reserved by
added after the comma). When the Enter key is pressed, the
MATLAB for various purposes and cannot be used as variable
assignments are executed from left to right, and the variables
names. These words are:
and their assignments are displayed. A variable is not
displayed if a semicolon is typed instead of a comma.

When typed, these words appear in blue. An error message is


displayed if the user tries to use a keyword as a variable
name. (The keywords can be displayed by typing the
command iskeyword.)
A number of frequently used variables are already defined 1. A script file is a sequence of MATLAB commands, also
when MATLAB is started. Some of the predefined variables called a program.
are:
2. When a script file runs (is executed), MATLAB executes
ans A variable that has the value of the last expression the commands in the order they are written, just as if they
that was not assigned to a specific variable. If the user does were typed in the Command Window.
not assign the value of an expression to a variable, MATLAB
3. When a script file has a command that generates an
automatically stores the result in and.
output (e.g., assignment of a value to a variable without a
pi The number π. semicolon at the end), the output is displayed in the
Command Window.

eps The smallest difference between two numbers. Equal


to 2^(-52), which is approximately 2.2204e-16. 4. Using a script file is convenient because it can be edited
(corrected or otherwise changed) and executed many times.
inf Used for infinity.
5. Script files can be typed and edited in any text editor and
i Defined as sqrt(-1), which is: 0 + 1.0000i.
then pasted into the MATLAB editor.
j Same as I.
6. Script files are also called M-files because the extension
NaN Stands for Not-a-Number. Used when MATLAB .m is used when they are saved.
cannot determine a valid numeric value. Example: 0/0.
Creating and Saving a Script File
Useful Commands for Managing Variables
In MATLAB script files are created and edited in the
The following are commands that can be used to eliminate Editor/Debugger Window.
variables or to obtain information about variables that have
This window is opened from the Command Window by
been created.
clicking on the New Script icon in the Toolstrip, or by clicking
Command - Outcome New in the Toolstrip and then selecting Script from the menu
that open.
clear - Removes all variables from the memory.

clear x y z - Removes only variables x, y, and z from the


memory.

who - Displays a list of the variables currently in the memory.

whos - Displays a list of the variables currently in the memory


and their sizes together with information about their bytes
and class

Script Files

The commands in the Command Window cannot be saved


and executed again.

In addition, the Command Window is not interactive.

This means that every time the Enter key is pressed only the
last command is executed, and everything executed before is
unchanged.

The commands in the file can be corrected or changed, and


the file can be saved and run again.

Files that are used for this purpose are called Script Files.

Notes About Script Files


When the current folder is not the folder where the script file
is saved, then the prompt shown in Figure below opens.

The user can then change the current folder to the folder
where the script file is saved, or add it to the search path.

Challenge 2: Calculating worker's pay

-A worker is paid according to his hourly wage up to 40 hours,


Creating and Saving a Script File
and 50% more for overtime. Write a program in a script file
Before a script file can be executed it has to be saved. This is that calculates the pay to a worker. The program asks the
done by clicking Save in the Toolstrip and selecting Save As ... user to enter the number of hours and the hourly wage. The
from the menu that opens. program then displays the pay.

When saved, MA TLAB adds the extension .m to the name. BASIC OF LINEAR ALGEBRA: SOLVING SIMULTANEOUS
EQUATION
The rules for naming a script file follow the rules of naming a
variable (must begin with a letter, can include digits and Learning Objective
underscore no spaces, and up to 63 characters long). The
Create algorithms to solve problems involving linear algebraic
names of user-defined variables, predefined variables, and
equations and appreciate the application of these equations
MATLAB commands or functions should not be used as
in the fields of engineering.
names of script files.
Background
Running (Executing) a Script File

A script file can be executed either directly from the Editor • System of linear equations that have to be solved
Window by clicking on the Run icon or by typing the file name simultaneously arise in problems that include several
in the Command Window and then pressing the Enter key. (possibly many) variables that are dependent on
each other. Ex. Electrical engineering
For a file to be executed, MATLAB needs to know where the • Such problems occur not only in engineering and
file is saved. The file will be executed if the folder where the sciences but in virtually any discipline (business,
file is saved is in the current folder of MATLAB or if the folder statistics, economics, etc.)
is listed in the search path. • A system of two (or three) equations with two or
(three) unknowns can be solved manually by
substitution or other mathematical methods.
• Solving a system in this way is practically impossible With that, we will apply Matrix to solve linear Equations with
as the number of equations (and unknowns) 3 or more unknowns.
increases beyond three.
Matrix Notation
• Matrix notation and algebra are useful because they
provide a concise way to represent and manipulate A matrix consists of a rectangular array of elements
linear algebraic equations. represented by a single symbol.
Graphical Methods [A] is the shorthand notation for the matrix and aij designates
an individual element of the matrix
Example Problem:

The Graphical Method for Two Equations

• A horizontal set of elements is called a row and a


vertical set is called a column.
• The first subscript i always designates the number of
the row in which the element lies.
• The second subscript j designates the column.
Drawbacks of the graphical method: • For example, element a23 is in row 2 and column 3.
Drawbacks of the graphical method: Graphical depiction of • The matrix in Fig. below has n rows and m columns
singular and ill-conditioned systems: (a) no solution, (b) and is said to have a dimension of n by m (or n × m).
infinite solutions, and (c) ill-conditioned system where the It is referred to as an n-by-m matrix.
slopes are so close that the point of intersection is difficult to • Matrices with row dimension n = 1, such as [B] = [b1
detect visually, as shown in the figure b2 · · · bm] are called row vectors.
• The matrix in Fig. above has n rows and m columns
and is said to have a dimension of n by m (or n × m).
It is referred to as an n-by-m matrix.
• Matrices with row dimension n = 1, such as [B] = [b1
b2 · · · bm]
• Matrices with column dimension m = 1, such as

Determinants and Cramer’s Rule

Drawback: Cramer’s rule is another solution technique that is


best suited to small numbers of equations.

Try this one: Find the value of x, y, & z


• For simplicity, the second subscript is dropped. As • An identity matrix is a diagonal matrix where all
with the row vector, there are occasions when it is elements on the main diagonal are equal to 1, as
desirable to employ a special shorthand notation to in
distinguish a column matrix from other types of
matrices.
• One way to accomplish this is to employ special
brackets, as in {C}.
• Matrices where n = m are called square matrices. For
example, a 4 by 4 matrix is

• The symbol [ I ] is used to denote the identity matrix.


The identity matrix has properties similar to unity.
• An upper triangular matrix is one where all the
• The diagonal consisting of the elements a11, a22, elements below the main diagonal are zero, as in
a33, and a44 is termed the principal or main
diagonal of the matrix.
• There are a number of special forms of square
matrices that are important and should be noted:
• A symmetric matrix is one where aij = aji for all i’s
and j’s. For example below, is a 3 by 3 symmetric
matrix.

• A lower triangular matrix is one where all


elements above the main diagonal are zero, as
in

• A diagonal matrix is a square matrix where all


elements off the main diagonal are equ

• Banded matrix has all elements equal to zero,


with the exception of a band centered on the
main diagonal:
al to zero, as in

• Note that where large blocks of elements are


zero, they are left blank.
The trace of a matrix is the sum of the elements on its
The above matrix has a bandwidth of 3 and is given a special principal diagonal. It is designated as tr[A] and is computed
name—the tridiagonal matrix. as:

MATRIX OPERATION

• Addition
• Subtraction
• Multiplication
• Division (using Inverse)

Addition and subtraction are possible if the dimension of the The trace will be used in the discussion of eigenvalues.
2 matrices is equal.
The final matrix manipulation that will have utility in our
For multiplication, the below conditions must be followed: discussion is augmentation.

A matrix is augmented by the addition of a column (or


columns) to the original matrix.

For example, suppose we have a matrix of coefficients:

Two other matrix manipulations that will have utility in our


discussion are the transpose and the trace of a matrix.

The transpose of a matrix involves transforming its rows into We might wish to augment this matrix [A] with an identity
columns and its columns into rows. For example, for the 4 × 4 matrix to yield a 3-by-6-dimensional matrix:
matrix,

Representation of Linear Algebraic Equations in Matrix Form

It should be clear that matrices provide a concise notation for


representing simultaneous linear equations that can be
the transpose, designated [A]T, is defined as:
expressed
LU DECOMPOSITION
- Gauss Elimination

- Crout's Method
where [A] is the n by n square matrix of coefficients,
- Choleski's Method
Upper Triangular – the system in this form has all zero
coefficients below the diagonal and is solved by a procedure
called Back Substitution. A similar form is used in the Gauss
Elimination Method.

{B} is the n by 1 column vector of constants,

Lower Triangular – the system in this form has all zero


coefficients above the diagonal and is solved by a procedure
called Forward Substitution. A similar form is used in the
Gauss Elimination Method

Diagonal Form– a system of this form that has nonzero


coefficients along the diagonal and zeros everywhere else. A
similar form is used in the Gauss-Jordan Method

Gauss - Elimination

• It is a procedure for solving a system of linear


equations.
• If the linear equations are represented in the
following equations:

DIRECT METHODS OF SOLVING LINEAR EQUATIONS USING


DIRECT METHODS

GAUSS-ELIMINATION
- Upper Triangular

- Lower Triangular

GAUSS-JORDAN
- Diagonal Form
and is substituted to Eq.1 to give

[L][y]=[b] ------Eq.3

The solution [x] is obtained in two steps.

1. 3 is solved for [y]

2. Then, the solution [y] is substituted in Eq.2,


and that equation is solved for [x].

LU decomposition can be solved using Gauss


Elimination methods, Crout’s Method & Choleski’s Method

LU DECOMPOSITION with Gauss Elimination Method


Gauss – Elimination Procedure (Backward Substitution)
Using Gauss Elimination,
Need to know the algorithms
Find [U] matrix, then solve for [L] matrix, and make the
– steps that have to be followed in order to implement the diagonal of the [L] matrix all 1’s. Then solve for unknown
numerical methods successfully. using LU steps.
- step-by-step instructions on how to carry out the solution.

Pivot Equation – the unchanged equation having the pivot


coefficient or the pivot element

MATLAB ACTIVITY

Robotics in Our Everyday Lives

1.Demanding

2. Demeaning

3.dirty
LU DECOMPOSITION
4.dangerous
The LU decomposition method is a method for solving a
system of linear equations [a][x]=[b]. 5.Driving

In this method, the matrix of coefficients [a] is Scot:


decomposed (factored) into a product of two matrices [L] and
Shared computer operating transport
[U]
Rovers sa Mars:
[a]=[L][U]
Sojourner, Spirit and Opportunity, Curiosity, and
Where the matrix [L] is a lower triangular matrix and
Perseverance
[U] is an upper triangular matrix.
ROBOT CONCEPTS, CLASSIFICATIONS, USER/APPLICATION
With this decomposition, the system of equations to
be solved has the form Degrees of Freedom

[L][U][x]=[b] -----Eq.1 • Refers to different axes of motion of the robotic


arm.
To solve this equation, the product [U][x] is defined as:
• The movement about one axis is hardware
[U][x]=[y] -----Eq.2 independent of movement about any other axis.
• Total number of locations
• P=2n
where: P – number of possible locations Numerically Controlled Robot
n – degrees of freedom ▫Programmed and operated much like a numerically
• Waist motion or Arm sweep - Motion of the entire controlled machine.
arm about the fixed base ▫Numerically Controlled Robot
• Shoulder or Vertical Motion - Movement above the ▫Servo-controlled by digital data
waist
• Elbow extension Intelligent (Sensory) Robot
• Wrist Motion ▫Equipped with a variety of sensors with visual and tactile
capabilities.
Pitch – up and down ▫Controlled by powerful computers
Yaw – side to side
Roll - \rotation of the wrist about the axis of the forearm ACCORDING TO MOVEMENT
Rectilinear / Cartesian
Robots Wrist Rotation ▫Works with Cartesian manipulator arm geometry
▫Movement is in three directions only up/down,
left/right, and front/back.

Cylindrical Robot
▫Robot whose work envelope is cylindrical
▫Robot’s arm swings around its base in a circular or polar
motion. (up and down, front end)

Spherical Robot
▫Robot whose work envelope is spherical in shape and
obviously is has spherical manipulator arm geometry.
▫With polar articulation for waist and shoulder and
rectilinear motion for reach.
▫The base moves in a circular motion (up to 210 degrees)
while its main arm moves up and down and in and out
• Pitch Axis
(extension and retraction)
Describes the wrist's rotational movement up and down
• Yaw Axis Fully Articulated Robot
Describes the wrist angular movement from the left side to ▫Robot with polar articulation for all degrees of
the right side.
movement
• Roll Axis ▫One example is the SCARA (Selective Compliance
Describes the rotation around the end of the wrist. Assembly Robotic Arm) which has six axes and therefore
increases its degrees of freedom.
CLASSIFICATION OF ROBOTS ▫Used in welding, painting, laser cutting, and water jet
cutting.
✓ According to Control
ACCORDING TO THE PROGRAM USED
✓ According to Movement Positive Stop
▫Produces only 2 position motion
✓ According To Program Used ▫Limited sequence or Bang – bang motion

ACCORDING TO CONTROL Point to Point


▫Ability to move a robot axis to any position within its
Fixed/Variable Sequence range
▫Pick and place robots
▫Point to point movement Continuous Path
Playback Robot ▫Like point to point
▫Robots that memorizes and records the path and ▫Destination points are very close together.
sequence of motions and can repeat them continuously
without guidance from the operator.
MODERN USES OF ROBOTS • Python can be used on a server to create web
applications.
Exploration
▫Full of danger or deep ocean WHY PYTHON?

1. Fastest Growing Programming Language


Industry
▫Repetitive Work

Medicine
▫Operation (making medicines)

Military and Police


▫Bomb disposal, spying, entering enemy bases

Entertainment

FACTORS: SELECTION OF ROBOTS

Work Volume
Speed and acceleration 2. Top Programming Languages 2021> Python
Repeatability dominates as the de facto platform for new
Resolution technologies
Accuracy
Economics
Safety

PYTHON ACTIVITY

INTRODUCTION TO PYTHON PROGRAMMING

AGENDA:

✓ Anaconda Tools
✓ Spyder
✓ JupyterLab
✓ Jupyter Notebook
✓ Google Colaboratory (colab)
✓ Visual Studio Code

ANACONDA

• Anaconda is a distribution of the Python and R


programming languages for scientific computing,
that aims to simplify package management and
deployment.

PYTHON
3. Key Python Packages for Data Science
• Python is a popular programming language.
• Python is an interpreted high-level general-purpose
programming language.
• Its language constructs as well as its object-oriented
approach aim to help programmers write clear,
logical code for small and large-scale projects.
4. Python works on different platforms (Windows, Mac,
Linux, Raspberry Pi, etc).

5. Python has a simple syntax similar to the English Spyder environment


language

6. Python has a syntax that allows developers to write


programs with fewer lines than some other programming
languages

7. Python runs on an interpreter system, meaning that code


can be executed as soon as it is written. This means that
prototyping can be very quick.

8. Python can be treated in a procedural way, an object-


oriented way or a functional way.

ANACONDA Environment JUPYTERLAB

JupyterLab is a next-generation web-based user interface for


Project Jupyter.

SPYDER

It refers to Scientific Python Development EnviRonment

Powerful Python IDE with advanced editing, interactive


testing, debugging, and introspection features.

Jupyterlab environment
Colab, or "Colaboratory", allows you to write and execute
Python in your browser, with

Zero configuration required

Access to GPUs free of charge

Easy sharing

Whether you're a student, a data scientist, or an AI


researcher, Colab can make your work easier.

Source:
JUPYTER NOTEBOOK https://colab.research.google.com/#scrollTo=5fCEDCU_qrC0L
inks to an external site.
It is a web-based, interactive computing notebook
environment. COLAB Environment: Go to Drive->New->More->Google
Colaboratory
Edit and run human-readable documents while describing the
data analysis

Python Getting Started

Python Install

Many PCs and Macs will have python already installed.

To check if you have python installed on a Windows PC,


search in the start bar for Python or run the following on the
Command Line (cmd.exe):

C:\Users\Your Name>python --version

To check if you have python installed on a Linux or Mac, then


on linux open the command line or on Mac open the Terminal
and type:
GOOGLE COLABORATORY (COLAB)
python --version
What is Colab?
Python Syntax

Execute Python Syntax


As we learned in the previous page, Python syntax can be
executed by writing directly in the Command Line:

>>> print("Hello, World!")

Hello, World!

Or by creating a python file on the server, using the .py file


extension, and running it in the Command Line:

C:\Users\Your Name>python myfile.py

Python Indentation

• Indentation refers to the spaces at the beginning of a


code line.
• Whereas in other programming languages the
indentation in code is for readability only, the
indentation in Python is very important.
• Python uses indentation to indicate a block of code.

Example:

if 5 > 2:

print("Five is greater than two!")

Python will give you an error if you skip the indentation:

Example

Syntax Error:

if 5 > 2:

print("Five is greater than two!")


energy, etc, and Actuators which can be used to
switch voltages or currents

Quantities and Units

ROBOT SENSORS

TRANSDUCER

• is defined as a device that converts one form of


energy into another form of the energy
• any device or component that converts an input
signal of one form to an output signal of another form
• an element or device which receives information in
the form of one quantity and converts it to
information in the same or another quantity or form.
• A device for translating the magnitude of one SENSOR
quantity into another quantity.
• A device that provides a usable output in response to
• Are used for compensation in different plants and
a specified measurement
systems.
• A sensor acquires a physical parameter and converts
• Help in reducing the sensitivity of a system to
it into a signal suitable for processing (e.g. optical,
parameter change.
electrical, mechanical).
• The word “Transducer” is the collective term used for
both Sensors which can be used to sense a wide range
of different energy forms such as movement,
electrical signals, radiant energy, thermal or magnetic
PROXIMITY SENSOR

• A proximity sensor detects an object when the object


approaches the detection boundary of the sensor.
Proximity sensors are used in various facets of
manufacturing for detecting the approach of
Passive Sensors different objects.
• Various types of proximity sensors are used for
• Transducers that require an external power source detecting the presence or absence of an object
for their operation. They produce an output signal in • Proximity sensors provide long-range detection,
the form of some variation in resistance, capacitance, which is evidently more precise than human vision.
or any other electrical parameter, which then has to Simply sensors solve the limitations and extend the
be converted to an equivalent current or voltage range of human senses.
signal. • For example, a capacitive or photoelectric sensor
might be suitable for a plastic target; an inductive
proximity sensor always requires a metal target.
• It is a sensor able to detect the presence of nearby
objects without any physical contact.
• Often emits an electromagnetic or electrostatic field
or a beam of electromagnetic radiation (infrared, for
instance), and looks for changes in the field or return
signal.
• The object being sensed is often referred to as the
proximity sensor’s target.
• The maximum distance that this sensor can detect is
For example, a photocell (LDR) is a passive transducer that will
defined "nominal range." Some sensors have
vary the resistance of the cell when light falls on it. This change
adjustments of the nominal range or means to report
in resistance is converted to a proportional signal with the help
a graduated detection distance.
of a bridge circuit. Hence a photocell can be used to measure
the intensity of light. APPLICATIONS:
Active Sensors ✓ PRODUCTION
✓ SAFETY
• Active sensors contrast with passive sensors, which
✓ BIOMETRICS TECHNOLOGY
simply detect and respond to some type of input from
✓ URBAN ENVIRONMENT
the physical environment.
✓ ENTERTAINMENT
• An example of an active sensor is a measuring
✓ CRIME PREVENTION
instrument that generates a signal, transmits it to a
✓ APPLIANCES
target, and receives a reflected signal from the target.
✓ MEDICAL TECHNOLOGY
Information concerning the target is obtained by
comparison of the received signal with the APPLICATIONS:
transmitted signal.
1. Parking sensors, systems mounted on car bumpers
Examples of Active Sensors that sense the distance to nearby cars for parking

✓ scanning electron microscopes, PROXIMITY SENSOR BLOCK DIAGRAM


✓ LiDAR,
✓ radar,
✓ GPS,
SENSING FACE – is responsible for the emission of the
✓ x-ray,
electrostatic/electromagnetic field to which the target will be
✓ sonar,
exposed. It is also the part that is being exposed to the
✓ infrared and sensor’s target.
✓ seismic.
OSCILLATOR – creates the repetitive signal with a defined
frequency, in which its amplitude varies depending on the
distance of the target from the sensing face.

DEMODULATOR – Extracts signal amplitude from the


oscillating carrier. The extracted amplitude carries the
information that is equivalent or linear to the distance of the
target object from the sensing face.

- The signal strength is compared to a


sufficient level and triggers feedback which is sent to the flip-
OPERATIONS:
flop circuit.
• The sensing surface of a capacitive sensor is formed
FLIP-FLOP – The flip-flop triggers the output when it has
by two concentrically shaped metal electrodes of an
received the feedback signal from the comparator in the
unwound capacitor.
demodulator circuit.
• When an object nears the sensing surface, it enters
OUTPUT- the output acts as a switch that is physically the electrostatic field of the electrodes and changes
connected to the circuitry in which the sensor is wired. the capacitance in an oscillator circuit.
• As a result, the oscillator begins oscillating. The
Inductive proximity sensor trigger circuit reads the oscillator’s amplitude and
• Widely used in modern high-speed process control when it reaches a specific level the output state of
environments for the detection, positioning, and the sensor changes.
counting of ferrous and non-ferrous metal objects. • As the target moves away from the sensor the
• Rely on the effect of a magnet approaching a high oscillator’s amplitude decreases, switching the
turns ratio coil that produces a voltage proportional sensor output back to its original state.
to the relative distance of that magnetic source from Capacitive Proximity Sensor
that coil.
Depends upon the dielectric constant of the target. The
larger the dielectric number of a material, the easier it is
to detect.

Capacitive Proximity Sensor

• Is similar to inducting proximity sensors. The main


difference between the two types is that capacitive
proximity sensors produce an electrostatic field
instead of an electromagnetic field.
• Capacitive switches will sense metal as well as
nonmetallic materials such as paper, glass, liquids,
and cloth.

Note: Sr – Sensing Distance (%)

• The above graph shows the relationship of the


• The larger the dielectric number of a material
the easier it is to detect.
• The dielectric constant of a target and the
sensor’s ability to detect the material based on
the rated sensing distance (Sr).
DIELECTRIC CONSTANT OF THE TARGET

Piezoelectric Disk

• A piezoelectric ceramic disk is mounted on the sensor


surface. It can transmit and receive high-frequency
pulses. A high-frequency voltage is applied to the disk,
causing it to vibrate at the same frequency.
• The vibrating disk produces high-frequency sound
waves. When transmitted pulses strike a sound-
• The above table shows the dielectric constants of reflecting object, echoes are produced.
some materials. • The duration of the reflected pulse is evaluated at the
• If, for example, a capacitive sensor has a rated sensing transducer. When the target enters the preset
distance of 10 mm and the target is alcohol, the operating range, the output of the switch changes
effective sensing distance (Sr) is approximately 85% state. When the target leaves the preset operating
of the rated distance, or 8.5 mm. range, the output returns to its original state.
• The sensitivity of the capacitive sensor is affected by • The emitted pulse is actually a set of 30 pulses at an
the moisture content and the density of the amplitude of 200 Kvolts. The echo can be in
substance to be sensed. microvolts.
COMMON APPLICATIONS

1. Level detection through a barrier

- For example, water has a much higher dielectric than


plastic. This gives the sensor the ability to “see through” the
plastic and detect the water.

Blind Zone

A blind zone exists directly in front of the sensor. Depending


on the sensor, the blind zone is from 6 to 80 cm. An object
placed in the blind zone will produce an unstable output.

COMMON APPLICATIONS

1. Controlling the fill level of solids in a bin.

2. Detecting fluids in containers such as milk.

ULTRASONIC PROXIMITY SENSOR

Ultrasonic proximity sensors use a transducer to send and


receive high-frequency sound signals. When a target enters
the beam, the sound is reflected back to the switch, causing it
to energize or de-energize the output circuit.
Range Definition

• The time interval between the transmitted signal and


the echo is directly proportional to the distance
between the object and the sensor.
• The operating range can be adjusted in terms of its
width and position within the sensing range. The
upper limit can be adjusted on all sensors. The lower
limit can be adjusted only with certain versions.
• Objects beyond the upper limit do not produce a
change in the output of the sensor. This is known as
“blanking out the background”.

Radiation Pattern

The radiation pattern of an ultrasonic sensor consists of the


main cone and several neighboring cones. The approximate
angle of the main cone is 5°.

Mutual Interference

• Mutual interference occurs when sonar devices are


mounted in close proximity to each other, and the
target is in a position to reflect echoes back to a
sensor in the proximity of the transmitting sensor.
• In this case, the distance between sensors (X) can be
determined through experimentation.
Similar to beamwidth. Beamwidth – in radio antenna pattern,
the angle between the half-power (-3db) points of the main
lobe, when referencing to the peak effective radiated power of
the main lobe.

Free Zones

-Free zones must be maintained around the sensor to allow for


neighboring cones. The following examples show the free area
required for different situations.

Parallel Sensors

• Two sonar sensors with the same sensing range have


been mounted parallel to each other. The targets are
vertical to the sound cone. The distance between the
sensors is determined by the sensing range.
• For example, if the sensing range of the sensors is 6
cm, they must be located at least 15 cm apart.
Opposing Sensors

• Two sonar sensors with the same sensing range have


been positioned opposite of each other. A minimum
distance (X) is required between opposing sensors so
that mutual interference does not occur.

If the angle were greater than 3°, the sonic pulses would be
reflected away, and the sensor would not receive an echo.

Flat and Irregular Shaped Surfaces

• Sonar sensors mounted next to a flat surface, such


as a wall or smooth machine face, require less free
area than sensors mounted next to an irregularly
shaped surface. Liquids and Coarse-Grained Materials

• Liquids, such as water, are also limited to an angular


alignment of 3°. Coarse-grained materials, such as
sand, can have an angular deviation of as much as
45°. This is because the sound is reflected over a
larger angle by coarse-grained materials.

Blanking Out Objects

• An object may be located in the vicinity of the sound


Angular Alignment cone, which causes improper operation of the
sensor. These objects can be blanked out by using an
The angle of the target entering the sound cone must also be
aperture made of a sound-absorbing material such
considered. The maximum deviation from the send directly to
as rock wool. This narrows the sound cone and
a flat surface is ±3°.
prevents pulses from reaching the interfering object.
OPERATING MODES

Sonar sensors can be set up to operate in several different


modes: diffuse, reflex, and thru-beam.

Diffuse Mode

This is the standard mode of operation. Objects, traveling in


any direction into the operating range of the sound cone, will
cause the sensor output to switch states.

Reflex Mode

The reflex mode uses a reflector located in the preset


operating range. The operating range is adjusted for the
reflector. The pulses are bounced off the reflector, and the
echo pulses are returned to the sensor. When a target blocks
the echo pulses, the output is activated. Typically used in
applications where the target is not a good sound absorber.
ROBOTIC VISION SYSTEM

Without robotic vision, robots are blind machines that move


according to their programming. They rigidly follow the code
that dictates their functions, making them ideal for repetitive
tasks that could be physically draining and challenging to
people. Now that we are at the advent of Industry 4.0, robots
are also evolving. It will allow them to keep up with the
Thru-Beam Mode demands and trends of the fourth industrial revolution.

Thru-beam sensors consist of a transmitter, which emits Central to the evolution of robotics is the creation of a robot
ultrasonic pulses, and a receiver. If the beam between the vision system for collaborative robots (cobot). Machine or
transmitter and the receiver is interrupted the output of the robot vision is a key feature of this evolution, introducing new
receiver switches state. levels of precision and accuracy in smart automated
processes.

Vision systems help cobots perform tasks such as inspecting,


identifying, counting, measuring, or reading the barcode.
Ultra-high-speed imaging and lens quality facilitate multi-
operations in one process.

Machine learning is also being applied to robotics, teaching


collaborative robots to perform new tasks based on data
Environmental Influences
patterns. It gives vision robots sophisticated search and
• Sound travel time can be affected by the physical corrective movement skills, such as the elimination of
properties of the air. This, in turn, can affect the overlaps, distortions, or misalignments.
preset operating distance of the sensor. Vision systems, however, are also useful in non-robotic
functions. They can be placed in critical production floor
locations such as conveyor lines to aid with product quality APPLICATIONS
control reviews.

At present, most robot vision systems are used for materials


handling and removals.

Giving robots the ability to see is a game-changer. The ability


to perceive their immediate surroundings significantly
enhances cobot capability, which in turn benefits human
workers, companies, and industries at large.

In practice, introducing vision-guided robots or cobots with


robot AI vision into the manufacturing system makes sense if
Other applications:
they can be easily configured and operated by the staff or
operator, saving time and labor costs. Inspection of manufactured goods such as semiconductor
chips, automobiles, food, pharmaceuticals, and more . . .
By definition, robotic vision is a process of extracting,
characterizing, and interpreting information from images of a
3-dimensional world.

Adding a vision system to a robot gives a robot eyes. The


robot can now find objects in its working envelope, thus
reducing the need for complex and expensive fixtures. This Application in bottling company.
increases the flexibility of robotic automation, adapting to
variations in part size, shape, and location. This will ultimately
reduce cell complexity

Robotics and Computer Vision

Measurement: A camera measures multiple diameters of a


bottleneck

COUNTING: counting of holes in the aluminum flange

Machine Vision (MV) is applying different technologies and


methods to perform imaging-based automatic inspection and
analysis, process control, and robot guidance in industrial
applications COUNTING: Identifying the presence or absence of the part.
Machine vision or vision system is also used to report the the field, opening the door to many new
location and orientation of the parts. applications and innovations.

Difference between Computer Vision & Machine Vision

• Computer vision refers to the capture and


automation of image analysis with an emphasis on
the image analysis function across a wide range of
DECODING theoretical and practical applications.
- It is an identification application in which the vision system • Machine vision traditionally refers to the use of
reads various codes and alphanumeric characters (text and computer vision in an industrial or practical
numbers) and decodes the codes to get the product features. application or process where it is necessary to
It is used to record information as historical data, track execute a certain function or outcome based on the
products, validate data, verify the correctness of data and image analysis done by the vision system.
verify the product. • Machine vision (also called “industrial vision” or
“vision systems”) is primarily focused on computer
vision in the context of industrial manufacturing
processes, be it in the inspection process itself (e.g.,
checking a measurement or identifying a character
string is printed correctly) or through some other
responsive input needed for control (e.g., robot
control or type verification).
• The machine vision system can consist of several
cameras, all capturing, interpreting, and signaling
individually with a control system related to some
pre-determined tolerance or requirement.
• Latest-generation systems also make use of 3D
• Computer vision (CV) deals with image and video vision system technology, providing more options for
acquisition, processing, analyzing, and automated inspection.
understanding images to perform object detection • Machine vision has become a key technology in the
and tracking, feature detection, extraction, and area of manufacturing and quality control due to the
matching. increasing quality demands of manufacturers and
• Computer vision is built upon the fields of customers. Machine vision utilizes industrial image
mathematics, physics, biology, engineering, and of processing through the use of cameras mounted
course, computer science. over production lines and cells in order to visually
• There are many fields related to computer vision, inspect products, read or direct products and guide
such as machine learning, signal processing, robots in real time without operator intervention.
robotics, and artificial intelligence. • Machine Vision - The process of extracting
• Even though it is a field built on advanced concepts, information from visual sensors to enable machines
more and more tools are making it accessible to to make intelligent decisions.
everyone from hobbyists to vision engineers to Advantages of Machine Vision
academic researchers.
• It is an exciting time in this field, and there are an • Machine vision system works faster than manual
endless number of possibilities for applications. system.
• One of the things that makes it exciting is that these • Machine vision is consistent.
days, the hardware requirements are inexpensive • Perform beyond human vision
enough to allow more casual developers entry into • High repeatable in a controlled environment
• No fatigue – 24/7
• Reliable
• Good for unsafe and hazardous environment
• Operate well in space-constrained environments

Vision in space

Machine Vision/Vision System operates beyond human


vision. Mobile robots
Other Applications:

Optical character recognition (OCR)

How Does Robotic Vision Work?

Cobots “see” via one or more integrated cameras. At least one


robot vision camera will be mounted on the robotic arm itself,
literally serving as the eye of the machine. In some cases,
additional cameras are installed in strategic locations in the
Face detection cobot’s working cell. This setup allows the camera to have a
wider visual angle and capture as much visual data as it needs
to perform its function in collaboration with human workers.

Before the machine is deployed, it is first programmed and


taught to identify the objects with which it should interact. The
cobot’s camera will take 2D or 3D scans of the object. The
image will then be stored in the cobot’s database and
programmed to trigger the machine to move and perform
specific tasks. Once the programming is complete, the cobot
can finally be installed in the assembly line.

The Process

There are three segments in a robot vision system:


Smart cars
Image capture

The cameras capture footage of the objects that enter a


cobot’s workspace. If the set-up is halfway through the
assembly line, there is a good chance that conveyor systems
will deliver the products directly before the cobots. The Ensures product consistency
camera/s will start capturing visual data from a calculated
Human workers are capable of icing the cake, but it would be
distance. Afterward, the machine will analyze the images or
unrealistic to expect anyone to be consistently precise for six
footage and enhance it to produce a clear picture.
to eight hours straight. This is an example of repetitive tasks
Image processing for which robots are an excellent replacement. And with robot
vision, factories can be more flexible in these assembly lines
The picture will go through further processing and be analyzed
and take advantage of the visual recognition feature. They can
by pixel. The system will compare the colors and apparent
produce more if they allow cobots to react to the variables that
shape of the object with the image programmed in its
enter their fields of vision.
database.
Reliable
Connectivity and response
Vision-guided robots are more reliable than their non-seeing
Once the machine recognizes that the object in the picture
counterparts. They don’t function blindly, after all. If
matches the pre-programmed image, it will perform a something vastly different from the 2D or 3D images
corresponding action on the object before it. This entire
programmed in the system comes across their path, they can
process happens in quick succession within seconds.
be made to skip that object and move on to the ones that pass
this first level of quality control. In this respect, factories can
boost efficiency with the use of their raw materials or parts in
To put things into context: one good example of this process the assembly line.
would be a robot vision system for the icing and decorating line
of a cake factory. Two custom cobot arms are stationed on Promotes a safe workplace
either end of this assembly line: one spreads buttercream Traditional, automatic machines move at directions and
frosting on the entire cake, while the other pipes have complex
speeds per their programming. Put a human worker on its
icing designs on top. A conveyor belt brings in the cakes and
path, and it will still keep going, regardless of whether they get
gets them frosted first before conveying them to the
out of its path or not. Cobots with robot vision AI, on the other
decorating arm (meanwhile, the frosting arm gets started on
hand, have sensors that detect obstructions along their pre-
the next cake).
programmed paths and movements. They stop at once their
Both arms have cameras (eyes) that scan each cake that comes sensors register an object in the way instead of powering on at
before it. Every time the frosting arm registers an uniced cake, full speed. With vision-guided cobots, factories can reduce the
it releases its icing nozzle and scraper, which spreads the risk of on-site accidents significantly.
buttercream evenly on the top and sides of the cake. The same
Reduces operating costs
goes with the decorating arm: the sight of an iced cake, whose
frosting matches the image of the model cake programmed Cobots with robot vision systems constitute a major
into its system, would trigger the machine to create the investment. Although returns on any form of investment are
corresponding icing design. never guaranteed, enterprises can be sure of gains, such as
time and resources saved, higher production rates, better and
In this scenario, the cake factory can mass-produce cakes with
consistent product quality, and better-rested employees. In
impressive speed and precision. The cobots in this factory are time, the returns can manifest as lower operating costs and
clearly recipe-driven, which means the bakery can easily
increased sales.
change cake designs or even produce more than one cake style
from a single decorating line. Source: https://www.tm-robot.com/en/robot-vision-system/

The Advantages of Robot Vision AI

The above is a basic demonstration of how cobots enhanced


with vision systems can fit into an assembly line. The example
also gives us a clear idea of their benefits:

Increases efficiency

A robot vision camera can help take images for your own AI
model training, and the image data can be automatically
collected. The training module can then be used in factories
for robots to better identify various kinds of product defects.
C INTRODUCTION • A compiler, like GCC, to translate the C code into a
language that the computer will understand
As we discussed during our Day 1, C programming is the basis
o GCC is a key component of so-called "GNU
of Arduino programming and other languages. Before we
Toolchain", for developing applications and
proceed to the introduction of Arduino programming and for
writing operating systems. The GNU
you to be able to perform your next activity, it is better to
Toolchain includes: GNU Compiler Collection
review the basics of C Programming. Your next laboratory will
(GCC): a compiler suite that supports many
lead you to accomplish the activities related to Robot Grippers.
languages, such as C/C++ and Objective-
What is C? C/C++.
• There are many text editors and compilers to choose
• C is a general-purpose programming language from. In this tutorial, we will use an IDE Links to an
created by Dennis Ritchie at the Bell Laboratories in external site..
1972.
• It is a very popular language, despite being old. C Install IDE
• C is strongly associated with UNIX, as it was An IDE (Integrated Development Environment) is used to edit
developed to write the UNIX operating system. AND compile the code.
UNIX(UNiplexed Information Computing System) - A highly Popular IDEs include CodeBlocks, Eclipse, DEVC++, and Visual
popular and multitasking Operating system, launched in 1969, Studio. These are all free, and they can be used to both edit
UNIX is powerful. and debug C code.
Why Learn C? Note: Web-based IDE's can work as well, but functionality is
• It is one of the most popular programming languages limited.
in the world We will use DEVC++ in this course, which is a good place to
• If you know C, you will have no problem learning start.
other popular programming languages such as Java,
Python, C++, C#, etc, as the syntax is similar You can find the latest version of DEVc++ at
• C is very fast, compared to other programming https://sourceforge.net/projects/orwelldevcpp/.Links to an
languages, like Java and Python external site.
• C is very versatile; it can be used in both applications
After installation, you can see an environment as shown
and technologies
below:
Difference between C and C++

• C++ was developed as an extension of C, and both


languages have almost the same syntax
• The main difference between C and C++ is that C++
supports classes and objects, while C does not

Get Started

This tutorial will teach you the very basics of C.

It is not necessary to have any prior programming experience.

In order to learn more and get started with C Programming,


click Next. C Quickstart

Let's create our first C file.


C GET STARTED Open Dev-C++ and go to File > New > Project > Console
Application > C Project > Make default language.
Get Started With C
Write the following C code and save the file as
To start using C, you need two things:
myfirstprogram.c.
• A text editor, like Notepad, to write C code
sasa.JPG

Example explained

Don't worry if you don't understand the code above - we will


discuss it in detail in later chapters. For now, focus on how to
run the code. In Dev-C++, it should look like this: C OUTPUT

C Output (Print Text)

To output values or print text in C, you can use the printf()


function:

Screenshot (9665).png

Then, go to Execute > Compile and Run to run (execute) the


program. The result will look something to this:

Screenshot (9666).png

Congratulations! You have now written and executed your first


C program.

Click Next to learn and understand the C Syntax.

C SYNTAX

Syntax

You have already seen the following code a couple of times in


the first chapters. Let's break it down to understand it better:

Example:
C VARIABLES

Variables are containers for storing data values.

In C, there are different types of variables (defined with To output variables in C, you must get familiar with something
different keywords), for example: called "format specifiers".

• int - stores integers (whole numbers), without Format Specifiers


decimals, such as 123 or -123 Format specifiers are used together with the printf() function
• float - stores floating point numbers, with decimals, to tell the compiler what type of data the variable is storing. It
such as 19.99 or -19.99 is basically a placeholder for the variable value. A format
• char - stores single characters, such as 'a' or 'B'. Char specifier starts with a percentage sign % followed by a
values are surrounded by single quotes. character.
Declaring (Creating) Variables For example, to output the value of an int variable, you must
use the format specifier %d or %i surrounded by double
To create a variable, specify the type and assign it a value:
quotes, inside the print() function:

To print other types, use %c for char and %f for float.

Click Next to learn more about C Data Types.


Where type is one of C types (such as int), and variableName
is the name of the variable (such as x or myName). The equal
sign is used to assign a value to the variable.
C DATA TYPES
So, to create a variable that should store a number, look at the
following example: Data Types

As explained in the Variables chapter, a variable in C must be a


specified data type, and you must use a format specifier inside
Example: the printf() function to display it:
Create a variable called myNum of type int and assign the
value 15 to it:

You can also declare a variable without assigning the value,


and assign the value later:

Basic Data Types

The data type specifies the size and type of information the
variable will store.
Note: If you assign a new value to an existing variable, it will
overwrite the previous value:

Output Variables

You learned from the output chapter that you can output
values/print text with the printf() function:
Basic Format Specifiers What’s on board?

There are different format specifiers for each data type. Here • ATmega328 MCU
are some of them: • 22 x digital I/O pins (6 can be used as PWM outputs)
• 8 x Analogue inputs
• 16MHz crystal oscillator
• 1 x Mini-B USB
• Operating voltage: 5V
• FLASH memory: 32KB
• SRAM: 2KB
• EEPROM: 1KBDimensions: 45 x 18 mm

GETTING STARTED WITH ARDUINO

Arduino Hardware

• Arduino Uno/Mega/Nano or one of the Raspberry Pi


versions are some of the complete microcontrollers
you can explore to build your own Robot.
• Arduino can be used for low-level tasks, and
Raspberry Pi for high-level robotics applications.
• The Arduino family of controllers was developed in
2005 by the Interaction Design Institute Ivrea in Italy.
Hardware and software are open source, which
added to their success and the availability of low-cost
versions. The Nano controller has a small footprint Arduino Uno (R3). Arduino Uno is a microcontroller board
and is ideal for small projects as it only costs a few based on the ATmega328 (datasheet). It has 14 digital
dollars. Larger versions, such as the Arduino Uno and input/output pins (of which 6 can be used as PWM outputs), 6
Arduino Mega, can take add-on boards or shields, but analog inputs, a 16 MHz ceramic resonator, a USB connection,
for simple projects, the Nano is all we need. a power jack, an ICSP header, and a reset button. It contains
• Is Arduino Nano better than Uno/Mega? everything needed to support the microcontroller; simply
o If the project is simple with low cost and a connect it to a computer with a USB cable or power it with an
small profile, it is better to go with Nano, and AC-to-DC adapter or battery to get started. The Uno differs
it can be used in portable electronics and from all preceding boards in that it does not use the FTDI USB-
sensor gathering. If desktop prototyping is to-serial driver chip. Instead, it features the Atmega16U2
needed with ethernet shields, then Uno is (Atmega8U2 up to version R2) programmed as a USB-to-serial
the best choice, and they can also be used in converter.
IoT sensors.
• Microcontroller ATmega328P
• Below are the Arduino Boards: Nano, Uno, Mega,
• Operating voltage of 5V
Leonardo..etc
• Maximum supply voltage 6 to 20V
• Digital I/O pins 14 (of which 6 provide PWM output)
• DC current per I/O pin 40mA
• DC current for 3.3V pin 50mA
• Flash memory16KB, of which 2KB is used by a boot
loader
• SRAM 2KB, EEPROM 1KB
• Clock speed 16MHz
• Can be powered via the USB connection or with an
Arduino Nano. The Arduino Nano 3.0 is a compact board external power supply
featuring the ATmega328 microcontroller. It’s a complete,
bread-board friendly development board which measures just
45 x 18 mm.
Arduino Mega (R3). The Arduino Mega 2560 R3 microcontroller
is based on the ATmega2560. It features 54 digital Arduino Leonardo. The Leonardo is Arduino's first development
input/output pins (of which 15 can be used as PWM outputs), board to use one microcontroller with built-in USB. This means
16 analog inputs, 4 UARTs (hardware serial ports), a 16 MHz that it can be cheaper and simpler. Also, because the board
crystal oscillator, a USB connection, a power jack, an ICSP handles USB directly, code libraries are available, allowing the
header, and a reset button. It contains everything needed to board to emulate a computer keyboard, mouse, and more.
support the microcontroller; simply connect it to a computer
with a USB cable or power it with an AC-to-DC adapter or Getting Started with Arduino products:
battery to get started. The Mega 2560 board is compatible
The Arduino Software (IDE) allows you to write programs and
with most shields designed for the Uno and the former boards
upload them to your board. To work offline, you should use the
Duemilanove or Diecimila.
latest version of the desktop IDE Links to an external site..
• Microcontroller: ATmega2560
Install the Arduino Desktop IDE
• Operating Voltage: 5V
• Input Voltage (recommended): 7-9V To get step-by-step instructions, select one of the following
• Input Voltage (limit): 6-9V links accordingly to your operating system.
• Digital I/O Pins: 54 (of which 15 provide PWM output)
• WindowsLinks to an external site.
• Analog Input Pins: 16
• DC Current per I/O Pin: 20 mA
• Mac OSLinks to an external site.
• DC Current for 3.3V Pin: 50 mA
• Flash Memory: 256 KB of which 8 KB used by
• LinuxLinks to an external site.
bootloader
• SRAM: 8 KB
• Portable IDE Links to an external site. (Windows and
• EEPROM: 4 KB
Linux)
• Clock Speed: 16 MHz
The Arduino has a small built-in ROM memory and cannot be
• Length: 101.52 mm
extended. Powering up is simply by connecting its USB socket
• Width: 53.3 mm
to a power supply or a PC (see Figure 1). Upload and download
• Weight 37 g of programs and data can also be accomplished over the USB
link.

asgdetsdhfgr.JPG

Figure 1: Arduino Nano connected to a laptop PC


For writing a program for the Arduino and uploading it to the Program 2: Arduino Demo Program “Blink,” Modified from
controller, we will use the integrated development Arduino App
environment (IDE). When starting this on a Mac, Windows or
Linux PC, one is greeted by an empty program with two C
functions, setup and loop, as shown in Figure 2.

arduino.JPG

Figure 2. Arduino app with an empty program

As the first step, we need to set up the Arduino app to match


Function setup will run only once at program start (after our Uno or Nano controller. From the Tools menu, select as
power-up or after a push on the reset-button), while loop will board Arduino Nano and as processor ATmega328P for
from then on run in an infinite loop. So as a complete C Arduino Nano or select board Arduino Uno. Then under Port
program, the hidden main program actually looks like Program select the correct COM port or USB port of your PC to which
1: you connected the Uno or Nano. Now to get this program
running, click on the tick symbol in the top left of the Arduino
app to compile the program into machine code. If all goes well,
you get a green message saying “Done compiling” with some
Program1: Hidden Main Program of the Arduino
statistical data (see Figure 3).

save sa.JPG

The next step is clicking the right arrow symbol (also in the top
left of the app) to upload the program to the controller. The
upload should start, indicated by the text “Uploading …” in the
Arduino app and by rapid blinking of the Nano’s send and
The term while (1) or while (true) (when including stdbool.h) receive LEDs. Completion of the successful upload is then
denotes an infinite loop, which means that subroutine loop will acknowledged by the message in Figure 4.
be called endlessly over and over again until someone either
presses the reset button or disconnects power.

Arduino Programming

The Arduino app comes with a variety of example programs.


One of them is the blink program that lets us play with one of If you have selected the wrong communication port or there is
the built-in LEDs on top of the controller. In this demo, the any problem with the connection, you will get an error
function setup in Program 2 has only a single line, calling message. Some Arduino clones require additional drivers or an
system function pinMode with the address of the pin (here: update of the built-in bootloader. Some versions of the
LED_- BUILTIN) and the desired initialization value (here: Arduino app have the entry “… (Old Bootloader)” in the
OUTPUT). processor menu, which works for older hardware or firmware
versions on clones. After the successful upload, the user
The loop function in Program 2 turns the LED on – waits – turns program will start to run straight away. So in our case, the
the LED off – waits again, all in an infinite loop. System function blinking pattern will start and run and run and run—until we
digitalWrite with the address of the pin (again: LED_BUILTIN), disconnect power, press reset, or overwrite the program. The
and the desired output value (HIGH for 1 or LOW for 0) is used application program is now permanently stored in the Arduino
for actually turning the LED on or off. However, a delay Nano, so even after disconnecting and reconnecting power,
statement is required, so we can actually see any effect. If we the program will start again and display the blinking pattern.
were to omit the two delay statements, the LED would change
state from on to off and back so quickly that we would only see
a dim glow. By changing the delay times (specified in
milliseconds), we can achieve different blinking patterns.
Arduino Interfacing asgdterwcvsb.JPG

• Interfacing a controller with the outside world,


sensors, and actuators, as well as displays and input
Figure 7. Resistor ring colors
devices, is one of the central tasks of building an
embedded system. On the Arduino, input/output
lines are organized in ports of eight lines each, and
each line can work either as an input or an output. To write the software for this hardware setup, we can extend
This means that we need to initialize each I/O line the blink program as shown in Program 3. In the setup part, we
before we can use it. need to initialize both pins. Pin D12 should be an input, while
• Only some of the input/output ports of the Atmel CPU pin D10 should be an output. In the loop part, we continuously
are made available as pins on the Nano board; some read the status of the switch and then set the LED output
larger boards offer more I/O lines. The labels printed accordingly. There is no need for a delay in this program.
onto the Nano board, unfortunately, do not match
the port numbers of the Atmel CPU. Labels A0–A7 (‘A’
for analog) refer, in fact, straight to CPU ports C0–C7, Program 3. Reading from and Writing to External Ports
and labels D2–D13 (‘D’ for digital) are linked to
various port pins from port B and port D (see Figure
5, Arduino Nano). Try not to use pin D13, as it is
internally connected to the onboard LED.

fhdgtyrdes.JPG

Figure 5. Arduino Nano board pins and matching port


numbers

Example:
Arduino Communication
We start with a simple input of a binary switch. On the Nano
board, we select pin D12 (digital 12), which happens to be The USB port of the Arduino is not just for providing power and
linked to the controller’s port C0 (see Figure 6, left). While the uploading new programs. It can also be used for transmitting
switch is open, a pull-up resistor of 10 kOhms to the 3.3 V pin data to and from the embedded controller to a host PC. In a
brings the input to a high state (logic 1). Once the button is stand-alone application, we might want to add some LEDs or a
pushed, the D12 input gets directly linked to the ground, so the display to the Arduino to show data, but with a PC link, we can
pin registers a low state (logic 0). easily transmit data from the Arduino to the PC (or vice versa)
and display it in a window. This is especially helpful during the
asgdetwscb.JPG
debugging phase.

In Program 4, we added a line of code for initializing the serial


Figure 6. Arduino Nano with external input and output; transmission in setup and one line that transmits the switch’s
left schematics, right breadboard status back to the PC in loop.

Program 4: Transmitting Data to a PC

For the output, we choose pin D10 (digital 11) and connect it
to an LED, which links via a 300 X resistor on its negative side
to the ground. Figure 6, right, shows the actual
implementation on a breadboard. Resistor values are coded as
color rings, as their surface is too small to print any actual
values on. In the simplest case, resistors have four rings, which
stand for two digits, a multiplier, and a quality indicator (which
we can ignore for now). The digit colors are as in Figure 7.
In Program 5, we simplify the setup to remote control the LED
from the PC. The desired LED value now no longer comes from
the switch on the Arduino, but from data input on the PC. We
initialize the LED to off at the start in setup. In the main loop,
we first check if new data is available on the serial port; only
then do we read and process it. If the transmitted character is
an ‘A’, we turn on the LED, if it is a ‘Z’, we turn it off; all other
characters are ignored. Note that depending on how you
transmit the characters from your PC, there may be additional
stray characters, such as carriage return/line feed (CR/LF).

Program 5. Reading Data from a PC

For testing, we can now enter these characters from the Serial
Monitor in the Arduino app, but they could also come from any
other application or another embedded controller, such as
another Arduino or a Raspberry Pi.

EXPERIMENT #2: ARDUINO-BASED DISTANCE DETECTOR


WITH A BUZZER AND LED INDICATORS
B. Angular Gripper - Jaws are opened/closed around a central
pivot point (sweeping/arcing motion)

jaws need to move up and out of the way in limited space.

C. Toggle Gripper - The pivot of jaw movement acts as an over-


center toggle lock and provides a high grip force/weight ratio.

2. Based on the number of fingers

3. Internal or external

A. Internal - Part geometry allows locking as well. A


standard 2/ or 3-fingered gripper may be used.

B. External - Common, closing force assist gripping.

December 1, 2022

ROBOT GRIPPERS AND END EFFECTORS

Agenda:

• Definition and purpose of Gripperr


• Types of Grippers
• Gripper Drive
• Gripper Design Consideration
• Gripper Selection

GRIPPER - A gripper is a device that enables the holding of an


object to be manipulated. GRIPPER DRIVE

TYPES OF GRIPPERS • Pneumatic - Smaller units, quick assembly, high cycle


rate, easy maintenance.
The types of grippers can be classified as follows:
• Electric Motors - High accuracy and repeatability, less
• based on the primary motion of the gripper jaws. floor space, low cost, and easy maintenance.
• based on the number of fingers • Hydraulic - High strength and high speed. large robot,
• Internal or External takes floor space, mechanical simplicity, and is usually
used for heavy loads.
1. Based on the Primary Motion of the Gripper Jaws
Shown in Table 1 is the comparison of Gripper Drives in terms
A. Parallel Gripper - The jaw moves in a parallel motion in of accuracy, strength, speed, space, advantages,
relation to the gripper body. disadvantages, and common applications.

Accurate, simple, inexpensive, and widely used.


2. Robot for Pick and Place

FINGER DESIGN CONSIDERATION

• Custom fingers for each application.


• Careful consideration: Size, Grip force. Source: Robotics 2021, 10(3), 105;
• Encompassing (ex. v-groove ) or retention finger (3rd https://doi.org/10.3390/robotics10030105
finger) shape to increase stability reduces the
necessary grip force.
• Frictional force
• Sensors to be used: Hall effect, proximity, tactile
sensor, magnetic switches etc.
• Protective covers.

GENERAL DESIGN PRACTICES

COME PRACTICAL APPLICATIONS OF GRIPPERS

1. Fruit Harvesting Robot

What Exactly Is an IoT?

The internet of Things (IoT) is the network of physical


objects-devices, vehicles, buildings, and other items
embedded with electronics, software, sensors, and
network connectivity – that enables these objects to
collect and exchange data.

The term “Internet of Things” was coined by Kevin Ashton


in 1999.

Devices that collect and transmit data via the internet.


Source: Agronomy 2022, 12(6), 1336;
https://doi.org/10.3390/agronomy12061336
Internet of Things Potentials

Things Connected to the Internet

The Internet of Things is already here....


WHAT IS DATA

What is Data?

• What is data?
• What is information?
• Data Representation
• What is knowledge
• Data Types
• Dataset

DATA: It can be any unprocessed fact, value, text, sound, or


2.5 Billion Gigabytes (2.5 Exabytes) picture that is not being interpreted and analyzed. Data is the
most important part of all Data Analytics, Machine Learning,
and Artificial Intelligence.

Looking at these pieces of data:

-- 11071984

-- 106.16

-- CV12BT

-- 9450000

Data - the raw facts and figures.

Structure - How the data is presented. Are the numbers


A huge amount of Data is generated every day.... actually numbers, or should be read as text?

Context - An environment where our prior knowledge and


understanding can make sense of data.

Meaning - Data in the correct structure and placed within


context.

Knowledge - The application of information to a solution.

After people, Data is our Most Valuable Asset!


• Data can be presented in different ways. KNOWLEDGE: Combination of inferred information,
• Presenting data in different ways has its advantages experiences, learning, and insights. Results in awareness or
and disadvantages. concept building for an individual or organization.
• Thinking about the way the data is to be used and
who will be using it will help you choose the best way
to present the data.
The dataset in Machine Learning
DATA REPRESENTATION

Different Forms of Data

Numeric Data: If a feature represents a characteristic


measured in numbers, it is called a numeric feature.

Categorical Data: A categorical feature is an attribute that can


take on one of the limited, and usually fixed number of
possible values on the basis of some qualitative property. A
categorical feature is also called a nominal feature.

Ordinal Data: This denotes a nominal variable with categories


falling in an ordered list. Examples include clothing sizes such
as small, medium, and large, or a measurement of customer
satisfaction on a scale from “not at all happy” to “very happy”.

Properties of Data

Volume: Scale of Data. With the growing world population and


technology at exposure, huge amounts of data are being
generated each and every millisecond.

Variety: Different forms of data – healthcare, images, videos,


audio clippings.

Velocity: Rate of data streaming and generation.

Value: Meaningfulness of data in terms of information that


researchers can infer from it.

Veracity: Certainty and correctness in data we are working on.

INFORMATION: Data that has been interpreted and


manipulated and now has some meaningful inference for the
users.
DATA CAN BE STRUCTURED DATA OR UNSTRUCTURED DATA Data Science Workflow

There are numerous kinds of research about AI & Data Science


STRUCTURED DATA VS. UNSTRUCTURED DATA in Industry 4.0.

INDUSTRY 4.0

The Fourth Industrial Revolution, 4IR, FIRe, or Industry 4.0,


conceptualizes rapid change to technology, industries, and
societal patterns and processes in the 21st century due to
increasing interconnectivity and smart automation.

It originated when Germany launched a project under the


name “Industrie 4.0” to digitalize manufacturing at the
Hannover Messe in 2011.

DATA SCIENCE

What is Data Science?

We learned that after people, data is our most valuable asset,


so we need to find, extract, refine, and monetize...we called it
Data Mining.

Data Science

It is an interdisciplinary field of scientific methods, processes,


algorithms, and systems to extract knowledge or insights from
data in various forms, either structured or unstructured
Nine Pillars of Industry 4.0

• Autonomous Robots The fourth industrial revolution, commonly referred to as


• Simulation industry 4.0, is upon us. Unlike its historical predecessors,
• Cloud Computing industry 4.0 is not driven by steam or gas – it’s much more
• 3D Printing space-age than that. Industry 4.0 revolves around the infusion
• Augmented Reality of artificial intelligence (AI) in manufacturing. While the
• Big Data Analysis characteristics of the fourth revolution center around smart
• Internet of Things factories, technically, 11 pillars provide industry 4.0
• Cyber Security scaffolding, as shown below.
• System Integration

1. Autonomous Robots - With recent technological


advancements, robots are becoming more autonomous,
flexible, and cooperative, with the ability to tackle complex as
well as common, mundane tasks.

2. Simulation (Digital Twin) - It will enable advanced control


and optimization and early problem detection, hence
improving product quality and reducing set-up time and
downtime.

3. Cloud Computing - With the improvement of cloud


technologies, more machine and production data will be
deployed to the cloud, which will result in better service
delivery and provide visibility and optimization through the
entire supply chain.

4. 3D Printing - Additive manufacturing, such as 3D printing, FUTURE.....ROBOTS & SMARTER MACHINES


will be used to produce smaller batches of customized
products with lightweight or complex designs, prototypes,
legacy replacement parts, or high-value low, volume parts.

5. Augmented Reality - It can help us provide visual, real-time


information to the right person at the right place and at the
right time.

6. Big Data Analytics - Companies have started collecting and


analyzing large data sets with the intention of optimizing
production quality, savings energy, reducing production costs,
etc.

7. Internet of Things - A network of devices that have local


intelligence, which enables the communication between the WHAT IS ARTIFICIAL INTELLIGENCE
facility, machines, and finished, as well as unfinished products.
What is Artificial Intelligence?
8. Cyber Security - With the increased connectivity in
manufacturing, the risk of cyber threats and cyber attacks will • A branch of computer science dealing with the
also increase. simulation of intelligent behavior in
computers.”(Merriam-Webster)
9. System Integration - With Industry 4.0, companies, • A program that can sense, reason, act, and adapt.”
departments, functions, suppliers, and customers will become (Intel)
much more connected, and information and knowledge will be • “Colloquially, the term ‘artificial intelligence is
able to travel seamlessly through the entire supply chain. applied when a machine mimics ‘cognitive’ functions
that humans associate with other human minds, such
as ‘learning' and ‘problem-solving’.” (Wikipedia)
• “Artificial intelligence, commonly called AI or
machine intelligence, is the programmed reasoning
and thinking skills applied to machines to mimic
human or animal intelligence. [Source Links to an
external site.}
• “The science and engineering of making intelligent
machines, especially intelligent computer programs.”
-John McCarthy-
• Artificial Intelligence is an approach to make a
computer, a robot, or a product think how smart
humans think. AI is a study of how the human brain
thinks, learns, decides, and works when it tries to
solve problems. And finally, this study outputs
intelligent software systems. The aim of AI is to
improve computer functions that are related to
human knowledge, for example, reasoning, learning,
and problem-solving.

Intelligence is intangible. It is composed of

• Reasoning
• Learning
• Problem Solving
• Perception
• Linguistic Intelligence
HISTORY AND EVOLUTION OF ARTIFICIAL INTELLIGENCE

AI DOMAIN AND APPLICATIONS

Global Artificial Intelligence (AI), Market Size [1]

MARCELO ANG
OTHER APPLICATIONS

MEDICAL FIELD:

Vital Signs Evaluator and Blood Type Identification using Deep


Learning for Blood Donation
Computer-Based Blood Type Identification Using Image PHILCABE HOMEPAGE
Processing and Machine Learning Algorithm

HUMAN RESOURCES DEPARTMENT:

Prediction of Employee Attrition

FARMING

Python Based Defect Classification of Theobroma Cacao Bean


using Fine-Tuned Visual Geometry Group16Links to an
external site.
INTRODUCTION TO MACHINE LEARNING

Welcome to the introduction of Machine Learning! This week,


we introduce the core idea of teaching a computer to learn
concepts using data—without being explicitly programmed..

After completing this module, you will be able to:

Discuss and introduce machine learning (ML)

Present the steps to complete a machine learning project

Introduce the ML vocabularies

Differentiate the general types of ML

Present the ML pipelines

Discuss the performance metrics for analysis for machine


learning regression and classification.

WHAT IS MACHINE LEARNING

What is Machine Learning?

Two definitions of Machine Learning are offered. Arthur


Samuel(1959) described it as: "the field of study that gives
computers the ability to learn without being explicitly
programmed." This is an older, informal definition.

Tom Mitchell provides a more modern definition: "A


computer program is said to learn from experience E with
respect to some class of tasks T and performance measure P,
if its performance at tasks in T, as measured by P, improves
with experience E."

AQUACULTURE Example: playing checkers.

E = the experience of playing many games of checkers

Oreochromis niloticus Growth Performance Analysis Using T = the task of playing checkers.
Pixel Transformation and Pattern RecognitionLinks to an
P = the probability that the program will win the next game.
external site.
According to Intel, Machine Learning is the study of programs
Faster R-CNN based Fish Detector for Smart Aquaculture
that are not explicitly programmed but learn patterns as they
SystemLinks to an external site.
are exposed to more data over time.”
Water Quality Monitoring:
https://drive.google.com/file/d/1oRmsc-FH5kxj-
atAfFRc4mfrXfYO8AB2/view?usp=sharing Links to an external
site.

Website for Remote Monitoring:


http://intsda.mariferosales.com/?fbclid=IwAR2tfUFfE6Mlzs37
GmzoFYZLM8gLsNSfhU7aarVJBiFhUY7osfKvTe-WDVo
Figure 2. Data is used as input to the learning algorithm
during training to develop the intelligent model. This will help
in prediction to answer a specific question.

Figure 1. Artificial Intelligence and Machine Learning


(Machine Learning is a subset of Artificial Intelligence.

Researchers in the field of Artificial Intelligence (AI) has


Figure 3. The example data can be predicted as cancerous or
demonstrated significant technical progress over the years.
not.
Most of this progress is due to advances in the AI sub-field -
Machine Learning. Machine Learning Limitation
This is supported by this study: Suppose you want to determine if an image is a cat or a dog.

What features would you use?

• Tail
• Head
• Eyes
• Nose
Machine Learning - Using data to answer questions. • Mount
• Height (there are small breeds of dogs)
• Ears

This is where Deep Learning can come in.


Deep Learning Problems to Solve Using Machine Learning

• Machine learning that involves using very • Pattern Classification


complicated models called “deep neural networks”. • Clustering / Categorization
(Intel) • Function Approximation
• Models determine the best representation of • Prediction / Forecasting
original data; in classic machine learning, humans • Optimization
must do this. • Recommendation
• Anomaly Detection
• Control
• And more….

MACHINE LEARNING VOCABULARIES

MACHINE LEARNING VOCABULARIES

Target: predicted category or value of the data (column to


predict).

Features: properties of the data used for prediction (non-


target columns).

Classic Machine Learning has 2 steps, while Deep learning


has one step only.

• Step1: Determine Features


• Step 2: Feed them through model

Example: a single data point within the data (one


row).

Label: the target value for a single data point.


Supervised Learning Types:

• Regression: predicts continuous


valued output
• Classification: predicts a discrete-
valued output

SUPERVISED LEARNING OVERVIEW


GENERAL TYPES OF MACHINE LEARNING

The below illustration shows the general types of machine


learning, such as supervised, unsupervised, and
reinforcement learning. We will limit our discussion to the
first two types (supervised and unsupervised)

Supervised Learning: Regression (Numeric


Answer)

Supervised Learning

• Use labeled training data to infer model


• Data (observations, measurements, etc.) are labeled
with pre-defined classes.
• Like a “teacher” giving the classes (supervision).

Supervised Learning: Classification (Categorical


Answer)
Supervised Learning: Classification (Categorical
Answer)

MACHINE LEARNING PIPELINES

MACHINE LEARNING PIPELINES-2


The price of the house is approximately $120,000.00

What if our dataset looks like this after plotting? Can we


predict the correct price of the item? (Ex. Size of Land,
House, etc)

Application: Use to predict the price of a house


based on the size of the house.

If we have 2 points....we could create a straight line, and from


there we can predict the value or price of the house.
Can w use the previous model or not? Prepare Dataset:
Split for training and testing: 70% -
30% split, 75% - 25% split, or 80% - 20%

It is better to use another model like the one


below.

Training:

• Feed training data to the learning


algorithm:

Relationship of input x and output y:

MACHNE LEARNING PIPELINES f(x) ----> y


The dataset must be split into Training Dataset and Testing
• Build the model
Dataset.

Dataset is composed of:


Testing:
Input: X = {x1, x2, …, xn}
Test the model using the testing set and obtain
Output: Y = {y1, y2, …, yn} the predictions based on the trained model.

Dataset Contents:
Rows of Data
Data Features
[Data Labels]
PERFORMANCE METRICS is correct; that is, the true class should
Metrics for Analysis
be equal to the predicted class. This will
show if the model is confused or not
CLASSIFICATION:
during the prediction.
• Classification Accuracy
• Confusion Matrix
• Sensitivity, Specificity, Accuracy
• Receiver Operating Characteristics
(ROC) Curve
• Precision and Recall
• F-measure
• Support

For classification, the performance metrics of


the developed models can be determined using
a confusion matrix. The accuracy, specificity,
precision, recall, and F1-score can be
computed. TP is the number of true positive,
TN as true negative, FN as the number of false
negative, and FP as the number of false
positive. ACCURACY

CONFUSION MATRIX • Accuracy is calculated as the


number of all correct
• The confusion matrix shown in
predictions divided by the total
Figure 1 is used to evaluate the
quality of the classifier and shows number of the dataset. The best
the distribution of the classifications. accuracy is 1.0, whereas the
Using TP, TN, FN, and FP from the worst is 0.0. Refer to Equation
confusion matrix, accuracy can be 1 for the equation to compute
computed as shown in Equation 1. the Accuracy.

RECALL OR SENSITIVITY

• Recall or Sensitivity measures


the percentage of the actual
positive class that is correctly
predicted. It is the capture rate
and can be computed
Calculating a confusion matrix can give a using Equation 2.
better insight if the classification model
RECEIVER OPERATING CHARACTERISTIC
CURVE (ROC)

• The ROC curve shows the


performance of a classification
PRECISION model at all classification
thresholds.
• Precision measures the • This curve plots two parameters
percentage of the predicted such as the true positive rate (TPR)
positive class that is correct and and the false positive rate (FPR).
can be determined • The Area under Curve (AUC)
using Equation 3. ranges in value from 0 to 1. A
prediction that is 100% correct has
an AUC of 1.0.
• Figure 3 shows a sample ROC.
Since the AUC in this study is
equal to 0.99, it means that the
SPECIFICITY model has desirable performance.

• Specificity is concerned with


how correctly the actual
negative class is predicted. This
can be calculated
using Equation 4.

F1
SCORE

• F1 Score is the harmonic mean.


It is a nice metric because it
uses precision and recall, as
shown in Equation 5.
REGRESSION:
• Mean squared error (MSE)
• Mean absolute error (MAE)
• Root mean squared error (RMSE)
• Relative absolute error (RAE)
• Mean Absolute Percentage
Error(MAPE)
MEAN ABSOLUTE PERCENTAGE
ERROR (MAPE)
• The measure of error refers to the
identification discrepancy between • MAPE is the Mean Absolute
the actual value and the predicted Percentage Error and can be
value, such as the following MSE, computed using Equation 8.
MAE, MAPE, and RMSE. • Mean Absolute Percentage
Error (MAPE) is the mean of all
MEAN SQUARED ERROR (MSE) absolute percentage errors
between the predicted and
• MSE is the Mean Absolute
actual values.
Error and can be computed
using Equation 6.
• MSE is the average of the
squared error that is used as
the loss function for least
squares regression: It is the
sum, over all the data points, of ROOT MEAN SQUARE ERROR
the square of the difference
between the predicted and • RMSE is the Root-Mean-
actual target variables divided Square-Error and can be
by the number of data points. computed using Equation 9.
• RMSE is the standard deviation
of the errors which occur when
a prediction is made on a
dataset. This is the same as
MSE (Mean Squared Error), but
the root of the value is
MEAN ABSOLUTE ERROR considered while determining
the model's accura
• MAE refers to Mean Absolute
Error and can be computed
using Equation 7.
• MAE evaluates the absolute
distance of the observations
(the dataset entries) to the
predictions on a regression,
taking the average of the
overall observations.
Python can be used to handle big data
PYTHON FOR DATA SCIENCE •
and perform complex mathematics.
• Python can be used for rapid
INTRODUCTION TO PYTHON PROGRAMMING
prototyping or production-ready
software development.
AGENDA:
• Anaconda Tools WHY PYTHON?
o Spyder
1. Fastest Growing Programming Language
o JupyterLab
o Jupyter Notebook
• Google Colaboratory (colab)
• Visual Studio Code

ANACONDA

• Anaconda is a distribution of the Python


and R programming languages for
scientific computing, that aims to
simplify package management and
deployment.

PYTHON
2. Top Programming Languages 2021>
• Python is a popular programming Python dominates as the de facto
language. platform for new technologies
• It was created by Guido van Rossum,
and released in 1991.
• Python is an interpreted high-level
general-purpose programming language.
• Its language constructs as well as its
object-oriented approach aim to help
programmers write clear, logical code for
small and large-scale projects.
• Python can be used on a server to
create web applications.

It is used for:

• web development (server-side),


• software development,
• mathematics,
• system scripting.

What can Python do?


• Python can be used on a server to
create web applications.
• Python can be used alongside software 3. Key Python Packages for Data Science
to create workflows.
• Python can connect to database
systems. It can also read and modify
files.
• Powerful Python IDE with advanced
editing, interactive testing,
debugging, and introspection
features.

4. Python works on different platforms


(Windows, Mac, Linux, Raspberry Pi, etc).
5. Python has a simple syntax similar to the
English language.
6. Python has a syntax that allows developers
to write programs with fewer lines than some
other programming languages.
7. Python runs on an interpreter system,
meaning that code can be executed as soon as
it is written. This means that prototyping can be
SPYDER Environment:
very quick.
8. Python can be treated in a procedural way,
an object-oriented way or a functional way.

ANACONDA Environment

JUPYTERLAB

• JupyterLab is a next-generation web-


based user interface for Project
Jupyter.

SPYDER

• It refers
to Scientific Python Development En
viRonment
JUPYTERLAB ENVIRONMENT: JUPYTER NOTEBOOK ENVIRONMENT:

JUPYTER NOTEBOOK GOOGLE COLABORATORY (COLAB)


• It is a web-based, interactive
computing notebook environment.
What is Colab?
• Edit and run human-readable Colab, or "Colaboratory", allows you to write
documents while describing the data and execute Python in your browser, with
analysis
• Zero configuration required
• Access to GPUs free of charge
• Easy sharing

Whether you're a student, a data scientist, or


an AI researcher, Colab can make your work
easier.
Source: https://colab.research.google.com/#scrollTo=5
fCEDCU_qrC0 Links to an external site.

COLAB Environment
Go to Drive->New->More->Google
Colaboratory
Python Syntax
Execute Python Syntax
• As we learned in the previous page,
Python syntax can be executed by
writing directly in the Command Line:

>>> print("Hello, World!")


Hello, World!

• Or by creating a python file on the


server, using the .py file extension, and
running it in the Command Line:

C:\Users\Your Name>python myfile.py

Python Indentation
COLAB ENVIRONMENT:
• Indentation refers to the spaces at the
Sample New File: beginning of a code line.
• Whereas in other programming
languages the indentation in code is for
readability only, the indentation in
Python is very important.
• Python uses indentation to indicate a
block of code.

Example:

Python Getting Started if 5 > 2:


print("Five is greater than two!")
Python Install Python will give you an error if you skip the
indentation:
Many PCs and Macs will have python already
installed. Example

• To check if you have python installed Syntax Error:


on a Windows PC, search in the start bar
for Python or run the following on the
if 5 > 2:
Command Line (cmd.exe): print("Five is greater than two!")
People use Python for countless tasks,
C:\Users\Your Name>python --version including:
• To check if you have python installed on
• Automated reporting
a Linux or Mac, then on linux open the
command line or on Mac open the • Data analysis
Terminal and type: • Web scraping
• Predictive models and data visualization
python –version • App and web development
• Simulations • TensorFlow also helps with building neural
• Academic research networks. Although it is a library in Python
• Data manipulation for data science, Tensorflow was written in
C++. Once imported to your workspace, you
get the benefits of both languages: the
A Python library is a group of pre-built coded
simplicity of Python and the performance of
modules that help you complete common tasks
C++.
with fewer lines of code. Instead of coding from
scratch, you can load tools to help you with Other libraries can be read from this source
data visualization, analysis, cleaning, and link.Links to an external site.
machine learning.
Also, Check this for the syntax used in Python.
Here are some of the best libraries in Python
for data science. Jupyter_Notebook_CheatSheet.pdf
• Keras is an advanced programming interface
(API) that works for the Tensorflow library. Data Analysis and Visualization
You can use the Tensorflow backend to
build neural networks. It makes an incredible LIBRARIES to import:
stepping stone to begin using Tensorflow as
it simplifies the complex nature
• Matplotlib is a library that helps with data
PYTHON for DATA ANALYSIS
visualization and plotting. You can make pie
charts, line graphs, scatterplots, power Pandas is an open-source Python Library
spectra, histograms, scatterplots, and box providing high-performance data manipulation
plots using its modules. Additionally, you can and analysis tool using its powerful data
zoom into the charts and plan the data
structures. The name Pandas is derived from
graphics.
the word Panel Data – an Econometrics from
• NumPy is one of the first libraries that Multidimensional data
worked with data science. The name is source: https://www.tutorialspoint.com/python_pandas/python_panda
short for Numerical Python. You can use s_introduction.htm Links to an external site.
NumPy for mathematical and statistical
NumPy is a Python library used for working
functions using large n-arrays or
with arrays. It also has functions for working in
multidimensional matrices. It works well
domain of linear algebra, fourier transform, and
for high-level math, linear algebra,
matrices. NumPy was created in 2005 by Travis
number crunching, and numeric analysis.
Oliphant. It is an open source project and you
• Pandas is another library in Python for can use it freely.
data science derived from NumPy. Also source: https://www.w3schools.com/python/numpy/default.asp Links
known as the Python Data Analysis to an external site.
Library, Pandas can import spreadsheets
and process data. Pandas is useful for
data manipulation and analysis of large
sample sizes. The modules in Pandas
PYTHON for DATA VISUALIZATION
handle big data sources quickly, making Matplotlib is a comprehensive library for
it an excellent tool for data munging. creating static, animated, and interactive
• Pytorch is a deep learning framework from
visualizations in Python. Matplotlib makes easy
Facebook’s AI research group. Compared to things easy and hard things possible. It can
Keras, Pytorch has more speed and Create quality plots with just a few lines of
flexibility. However, it features a low-level code.
API that makes it less user-friendly. source: https://matplotlib.org/ Links to an external site.
Seaborn is a Python data visualization library
based on matplotlib. It provides a high-level
interface for drawing attractive and informative
statistical graphics
source: https://seaborn.pydata.org/Links to an external site.

Pandas Built in Data Visualization:


• Area - An area chart or area graph displays
graphically quantitative data. It is based on
the line chart. The area between axis and
line are commonly emphasized with colors,
textures and hatchings. Commonly one
compares two or more quantities with an
area chart • Histogram - A histogram is a plot
that lets you discover, and show, the
underlying frequency distribution
(shape) of a set of continuous data.
This allows the inspection of the data
for its underlying distribution (e.g.,
normal distribution), outliers,
skewness, etc.

• Bar Plots - A bar chart or bar graph is a


chart or graph that presents categorical
data with rectangular bars with heights
or lengths proportional to the values
that they represent. The bars can be
plotted vertically or horizontally. A
vertical bar chart is sometimes called a
line graph. • Line Plots - A line plot is a graph that
shows frequency of data along a number
line. It is best to use a line plot when the
data is time series. It is a quick, simple
way to organize data

• Scatter Plots - are used when you


want to show the relationship
between two variables. Scatter plots
are sometimes called correlation rectangle. A boxplot is a standardized
plots because they show how two way of displaying the distribution of
variables are correlated. data based on a five number
summary (“minimum”, first quartile
(Q1), median, third quartile (Q3), and
“maximum”). It can tell you about
your outliers and what their values
are. It can also tell you if your data is
symmetrical, how tightly your data is
grouped, and if and how your data is
skewed

• Hexagonal Bin Plots - Hexagonal


Binning is another way to manage
the problem of having to many
points that start to overlap.
Hexagonal binning plots density,
rather than points. Points are binned
into gridded hexagons and
distribution (the number of points
per hexagon) is displayed using either
the color or the area of the
hexagons. Useful for Bivariate Data,
alternative to scatterplot.

• Box Plots - It is a plot in which a


rectangle is drawn to represent the
second and third quartiles, usually
with a vertical line inside to indicate
the median value. The lower and
upper quartiles are shown as
horizontal lines either side of the
• Kernel Density Estimation plot well as financial analysis. plotly is an interactive
(KDE) - KDE is a technique that let’s visualization library
you create a smooth curve given a
set of data. This can be useful if you
want to visualize just the “shape” of
some data, as a kind of continuous
replacement for the discrete
histogram. It can also be used to
generate points that look like they
came from a certain dataset – this
behavior can power simple
simulations, where simulated objects
are modeled off of real data. OTHER PYTHON LIBRARIES TO
IMPORT:
PIL Python Imaging Library (abbreviated as PIL)
(in newer versions known as Pillow) is a free
library for the Python programming language
that adds support for opening, manipulating,
and saving many different image file formats. It
is available for Windows, Mac OS X and Linux
source: https://treehozz.com/what-is-pil-image-format Links to an
external site.

DATA CLEANING & DATA PREPROCESSING

Dataset to be used in the next Activities and


Demonstration.
Data.csv Download Data.csv
data_co2.csv Download data_co2.csv
Salary_Data.csv Download Salary_Data.csv

MACHINE LEARNING – REGRESSION

Geographical plotting is used for world map as MACHINE LEARNING - REGRESSION-2


well as states under a country. Mainly used by
Regression is a supervised learning technique
data analysts to check the agriculture exports
which helps in finding the correlation between
or to visualize such data.
variables and enables us to predict the
plotly is a Python library which is used to continuous output variable based on the one or
design graphs, especially interactive graphs. It more predictor variables. It is mainly used for
can plot various graphs and charts like prediction, forecasting, time series modeling,
histogram, barplot, boxplot, spreadplot and and determining the causal-effect relationship
many more. It is mainly used in data analysis as between variables
Regression analysis is a statistical method to highlighted type of regression. You may click
model the relationship between a dependent below source link to learn more about other
(target) and independent (predictor) variables types of regression
with one or more independent variables. More
specifically, Regression analysis helps us to ✓ Linear Regression (Simple and Multiple)
understand how the value of the dependent ✓ Polynomial Regression
variable is changing corresponding to an ✓ Support Vector Regression
independent variable when other independent ✓ Decision Tree Regression
variables are held fixed. It predicts ✓ Random Forest Regression
continuous/real values such as temperature, ✓ Ridge Regression
age, salary, price, etc ✓ Lasso Regression
Terminologies Related to the Regression LABORATORY 3: SIMPLE LINEAR REGRESSION
Analysis:
Dependent Variable: The main factor in
Regression analysis which we want to predict
or understand is called the dependent variable.
It is also called target variable.
Independent Variable: The factors which affect
the dependent variables or which are used to
predict the values of the dependent variables
are called independent variable, also called as a
predictor.
Outliers: Outlier is an observation which
contains either very low value or very high
value in comparison to other observed values.
An outlier may hamper the result, so it should
be avoided.
Multicollinearity: If the independent variables
are highly correlated with each other than
other variables, then such condition is called
Multicollinearity. It should not be present in the
dataset, because it creates problem while
ranking the most affecting variable.
Underfitting and Overfitting: If our algorithm
works well with the training dataset but not
well with test dataset, then such problem is
called Overfitting. And if our algorithm does
not perform well even with training dataset,
then such problem is called underfitting.
Some Types of Regression
There are various types of regressions which
are used in data science and machine learning.
Each type has its own importance on different
scenarios, but at the core, all the regression
methods analyze the effect of the independent
variable on dependent variables. Given below
below are just some types of regression models
but for this module, we will be focusing on the
LABORATORY 4:
MACHINE LEARNING
CLASSIFICATION
Jan 5, 2023

GENERAL TYPES OF
MACHINE LEARNING
The below illustration shows the general types
of machine learning, such as supervised,
unsupervised, and reinforcement learning. We
will limit our discussion to the first two types
(supervised and unsupervised)
Support vector machine

Figure1. General Types of Machine Learning


and Its Applications.

Supervised Learning

• Use labeled training data to infer


model
• Data (observations, measurements,
etc.) are labeled with pre-defined
classes.
• Like a “teacher” giving the classes
(supervision).

STUDY THIS LINK:

https://www.javatpoint.com/machine-
learning-support-vector-machine-algorithm

INTRO TO DEEP
Supervised Learning Types:
LEARNING
• Regression: predicts continuous Topic Outline
valued output • Deep Learning
• Classification: predicts a discrete- • Neural Networks
valued output o Layer
o Activation Function
o Training
• Artificial Neural Network
• Convolutional Neural Network
• Recurrent Neural Network
• ANN vs CNN vs RNN
• Fine Tuning a Neural Network
WHAT IS DEEP ARTIFICIAL NEURAL
NETWORK (ANN)
LEARNING
Deep learning is a subset of machine learning in
What Is An Artificial Neural
artificial intelligence that has networks capable Network?
of learning unsupervised from data that is
unstructured or unlabeled. Also known as deep An artificial neural network is a computing
neural learning or deep neural network system that is comprised of a collection of
connected units called neurons that are
Deep learning is a sub-field of machine learning organized into what we call layers.
that uses algorithms inspired by the structure
and function of the brain's neural networks. The connected neural units form the so-called
network. Each connection between neurons
With deep learning, we're still talking about transmits a signal from one neuron to the other.
algorithms that learn from data. However, now The receiving neuron processes the signal and
the algorithms or models that do this learning signals to downstream neurons connected to it
are based loosely on the structure and function within the network. Note that neurons are also
of the brain's neural networks. commonly referred to as nodes.
The neural networks that we use in deep Nodes are organized into what we call layers.
learning aren't actual biological neural networks At the highest level, there are three types of
though. They simply share some characteristics layers in every ANN:
with biological neural networks, and for this
reason, we call them artificial neural networks 1. Input layer
(ANNs) 2. Hidden layers
3. Output layer
We often also use other terms to refer to
ANNs. In the field of deep learning, the Different layers perform different kinds of
term artificial neural network (ANN) is used transformations on their inputs. Data flows
interchangeably with the following: through the network starting at the input layer
and moving through the hidden layers until the
• net output layer is reached. This is known as a
• neural net forward pass through the network. Layers
• model positioned between the input and output layers
are known as hidden layers.
WHAT IS NEURAL Let's consider the number of nodes contained
NETWORK in each type of layer:
1. Input layer - One node for each component of
Neural networks reflect the behavior of the input data.
the human brain, allowing computer 2. Hidden layers - Arbitrarily chosen number of
programs to recognize patterns and nodes for each hidden layer.
solve common problems in the fields of 3. Output layer - One node for each of the possible
AI, machine learning, and deep learning. desired outputs.

Now that we have a general idea of the


definition and structure of an ANN, let's have a
look at how these ideas can be illustrated
Layers, Activation Functions
and Training Neural Network

Layers in Neural Network


We'll be working to better understand the layers
within an artificial neural network. We'll also see how
to add layers to a sequential model in Keras.

Previously, we saw how the neurons in an ANN are


organized into layers. The examples we looked at
showed the use of dense layers, which are also known
as fully connected layers. There are, however, We can see that the first layer, the input layer,
different types of layers. Some examples include: consists of eight nodes. Each of the eight nodes in
this layer represents an individual feature from a
• Dense (or fully connected) layers
given sample in our dataset.
• Convolutional layers
• Pooling layers This tells us that a single sample from our dataset
• Recurrent layers consists of eight dimensions. When we choose a
• Normalization layers
sample from our dataset and pass this sample to the
model, each of the eight values contained in the
Why Have Different Types Of sample will be provided to a corresponding node in
the input layer.
Layers?
We can see that each of the eight input nodes are
Different layers perform different transformations connected to every node in the next layer.
on their inputs, and some layers are better suited for
some tasks than others. Each connection between the first and second layers
transfers the output from the previous node to the
For example, a convolutional layer is usually used input of the receiving node (left to right). The two
in models that are doing work with image data. layers in the middle that have six nodes each are
Recurrent layers are used in models that are doing hidden layers simply because they are positioned
work with time series data, and fully connected between the input and output layers.
layers, as the name suggests, fully connects each
input to each output within its layer. Layer Weights
For now, we will keep our focus on layers in Each connection between two nodes has an
general, and we'll learn more in depth about specific associated weight, which is just a number.
layer types as we descend deeper into deep learning.
Each weight represents the strength of the
Example Artificial Neural connection between the two nodes. When the
network receives an input at a given node in the
Network input layer, this input is passed to the next node via
a connection, and the input will be multiplied by the
Let's consider the following example ANN: weight assigned to that connection.
For each node in the second layer, a weighted sum
is then computed with each of the incoming
connections. This sum is then passed to an
activation function, which performs some type of
transformation on the given sum. For example, an
activation function may transform the sum to be a
number between zero and one. The actual
transformation will vary depending on which
node output = activation(weighted sum of
activation function is used.
inputs)
node output = activation(weighted sum of
inputs) The activation function does some type of
operation to transform the sum to a number that is
often times between some lower limit and some
Forward Pass or forward Propagation upper limit. This transformation is often a non-
Through A Neural Network linear transformation. Keep this in mind because
this will come up again by the time this post
Once we obtain the output for a given node, the reaches its conclusion.
obtained output is the value that is passed as input to
the nodes in the next layer. What Do Activation Functions
This process continues until the output layer is
reached. The number of nodes in the output layer
Do?
depends on the number of possible output or
prediction classes we have. In our example, we have
What's up with this activation function
four possible prediction classes. transformation? What's the intuition? To explain
this, let's first look at some example activation
Suppose our model was tasked with classifying four functions.
types of animals. Each node in the output layer would
represent one of four possibilities. For example, we Sigmoid Activation Function
could have cat, dog, llama or lizard. The categories or
classes depend on how many classes are in our Sigmoid takes in an input and does the following:
dataset.
• For most negative inputs, sigmoid will
For a given sample from the dataset, the entire
transform the input to a number very close
process from input layer to output layer is called a
forward pass through the network. to 0.
• For most positive inputs, sigmoid will
Finding The Optimal Weights transform the input into a number very
close to 1.
As the model learns, the weights at all connections are • For inputs relatively close to 0, sigmoid will
updated and optimized so that the input data point transform the input into some number
maps to the correct output prediction class. This gives between 0 and
us a general introductory understanding about how
layers are working inside ANNs. Mathematically, we write

Activation Function in
Neural Network
In an artificial neural network, an activation
function is a function that maps a node's
inputs to its corresponding output

This makes sense given the illustration in the


discussion on layers. We took the weighted sum of
each incoming connection for each node in the layer,
and passed that weighted sum to an activation
function.
Convolutional Neural Network (CNN/ConvNet) is a class of
a neural network we think about matrix multiplications but t
mathematics convolution is a mathematical operation on tw
by the other. The role of the ConvNet is to reduce the image
good prediction.

RECURRENT NEURAL
NETWORK (RNN)
Recurrent Neural Network (RNN) is a Deep
learning algorithm and it is a type of Artificial Neural
Network architecture that is specialized for
processing sequential data. RNNs are mostly used in
the field of Natural Language Processing (NLP)
So, for sigmoid, 0 is the lower limit, and 1 is the upper
limit.

Alright, we now understand mathematically what one ANN vs CNN vs RNN


of these activation functions does, but what's the
intuition? Artificial Neural Network (ANN), is a group of
multiple perceptrons or neurons at each layer.
Activation Function Intuition ANN is also known as a Feed-Forward Neural
Well, an activation function is biologically inspired by network because inputs are processed only in
activity in our brains where different neurons fire (or the forward direction.
are activated) by different stimuli. This type of neural networks are one of the
simplest variants of neural networks. They pass
information in one direction, through various
Relu Activation Function input nodes, until it makes it to the output
node. The network may or may not have
Now, it's not always the case that our activation
hidden node layers, making their functioning
function is going to do a transformation on an input to
be between 0 and 1.
more interpretable.
In fact, one of the most widely used activation
Advantages:
functions today called ReLU doesn't do this. ReLU,
which is short for rectified linear unit, transforms the • Storing information on the entire network.
input to the maximum of either 0 or the input itself. • Ability to work with incomplete knowledge.
relu(x) = max(0,x) • Having fault tolerance.
• Having a distributed memory.

So if the input is less than or equal to 0, then relu will Disadvantages:


output 0. If the input is greater than 0, relu will then
just output the given input. • Hardware dependence.
• Unexplained behavior of the network.
The idea here is, the more positive the neuron is, the • Determination of proper network structure.
more activated it is. Now, we've only talked about two
activation functions here, sigmoid and relu, but there Convolutional neural networks (CNN) are one
are other types of activation functions that do
of the most popular models used today. This
different types of transformations to their inputs.
neural network computational model uses a
variation of multilayer perceptrons and contains
CONVOLUTIONAL NEURAL one or more convolutional layers that can be
NETWORK (CNN) either entirely connected or pooled. These
convolutional layers create feature maps that
record a region of image which is ultimately
broken into rectangles and sent out for
nonlinear processing.
Advantages:
• Very High accuracy in image recognition
problems.
• Automatically detects the important features
without any human supervision.
• Weight sharing.

ANN CNN RNN


Disadvantages: Tabular
Sequence
• Type of Data Data, Text Image Data
CNN do not encode the position and orientation data
Data
of object.
Parameter
• Lack of ability to be spatially invariant to the Sharing
No Yes Yes
input data.
Fixed Length
• Lots of training data is required. Yes Yes No
input
Recurrent
Recurrent neural networks (RNN) are more Connections
No No Yes
complex. They save the output of processing
Vanishing and
nodes and feed the result back into the model Exploding Yes Yes Yes
(they did not pass the information in one Gradient
direction only). This is how the model is said to Spatial
No Yes No
learn to predict the outcome of a layer. Each Relationship
node in the RNN model acts as a memory cell, ANN is CNN is RNN includes
continuing the computation and considered considered less feature
implementation of operations. If the network’s to be less to be more compatibility
Performance
powerful powerful when
prediction is incorrect, then the system self-
than CNN, than ANN, compared to
learns and continues working towards the RNN. RNN. CNN.
correct prediction during backpropagation. Facial
Facial recognition,
Advantages:
recognition text Text-to-
• An RNN remembers each and every information Application and digitization speech
Computer and Natural conversions.
through time. It is useful in time series vision. language
prediction only because of the feature to processing.
remember previous inputs as well. This is called High
Having fault Remembers
Long Short Term Memory. accuracy in
tolerance, each and
• Recurrent neural network are even used with image
Main Ability to every
convolutional layers to extend the effective recognition
advantages work with information,
problems,
pixel neighborhood. incomplete Time series
Weight
knowledge. prediction.
sharing.
Disadvantages:
Hardware Large
Gradient
• Gradient vanishing and exploding problems. dependence, training
vanishing,
Disadvantages Unexplained data
• Training an RNN is a very difficult task. exploding
behavior of needed,
• It cannot process very long sequences if using gradient.
the network. don’t
tanh or relu as an activation function.
encode the For example, we have to choose how many layers
position we're using, what types of layers we're using, what
and order to put the layers in, how many nodes to include
orientation in each layer, decide how much regularization to use,
of object. what to set our learning rate as, etc.

• Number of layers
• Types of layers
• Order of layers
• Number of nodes in each layer
• How much regularization to use
• Learning rate

FINE-TUNING NEURAL Building and validating our model can be a huge task
in its own right, depending on what data we're training
NETOWRKS it on.

This is what makes the fine-tuning approach so

Introducing Fine-Tuning attractive. If we can find a trained model that already


does one task well, and that task is similar to ours in at
least some remote way, then we can take advantage
and Transfer Learning of everything the model has already learned and apply
it to our specific task.
Fine-tuning is very closely linked with the
term transfer learning. Transfer learning occurs when Now, of course, if the two tasks are different, then
we use knowledge that was gained from solving one there will be some information that the model has
problem and apply it to a new but related problem. learned that may not apply to our new task, or there
may be new information that the model needs to learn
from the data regarding the new task that wasn't
Transfer learning occurs when we use learned from the previous task.
knowledge that was gained from solving one
For example, a model trained on cars is not going to
problem and apply it to a new but related have ever seen a truck bed, so this feature is
problem. something new the model would have to learn about.
However, think about everything our model for
recognizing trucks could use from the model that was
For example, knowledge gained from learning to originally trained on cars.
recognize cars could be applied in a problem of This already trained model has learned to understand
recognizing trucks. edges and shapes and textures and more objectively,
Fine-tuning is a way of applying or utilizing transfer head lights, door handles, windshields, tires, etc. All of
learning. Specifically, fine-tuning is a process that these learned features are definitely things we could
takes a model that has already been trained for one benefit from in our new model for classifying trucks.
given task and then tunes or tweaks the model to
make it perform a second similar task. How to Fine-Tune?
Why Use Fine-Tuning? If we have a model that has already been trained to
recognize cars and we want to fine-tune this model to
Assuming the original task is similar to the new task, recognize trucks, we can first import our original
using an artificial neural network that has already been model that was used on the cars problem.
designed and trained allows us to take advantage of For simplicity purposes, let's say we remove the last
what the model has already learned without having to layer of this model. The last layer would have
develop it from scratch. previously been classifying whether an image was a
When building a model from scratch, we usually must car or not. After removing this, we want to add a new
try many approaches through trial-and-error. layer back that's purpose is to classify whether an
image is a truck or not.
In some problems, we may want to remove more than compensate for any disturbances that add
just the last single layer, and we may want to add to the controller’s driving signal.
more than just one layer. This will depend on how • They do not correct for disturbances and
similar the task is for each of the models. are simply commanded by the input.
• The control action is independent of the
Layers at the end of our model may have learned output.
features that are very specific to the original task,
where as layers at the start of the model usually learn
more general features like edges, shapes, and textures. PARTS
After we've modified the structure of the existing • INPUT – sometimes called the reference.
model, we then want to freeze the layers in our new It is the stimulus, excitation, or command
model that came from the original model. applied to a control system, typically from
an external source, usually in order to
Freezing Weights produce a specified response from the
control system.
By freezing, we mean that we don't want the weights • INPUT TRANSDUCERS – a subsystem
for these layers to update whenever we train the which converts the form of the input to
model on our new data for our new task. We want to that used by the controller.
keep all of these weights the same as they were after • CONTROLLER – drives the process or a
being trained on the original task. We only want the plant.
weights in our new or modified layers to be updating • PLANTS - It may be a piece of equipment,
After we do this, all that's left is just to train the model perhaps just a set of machine functioning
on our new data. Again, during this training process, together, the purpose of which is to
the weights from all the layers we kept from our perform a particular operation. It is a
original model will stay the same, and only the weights system to be controlled.
in our new layers will be updating • DISTURBANCES - A signal that tends to
adversely affect the value of the output of
Jan 26, 2023 a system.
• SUMMING JUNCTIONS – yield the
algebraic sum of their input signals using
5.1 SYSTEMS associated signs.
CONFIGURATIONS • OUTPUT – sometimes called as the
controlled variable. It is the actual
response obtained from the control
OPEN-LOOP SYSTEMS system. It may or may not be equal to the
specified response implied by the input.
A generic open-loop system is shown in Figure 1.6(a).
TWO OUTSTANDING FEATURES
1. Their ability to perform accurately is
FIGURE 1.6(a). Open-Loop System Block Diagram determined by their calibration. To
calibrate means to establish or reestablish
OPEN-LOOP SYSTEMS the input-output relation to obtain a
desired system accuracy.
• Systems in which the output has no effect 2. They are not usually troubled with
on the control action. problems of instability.
• In an open-loop control system, the
output is neither measured nor fed back EXAMPLE OF OPEN-LOOP CONTROL
for comparison with the input.
• Any control system that operates on a
SYSTEM
time basis.
• The output is not compared with the • Most automatic toasters are open-loop
reference input. systems because they are controlled by a
• The distinguishing characteristic of an timer. The time required to make “good
open-loop system is that it cannot toast” must be estimated by the user, who
is not part of the system. Control over the
quality of toast (the output) is removed control action may be performed as some
once the time, which is both the input and function of the output and input.
the control action, has been set. The time
is typically set by means of a calibrated Characteristics of Feedback
dial or switch.
1. Increased accuracy.

CLOSED-LOOP SYSTEMS 2. Tendency toward oscillation or instability.

3. Reduced sensitivity of the ratio of output to input


The disadvantages of open-loop systems, namely to variations in system parameters and other
sensitivity to disturbances and inability to correct for characteristics.
these disturbances, may be overcome in closed-loop
systems. The generic architecture of a closed-loop 4. Reduced effects of nonlinearities.
system is shown in Figure 1.6(b).
5. Reduced effects of external disturbances or noise.

6. Increased bandwidth. The bandwidth of the system


is a frequency response measure of how well the
FIGURE 1.6(b). Closed-Loop System Block Diagram system responds to (or filters) variations (or
frequencies) in the input signal.
CLOSED-LOOP SYSTEMS
EXAMPLE OF CLOSED-LOOP
• A system that maintains a prescribed CONTROL SYSTEM
relationship between the output and the
reference input by comparing them and An autopilot mechanism and the airplane it controls is
using the difference as a means of control. a closed-loop (feedback) control system. Its purpose is
to maintain a specified airplane heading, despite
PARTS atmospheric changes. It performs this task by
continuously measuring the actual airplane heading,
and automatically adjusting the airplane control
• The control action is somehow dependent
surfaces (rudder, ailerons, etc.) as to bring the actual
on the output. It is commonly called
airplane heading into correspondence with the
feedback control system.
specified heading. The human pilot or operator who
• OUTPUT TRANSDUCER OR SENSOR
presets the autopilot is not part of the control system.
– measures the output response and
converts it into the form used by the
controller. COMPUTER-CONTROLLED SYSTEMS
• FEEDBACK PATH – The return path from
the output to the summing junction.
• ACTUATING SIGNAL – The result of the
subtraction of the output signal from the • In this system the controller or the
input signal at the summing junction. Also compensator is a digital computer.
called as ERROR in systems where both
the input and output transducers ADVANTAGES
have unity gain, in which the actuating
signal’s value is equal to the actual • Many loops can be controlled or
difference between the input and the compensated by the same computer
output. through time sharing.
• Any adjustments made to yield a desired
FEEDBACK response can be made by changes in
software rather that hardware.
• It is the property of a closed loop system • Computer can also perform supervisory
which permits the output (or some other function.
controlled variable) to be compared with
the input to the system (or an input to
some other internally situated component
or subsystem) so that the appropriate
EXAMPLES OF CONTROL SYSTEMS 5.2 INTRODUCTION TO
ROBOT CONTROL SYSTEM
Electric Switch
• An electric switch is a manufactured Introduction to Robotic
control system, controlling the flow of
electricity. By definition, the apparatus or Control Systems
person flipping the switch is not a part of
this control system. Robotics is an interdisciplinary area of study
• The input to this system is the flipping of between engineering and computer science.
the switch On or Off. The key aim of robotics is to produce,
• The output is the flow or nonflow of
computer-programmable machines, that can do
electricity.
tasks with more speed and precision. The
application of robotics is countless in the
Thermostatically Controlled Heater or current era, for example transporting heavy
Furnace things (in logistic management), automated
manufacturing, self-driving cars, unmanned
• A thermostatically controlled heater or aerial vehicles, and many more.
furnace automatically regulating the
temperature of a room or enclosure is a It is necessary for every beginner to understand
control system. the concept of Control Systems to get started
• The input to this system is a reference
temperature, usually specified by
with robotics. Control systems help to control
appropriately setting a thermostat. the movements and functions of the robot. To
• The output is the actual temperature of understand the control system first we need to
the room or enclosure. understand some terminologies used in
• When the thermostat detects that the robotics.
output is less than the input, the furnace
provides heat until the temperature of the
enclosure becomes equal to the reference
input. Then the furnace is automatically
turned off.
• When the temperature falls somewhat
below the reference temperature, the
furnace is turned on again.

Temperature Control System

Feedback Control System

James Watt’s Speed Control System • State- output produced by a robotic


system is known as a state. Normally
we denote it by x, the state depends
on its previous states, stimulus
Robot Using A Pattern-recognition (signals) applied to the actuators, and
the physics of the environment. The
state can be anything pose, speed,
velocity, angular velocity, force and
etc.
• Estimate- Robots cannot determine
the exact state x, but they
can estimate it using the sensors
attached to them. These estimations consider them before you design the
are denoted with y. It is the control system equations
responsibility of the robotic engineer
to select good enough sensors or to Note: A robot can have one or more controllers
calibrate the sensors well, such that for various purposes. For example one
they can produce y ~ x. controller for cruise control and another
• Reference- the goal state we wish to controller for controlling the linear motion of
achieve, it is denoted using r. the robot hand, and one for rotation movement
• Error- the difference between of the hand and etc.
the reference and estimate is known
as an error. We need the controllers because the dynamics
• Control Signal- the stimulus (system plant) vary with time. Such as when the
produces/output by the controller is robot moves up in a slope and then down in the
known as the control signal, it is slope, or first travels on smooth concrete, then
denoted using u. on a carpeted floor. So the best way to design a
• Dynamics- it is also called the system controller is by understanding the physics of
plant/system model, it denotes how the environment well. It will help to list out the
the system will behave under non- elements that needed to be considered in
static conditions. Dynamics are controller design.
affected by the environment that Before I conclude let us see the desired
may change or are not always linear. characteristics of controllers. We have already
For example, floor type seen the first requirement,
(concrete/wood), air drag, slope and
etc. 1. The controller should reduce the
error closer to zero, e~0, It should
It is always the key responsibility of the bring the estimation to the
engineer to build a controller, that reacts and reference, y~r
produces control signal u, such that e~0 & x~r. 2. They need to be robust, they should
Let me give you an example of the above- not depend on things we don’t know.
discussed key terms. Assume you are building a If there are any changes in the
self-driving robot. You should have a cruise robot’s environment it should be able
controller for your robot. Here, to adapt to it.
3. They must be stable, meaning they
• The speed(x) of your robot is the should not go out of control.
state 4. They need to be smooth in their
• Estimated current speed(y) from a movements.
preferred sensor (for example wheel 5. The controller needs to
encoder) be responsive. It should be fast
• the speed you wish to achieve is the enough to get the output to the
reference (r) reference level, within a satisfactory
• error is simply the difference time.
between the r & y
• The voltage produced by your In summary, we give a reference state to a
controller to increase or decrease the controller. The controller also has sensor
speed is your control signal (u) feedback, using the reference state, and the
• Environmental characteristics like sensor feedback controller generates the
friction & air drag may affect the control signal needed to reach the reference
dynamics of the system. You should state. This control signal is fed to the “System”.
The system dynamics determine how the
system behaves to this control input. If the
controller is good, hopefully, the “System” will
reach our desired reference state.

5.3 DIFFERENCE BETWEEN OPEN


LOOP AND CLOSED LOOP SYSTEM

5.4 APPLICATIONS OF NON-


SERVO AND SERVO ROBOT
https://towardsdatascience.com/introduct
ion-to-robotic-control-systems-
9ec17c8ac24f
Feb 9, 2023

Feb 16, 2023

You might also like