Robot Programming Techniques Explained
Robot Programming Techniques Explained
A robot program can be defined as a path in space to be followed by the manipulator, combined
with peripheral actions that support the work cycle. A robot can perform complex tasks under
the control of stored programs, which can be modified at will.
To program a robot, specific commands are entered into the robot’s controller memory,
and this action may be performed in a number of ways.
For limited sequence robots programming occurs when limit switches and mechanical
stops are set to control the endpoints of its motions.
A sequencing device controls the occurrence of the motions, which in turn controls the
movement of the joints that completes the motion cycle.
For practical applications in industry, there are two categories of robot programming:
Online programming
Offline programming
The teach pendant is the interface between the operator / programmer and the robot,
and the robot is manually driven to the required positions and paths in turn to create
the program. A teach pendant is a device which you plug directly into the robot.
Using its interface, you move the robot to the desired positions and record each
movement.
To program the robot, the operator moves it from point-to-point, using the buttons on
the pendant to move it around and save each position individually.
When the whole program has been learned, the robot can play back the points at full
speed.
Most traditional industrial robots come with a teach pendant, which makes them
familiar to technicians.
They allow precise positioning, as the robot can be programmed using numerical
coordinates in world coordinates, robot coordinates, or another coordinate system.
Teach pendants are great for simple movements, such as painting in a straight line or
over a large flat surface.
Disruptive to the whole system due to robot downtime. The robot must be put into
"teach mode" and all operations using the robot halted until it has been programmed.
Requires training to learn and program.
Might be difficult for skilled craftspeople who are unfamiliar with programming.
It requires the operator to move the robot arm through the desired motion path during a
teach procedure, thereby entering the program into the controller memory for subsequent
playback.
Task is ‘taught’ to the robot by manually moving the manipulator through the
required motion cycle, and simultaneously entering the program into the controller
memory for playback.
There are two methods of performing the lead through teach procedure
Quicker than traditional teach pendants. It removes the need for multiple button
pressing, allowing the operator to simply move the robot to the desired position.
More intuitive than both traditional teach pendants and offline programming as the task
is programmed in almost the same way a human operator would perform it. This makes
it simple for operators to learn.
Very good for detailed tasks which would require many lines of code to achieve the
same effect, such as path following and error handling (failed picks for example).
As with a traditional teach pendant, this method uses the physical robot for
programming. This means that it does not reduce downtime, as much as offline
programming.
Moving the robot to precise coordinates is not as straightforward as with the other
methods. This is especially true with some joystick-based systems, where there is no
way of entering a numerical value.
Some systems combine these features by allowing for the entering of exact numerical
coordinates along with positioning-based coordinates.
Not so good for tasks which are "algorithmic" in nature. For example, if a robot had to
paint a flat surface by moving horizontally along the surface, then move down an inch,
move horizontally in the opposite direction, etc. Moving the robot by hand would be
arduous and inaccurate for such a task.
Offline Programming
This involves creating the robot code without (necessarily) having the robot present. When the
program is ready, you then download it onto the robot and debug it. As a result, the robot can
continue to do productive work while you create the program.
1. Text-based programming
You write the program offline in a text editor then download it to the robot when it
is ready.
If you use the manufacturer’s programming language, it is likely that you can access
more of the robot’s functionality using this method. However, it has a disadvantage
that it requires a lot more debugging than other programming methods.
This involves programming the robot as if you were moving the real robot, but really
you are moving a simulation of it.
When you have finished and debugged the program, you can load it onto the robot.
If the software is good, this method combines the best of both lead-through and
teach pendant programming, with the added advantages of being an offline method.
Advantages of Offline Programming
Reduces downtime required for robot programming. Programs are developed offline, so
the robot only must be halted while the new program is being downloaded and tested.
Offline programming with simulation can be available to visualize the final motion in a
virtual work environment.
Can be quite intuitive, especially if the robot can be moved around in a 3D CAD
environment with drag and drop techniques.
Easy to test many different approaches to the same problem, this would be inefficient
for online programming methods
Virtual models will never be able to represent the real world with 100% accuracy.
Programs may still need to be altered after they are applied to the real robot.
Might take longer overall
World modeling is the process used by a robot to determine the position of other objects in its world.
Communication between the robots has enabled cooperative world modeling to be used to determine
team strategy.
b. Path generation
Path generation is a fundamental task for a mobile robot by which it moves in an environment avoiding
obstacles, defects in the floor and generating a safe path. The path generation problem is as old as
mobile robots and is a fundamental problem to the adaptation of artificial intelligence technology
to robotics.
c. Sensing
Robotic sensing mainly gives robots the ability to see, touch, hear and move and uses algorithms that
require environmental feedback.
Sensing enable force control, equipping the robot to place and fit objects precisely.
The force sensing capabilities in advanced force/torque and proximity sensors help to find the right
orientation of the object using the right amount of force.
d. Programming support
To perform a particular action, robots are programmed either by guiding or by off-line programming. Most of
the industrial robots are programmed by guiding a robot from point to point through the phases of an
operation, with each point stored in the robotic control system.
The development environment is a set of processes and tools that are used to develop a source
code or program.
Integrated Development Environment (IDE) is the software development tool used to write,
build, test and debug a program.
They also provide developers with a common user interface (UI) to develop and debug in
different modes.
Thus, we need to have the required software setup, i.e., installation on our PC which will be
used to write computer programs, compile, and execute them.
examples
AVR Studio
AVR Studio is an Integrated Development Environment (IDE) for writing and debugging
AVR applications in Windows 9x/ME/NT/2000/XP/VISTA environments.
AVR Studio provides a project management tool, source file editor, simulator,
assembler and front-end for C/C++, programming, emulation and on-chip debugging.
AVR Studio supports the complete range of ATMEL AVR tools and each release will
always contain the latest updates for both the tools and support of new AVR devices.
AVR Studio 4 has a modular architecture which allows even more interaction with 3rd
party software vendors.
Atmel Studio
Is the integrated development platform for developing and debugging all AVR® and
SAM microcontroller applications
The Atmel Studio 7 IDP gives you a seamless and easy-to-use environment to write,
build and debug your applications written in C/C++ or assembly code.
It also connects seamlessly to the debuggers, programmers and development kits that
support AVR and SAM devices
You will need the following setup to start with programming using any programming language.
Text Editor
A text editor is software that is used to write computer programs. Your Windows machine must have a
Notepad, which can be used to type programs.
You can use this software to type your computer program and save it in a file at any location. You can
download and install other good editors like Notepad++, which is freely available.
Compiler
You write your computer program using your favorite programming language and save it in a text file
called the program file.
The computer cannot understand your program directly given in the text format, so we need to convert
this program in a binary format, which can be understood by the computer.
The conversion from text program to binary file is done by software called Compiler and this process of
conversion from text formatted program to binary format file is called program compilation.
Finally, you can execute binary file to perform the programmed task.
The following flow diagram gives an illustration of the process −
So, if you are going to write your program in any such language, which needs compilation like C, C++,
Java and Pascal, etc., then you will need to install their compilers before you start programming.
Interpreter
We just discussed about compilers and the compilation process. Compilers are required in case you are
going to write your program in a programming language that needs to be compiled into binary format
before its execution.
There are other programming languages such as Python, PHP, and Perl, which do not need any
compilation into binary format, rather an interpreter can be used to read such programs line by line
and execute them directly without any further conversion.
So, to write your programs in PHP, Python, Perl, Ruby, etc., you will need to install their interpreters
before you start programming.
Online Compilation
If you are not able to set up any editor, compiler, or interpreter on your machine,
then [Link] provides a facility to compile and run almost all the programs online with an
ease of a single click.
Programming Activities
Computer programming is the process of designing and building an executable computer program to
accomplish a specific computing result or to perform a specific task.
Analysis,
Generating algorithms,
Profiling algorithms' accuracy
resource consumption
The implementation of algorithms in a chosen programming language (commonly referred to
as coding)
Robotic Programming:
To perform a particular action, robots are programmed either by guiding or by off-line programming.
Most of the industrial robots are programmed by guiding a robot from point to point through the
phases of an operation, with each point stored in the robotic control system.
Different Types of Robot Programming Languages
Robotic software plays a key role in performing complex operations and accurate
functionalities.
To start programming in robotics, you must start learning various types of languages to make
a robot work.
There are over 1500 programming languages in the world, which are used to learn and
implement. Here are the top and most popular programming languages in robotics:
1) C/C++
Choosing to learn C and C++ is the best start for aspiring roboticists as it is a general
purpose programming language that contains imperative, object-oriented and generic
programming features.
C++ allows interaction with low level hardware, and also real time performance.
C and C++ are very mature programming languages.
To ensure the best performance of a robot, it will be better to use C++.
As the robotics is very dependent on the real time performance, C and C++ are the best
options to the roboticists.
2) Python
Python is the high-level programming language and it plays a key role in building and testing robots.
Python is a good platform to automate, teach, and post-process robot programs.
Many people choose this programming language as we can write script that calculates, records, and
simulates an entire robot program instead of manually teaching every statement to a robot. This
helps to quickly test and visualize solution in simulation as well as refine the program and its logic.
• When compared to C, C++ and Java, you can write fewer lines of code in Python.
• Learning python is an essential guide to create an autonomous mobile robot using popular
robotic software frameworks.
• This language is used in designing embedded system and it is an integral part of Robot operating
system.
• The major focus of Python is ease of use and less time is required to program such as defining,
and casting variable types.
• When you are required to implement some basic functionality, there are a huge number of free
libraries for it, which means you do not have to ‘reinvent the wheel’.
3) Java
To perform human-like tasks, robotics systems must be included with functions via
programming languages.
To enable robots with these functions, Java language can be used as it offers an array of
APIs that are tailor-made to the needs of the robotics realm.
Command-and-control recognizers, dictation systems, and speech synthesizers can be built
using the Java Speech API and the Java Media Framework can be used to receive and
process visual images.
Java contains all the high-level features needed in robotics industry especially when it comes
to artificial intelligence.
Using Java, you can create highly efficient algorithms for machine learning, search and
neural algorithms, language processing etc.
The Java Virtual Machine interprets the instructions at run-time
Java enables users to use the same code on many different machines, thanks to the Java
Virtual Machine.
It provides all the high level features needed to deal with various aspects of robotics.
4) C#/.NET
5) MATLAB
Technically speaking, MATLAB is not a programming language but it is a tool with which you
can find engineering solutions based on mathematics.
Robotic developers need to learn MATLAB if they want to analyze data, produce advanced
graphs or implement control systems.
MATLAB, and its open source relatives, such as Octave, is very popular with some robotic
engineers for analyzing data and developing control systems.
Wave
Wave was the first high-level language created for programming a robot.
Standford Artificial Laboratory developed it in 1973.
AL
AML is the programming language used for the control of robots produced by
IBM.
AML is intended to provide a complete interpreted computer language along
with all of the programming support typically associated with high-level
programming languages.
APT
Karel, Karel 2, and Karel 3 are robot control languages used by some FANUC
robot controllers.
CAP 1
MML was a model-based mobile robot language that was developed at the
University of California.
It is a high-level offline programming language, which contains functions for
high-level sensor functions, geometric model description and path planning, and
others.
This language contains an important concept of slow and fast functions, which
architecture is essential for real-time control of robots.
A slow function is executed sequentially, while a fast function is executed
immediately.
The second important concept is the separation of the reference and current
posture, which makes precise and smooth motion control and dynamic posture
correction possible.
RIPL
The VAL language is the most advanced commercial language designed for use with
Unimation, Inc. industrial robots.
VAL stands for Victor’s Assembly Language. It is basically an offline language in which the
program defining the motion sequence can be developed off line, but the various point
locations used in the work cycle are most conveniently defined by leadthrough.
To demonstrate the VAL language, let us assume that the robot must pick up objects from a
chute and place them in successive boxes. One possible sequence of robot activity is as
follows:
1. Move to a location above the part in the chute.
2. Move to the part.
3. Close the gripper jaws.
4. Remove the part from the chute.
5. Carry the part to a location above the box.
6. Put the part into the box.
7. Open the gripper jaws.
8. Withdraw from the box.
The corresponding VAL program is as follows:
EDIT DEMO. 1
PROGRAM DEMO. 1
1. ? APPRO PART, 50 @
2. ? MOVES PART @
3. ? CLOSE I @
4. ? DEPARTS 150@
5. ? APPROS BOX, 200@
6. ? MOVE BOX@
7. ? OPENI @
8. ? DEPART@
The exact meaning of each line is:
Most articulated robots perform by storing a series of positions in memory, and moving
to them at various times in their programming. For example, a robot that is moving items from
one place to another might have a simple program like this:
Move to P1
Move to P2
Move to P3
Close gripper
Move to P4
Move to P5
Open gripper
Move to P1 and finish
For a given robot, the only parameters necessary to locate the end effector (gripper,
welding torch, etc.) of the robot completely are the angles of each of the joints. However, there
are many different ways to define the points for the robot to move to, some of which can be
much more efficient, depending on the task to be accomplished.
Why robots
The three important capabilities of robots that make them useful for applications are:
Transport
Manipulation
Sensing
Transport
Manufacturing Applications
Transport goods
Pick and place
Palletizing
Space Industry
Intelligent wheelchairs
Robot arms used to manipulate and handle patients
EXAMPLES
Arduino
is an open-source hardware and software company, project and user community that
designs and manufactures single-board microcontrollers and microcontroller kits for building
digital devices.
Arduino board designs use a variety of microprocessors and controllers.
The boards are equipped with sets of digital and analog input/output (I/O) pins that may be
interfaced to various expansion boards ('shields') or breadboards (for prototyping) and other
circuits. The boards feature serial communications interfaces, including Universal Serial
Bus (USB) on some models, which are also used for loading programs from personal
computers.
The microcontrollers can be programmed using the C and C++ programming languages,
using a standard API which is also known as the "Arduino language".
The Arduino project provides an integrated development environment (IDE)
Sketch:
Comments
Everything between the /* and */ is ignored by the Arduino when it runs the sketch. There's
another style for short, single-line comments. These start with // and continue to the end of
the line.
Variables
A variable is a place for storing a piece of data. It has a name, a type, and a value. There's more
information in the Variables tutorial.
Functions
A function (procedure or sub-routine) is a named piece of code that can be used from elsewhere in a
sketch. You can call a function that's already been defined (either in your sketch or as part of the
Arduino language).
There are two special functions that are a part of every Arduino sketch:
setup()
loop().
The setup () is called once, when the sketch starts.
It's a good place to do setup tasks like setting pin modes or initializing libraries.
The loop () function is called over and over and is heart of most sketches. You need to include both
functions in your sketch, even if you don't need them for anything.
Microcontrollers (Arduino)
Digital Pins
The pins on the Arduino can be configured as either inputs or outputs.
Arduino (Atmega) pins default to inputs, so they don't need to be explicitly declared as inputs
with pinMode().
Analog Input Pins
The Atmega controllers used for the Arduino contain an onboard 6 channel analog-to-digital
(A/D) converter.
While the main function of the analog pins for most Arduino users is to read analog sensors,
the analog pins also have all the functionality of general purpose input/ output (GPIO) pins
(the same as digital pins 0 – 13). The analog pins can be used identically to the digital pins,
using the aliases A0 (for analog input 0), A1, etc.
PWM
Pulse Width Modulation, or PWM, is a technique for getting analog results with digital means.
Digital control is used to create a square wave, a signal switched between on and off.
Memory
There are three pools of memory in the microcontroller used on Arduino boards (ATmega168):
Flash memory (program space), is where the Arduino sketch is stored.
SRAM (static random access memory) is where the sketch creates and manipulates variables
when it runs.
EEPROM is memory space that programmers can use to store long- term information.
Blink example
1. – Test Arduino
To build the circuit, attach a 220-ohm resistor to pin 13.
Then attach the long leg of an LED (the positive leg, called the anode) to the resistor.
Attach the short leg (the negative leg, called the cathode) to ground.
Then plug your Arduino board into your computer.
In the program below, the first thing you do is to initialize pin 13 as an output pin with the line
pinMode(13, OUTPUT);
In the main loop, you turn the LED on with the line: digitalWrite(13, HIGH);
This supplies 5 volts to pin 13. That creates a voltage difference across the pins of the LED, and lights it
up. Then you turn it off with the line:
digitalWrite(13, LOW);
void setup() {
pinMode(LED_PIN, OUTPUT); // Configure pin 13 to be a digital
output.
}
void loop() {
digitalWrite(LED_PIN, HIGH); // Turn on the LED.
delay(1000); // Wait 1 second (1000 milliseconds).
digitalWrite(LED_PIN, LOW); // Turn off the LED.
delay(1000); // Wait 1 second.
}
2. – Potentiometer
Using a potentiometer, you will be able to control the resistance of
an LED. Turning the knob will increase and decrease the frequency
the LED blinks.
Parts Needed
(1) Arduino Uno
(1) USB A-to-B Cable
(1) Breadboard – Half Size
(1) LED 5mm
(1) 220 Ω Resistor
(1) Potentiometer (10k Trimpot)
(6) Jumper Wires
Project Diagram
The circuit:
* Potentiometer attached to analog input 0
* Center pin of the potentiometer to the analog pin
* One side pin (either one) to ground
* The other side pin to +5V
* LED anode (long leg) attached to digital output 13
* LED cathode (short leg) attached to ground
Project Code
1. Connect the Arduino board to your computer using the USB
cable.
2. Open project code
/*
Analog Input
Demonstrates analog input by reading an analog sensor on analog pin 0 and
turning on and off a light emitting diode(LED) connected to digital pin 13.
The amount of time the LED will be on and off depends on
the value obtained by analogRead().
* Note: because most Arduinos have a built-in LED attached to pin 13 on the board, the LED is
optional.
*/
int sensorPin = A0; // select the input pin for the potentiometer
int ledPin = 13; // select the pin for the LED
int sensorValue = 0; // variable to store the value coming from the sensor
void setup() {
// declare the ledPin as an OUTPUT:
pinMode(ledPin, OUTPUT);
}
void loop() {
// read the value from the sensor:
sensorValue = analogRead(sensorPin);
// turn the ledPin on
digitalWrite(ledPin, HIGH);
// stop the program for <sensorValue> milliseconds:
delay(sensorValue);
// turn the ledPin off:
digitalWrite(ledPin, LOW);
// stop the program for for <sensorValue> milliseconds:
delay(sensorValue);
}
3. Select the board and serial port as outlined in earlier section.
4. Click upload button to send sketch to the Arduino.
3. – Photoresistor
A photoresistor changes the resistance a circuit gets based on the
amount of light that hits the sensor. In this project, the brightness
of the LED will increase and decrease based on the amount of light
present.
Parts Needed
(1) Arduino Uno
(1) USB A-to-B Cable
(1) Breadboard – Half Size
(1) LED 5mm
(1) 330 Ω Resistor
(1) 10K Ω Resistor
(1) Photoresistor
(6) Jumper Wires
Project Diagram
Project Code
1. Connect the Arduino board to your computer using the USB
cable.
2. Open project code
/******************************************************************
* SparkFun Inventor's Kit
* Example sketch 06
*
* PHOTO RESISTOR
*
* Use a photoresistor (light sensor) to control the brightness
* of a LED.
*
* This sketch was written by SparkFun Electronics,
* with lots of help from the Arduino community.
* This code is completely free for any use.
* Visit [Link] for SIK information.
* Visit [Link] to learn about the Arduino.
*
* Version 2.0 6/2012 MDG
* Version 2.1 9/2014 BCH
/*****************************************************************/
// We'll also set up some global variables for the light level:
int lightLevel;
int calibratedlightLevel; // used to store the scaled / calibrated
lightLevel
int maxThreshold = 0; // used for setting the "max" light level
int minThreshold = 1023; // used for setting the "min" light level
void setup()
{
pinMode(ledPin, OUTPUT); // Set up the LED pin to be an output.
[Link](9600);
}
void loop()
{
lightLevel = analogRead(sensorPin); // reads the voltage on the
sensorPin
[Link](lightLevel);
//autoRange(); // autoRanges the min / max values you see in your
room.
void autoRange()
{
if (lightLevel < minThreshold) // minThreshold was initialized to 1023
-- so, if it's less, reset the threshold level.
minThreshold = lightLevel;
// Once we have the highest and lowest values, we can stick them
// directly into the map() function.
//
// This function must run a few times to get a good range of bright
and dark values in order to work.
Parts Needed
(1) Arduino Uno
(1) USB A-to-B Cable
(1) Breadboard – Half Size
(1) Temperature Sensor – TMP36
(5) Jumper Wires
Project Diagram
Project Code
1. Connect the Arduino board to your computer using the USB
cable.
2. Open project code
/******************************************************************
SparkFun Inventor's Kit
Example sketch 07 - TEMPERATURE SENSOR
Even more exciting, we'll start using the Arduino's serial port
to send data back to your main computer! Up until now, we've
been limited to using simple LEDs for output. We'll see that
the Arduino can also easily output all kinds of text and data.
This sketch was written by SparkFun Electronics,
with lots of help from the Arduino community.
This code is completely free for any use.
Visit [Link] for SIK information.
Visit [Link] to learn about the Arduino.
void setup()
{
[Link](9600); //Initialize serial port & set baud rate to 9600 bits per
second (bps)
}
void loop()
{
//Now print to the Serial monitor. Remember the baud must be 9600 on your
monitor!
// These statements will print lines of data like this:
// "voltage: 0.73 deg C: 22.75 deg F: 72.96"
[Link]("voltage: ");
[Link](voltage);
[Link](" deg C: ");
[Link](degreesC);
[Link](" deg F: ");
[Link](degreesF);
5. – Servo
In this project, you will be able to sweep a servo back and forth
through its full range of motion.
Parts Needed
(1) Arduino Uno
(1) USB A-to-B Cable
(1) Breadboard – Half Size
(1) Servo
(6) Jumper Wires
Project Diagram
Project Code
1. Connect the Arduino board to your computer using the USB
cable.
2. Open project code
/*
SparkFun Inventor's Kit
Example sketch 08-1
SINGLE SERVO
Sweep a servo back and forth through its full range of motion.
void setup()
{
void loop()
{
int position;
Parts Needed
(1) Arduino Uno
(1) USB A-to-B Cable
(1) Breadboard – Half Size
(1) LCD Screen
(1) Potentiometer
(16) Jumper Wires
Project Diagram
Project Code
1. Connect the Arduino board to your computer using the USB
cable.
2. Open project code
/*
SparkFun Inventor's Kit
Example sketch 15
This sketch will show you how to connect an LCD to your Arduino
and display any data you wish.
#include <LiquidCrystal.h>
void setup()
{
void loop()
{