Professional Documents
Culture Documents
Hour 1
Overview Session
What is a Robot ?
• From Wikipedia
• A robot is a mechanical or virtual artificial agent, usually an electro-
mechanical machine that is guided by a computer program or electronic
circuitry.
• Robots can be autonomous or semi-autonomous and range from
humanoids such as Honda's Advanced Step in Innovative Mobility (ASIMO)
and TOSY's TOSY Ping Pong Playing Robot (TOPIO) to industrial robots,
collectively programmed swarm robots, and even microscopic nano robots.
• By mimicking a lifelike appearance or automating movements, a robot may
convey a sense of intelligence or thought of its own.
What is a Robot ?
• From The Oxford English Dictionary
• A machine capable of carrying out a complex series of actions
automatically, especially one programmable by a computer:
What is a Robot
What is a Robot – The Future ?
• What do you think a robot is ?
• Could a robot replace your teacher ?
Using Robotics To Learn Programming
• At Barclays we have found that using small robots teaches
programming in a way that helps everyone understand the basics
• We will be using these robots from 4tronix
• 3 different challenges
• Programming at the end of the session - create your own robot zoog
on the screen
Icebreaker
• Ever wanted to be an app ? Now is your chance
Introducing the Robot
• How the Robot works
• How to upload code
• How to change code
Introducing the Robot – The IDE
• Where you write code
• Save your sketch – the
app
Introducing the Robot – The Sketch
void loop()
• The sketch is the app {
Move Challenge 1
Barclays Mobile Robotics
Hour 3
Shape Challenge 2
Barclays Mobile Robotics
Hour 4
If ( leftObstacleSensor() == true )
{
//Execute this block of code within the curly brackets
halt(0);
reverse(0,255);
}
Active Sensor - Ultrasonic
Passive Sensor - Motion
• Motion Sensors can detect movement – they look for IR / Heat
Passive Sensor – Light/IR
• Light Sensor can detect Light – Or Infra Red. Used a lot in Robotics for
position and distance calculation
Laser Range Finders
• Laser Range Finders send out a laser beam. The beam bounces off its
target and the light comes back and the sensors can measure the time
difference.
• This is a very accurate measurement. Expensive to buy
Barclays Mobile Robotics
Hour 5
If ( leftObstacleSensor() == true )
{
//Execute this block of code within the curly brackets
halt(0);
reverse(0,255);
}
Passive Sensor – Light/IR
• Light Sensor can detect Light – Or Infra Red. Used a lot in Robotics for
position and distance calculation
Barclays Mobile Robotics
Hour 6
• X Direction
The Screen Grid 0
1
• Y Direction
2
3
4
5
6
7
The Screen Grid 0 1 2 3 4 5
1
• Coordinate
• (X,Y)
2
• 5,4 3
4
The Screen Grid 0 1 2 3 4 5 6 7
1
• Coordinate
• (X,Y)
2 ?
• (6,3) 3 ?
• ????
4 ?
5
6
7
The Screen Grid 1280
• Coordinate System of
Screen could be 1280
x 1024
• (X,Y)
• (600,700)
1024
• ????
Software – Lets Code
• Open Processing on Laptop
• Get to first Screen
• This is an IDE
• This is where you will write code
• Called a Sketch
• Save the Sketch
• Open an Example
Software – Lets Code
• Example – Open the Bounce
Sketch and have a look and run
Software – Lets Code
• Have a look at the code – can you
see how to make the ball get
smaller or bigger ?
• Faster or slower ?
• Have a look and see what you
think – use the stop button and
restart when you have made a
change in the code
Software – Lets Code
• Software programs are procedural
• Real Life Demo! You are Sketch!
• See how programs are procedures – one instruction then another
• In a Loop
Software – Lets Code
• Lets look at writing a few lines of
code – create a new sketch and
type these lines
• size(500,500);
• ellipse(100,100,50,50);
• Now run
Software – Lets Code
• Syntax is important – this sets the size of the window
size(500,500);
Software – Lets Code
• Syntax is important – draw a circle
ellipse(100,100,50,50);
Software – Lets Code
• We can change colour and size of
lines.
• Colour can be set by the fill
command
• size(300,300);
• fill(0);
• ellipse(100,100,40,50);
• fill(255);
• ellipse(140,140,40,50);
Software – Lets Code
• Some commands can set the colour
• fill
• If you use single number 0 is black
and 255 is white
• If you use a triplet with RGB Red
Green Blue
• 255,0,0 is red
• fill(255,0,0);
• ellipse(100,100,20,20);
• Draws an circle that is red
Software – Lets Code
• We can change colour and size of
lines.
• Colour can be set by the fill
command
• size(300,300);
• fill(0,255,0);
• ellipse(100,100,40,50);
• fill(255,0,255,0);
• ellipse(140,140,40,50);
Software – Lets Code
• Different commands
• line(x1,y1,x2,y2);
• stroke(34); ( Line Colour)
• strokeWeight(3);
• rect(x1,y1,l,w);
• background(255);
• Use these to make something!
• http://processing.org/tutorials/
// zoog
// Eyes
size(200,200); fill(0);
background(255); ellipse(81,70,16,32);
smooth(); ellipse(119,70,16,32);
ellipseMode(CENTER);
rectMode(CENTER); // Legs
stroke(0);
// Body line(90,150,80,160);
stroke(0); line(110,150,120,160);
fill(150);
rect(100,100,20,100);
Software – Lets Code
• Lets look ad Sketch Structure so
we can build more advanced
sketches
void setup()
{
}
void draw()
{
}
Software – Lets Code
void setup() {
// Set the size of the window
size(200,200);
Type the first part into }
a new sketch // draw() loops continuously until you close the sketch
window.
Save it! void draw() {
// Draw a white background
background(255);
void draw() {
background(255);
stroke(0);
fill(175);
rectMode(CENTER);
rect(mouseX,mouseY,50,50);
}
Software – Lets Code
• Go back to zoog sketch and see if you
can use mouseX and mouseY to move
bits of zoog around
• Hint – you can write mouse+10 like
• ellipse(mouseX+10,mouseY,100,100);
Software – Lets Code
• Variables allow us to use names
rather than values.
• We can modify the values when the
sketch is running
• mouseX is a variable
Software – Lets Code
// Declare and initialize two integer variables at the top of the
code.
int circleX = 100;
Copy this code to a int circleY = 100;
If ( test )
{
Execute this code(value);
}
Software – Lets Code
• The test can be greater than, less than, equal to AND OR and any
combination you like:
void setup() {
size(200,200);
}
void draw() {
Type this in – what
background(r,g,b);
happens ???? stroke(255);
Change things around line(width/2,0,width/2,height);