Chapter 5: Building Block of Robot

At a school science exhibition in Jodhpur, a small wheeled robot rolls slowly across a table. When it reaches the edge, it stops, turns, and rolls back. A crowd of students watches it do this again and again. Someone asks the boy standing next to it, “How does it know where the edge is?”

He turns the robot over. Underneath, there is no single magic part. There is a plastic base with two wheels and two small motors. There is a tiny board with a black chip on it, held down by four screws. There is a small sensor pointing downwards, with two wires running to the board. A battery holder is taped to one side. Everything is joined by coloured wires.

Nothing there is clever by itself. The sensor cannot move the wheels. The motors cannot see the edge. The board cannot do either. The robot works only because these parts are connected in the right order, and each one does one job.

That is what this chapter is about (see Fig. 5.0-1).

Diagram

Fig. 5.0-1 – a small wheeled school robot shown upside down on a table, with plain labels pointing to the base, two wheels with motors, a small circuit board, a downward-facing sensor, a battery holder and the connecting wires

NoteCuriosity Corner

Q1. The robot has no brain of its own, so which part actually decides that it should stop? Q2. A ceiling fan works perfectly well without any sensor. Why does a robot need one? Q3. Once a decision is made, what turns that decision into real movement? Q4. A flying drone and a factory robotic arm look nothing alike. Are they built from the same blocks? Q5. What holds all these loose parts together and keeps them from being damaged?

By the end of this chapter, you will be able to answer each of these questions yourself.

5.1 A Robot as a System

Look at a cycle standing in the school yard. It has a frame, two wheels, a chain, pedals and brakes. Take away the chain and the pedals turn uselessly. Take away the brakes and you cannot stop safely. No single part is a cycle. The cycle is what you get when all the parts are joined in the right way.

A robot is like that too, only with more kinds of parts. It has metal or plastic bodywork, wires, motors, a battery, a small computer board and some sensing parts. On its own, each part is quite ordinary. A motor only spins. A battery only stores charge. Joined properly, they become a machine that can move around a room without bumping into the wall.

When parts are joined like this so that they work with one another, we call the whole thing a system.

NoteDefinition

A system is a set of parts joined together in a fixed way, where each part does one job and the parts together do something that no single part could do alone.

Why we study a robot block by block

A robot may have hundreds of small parts. Nobody learns a robot screw by screw. Instead, we group parts that share the same job into a block, and then study what each block does and how the blocks pass work to one another. This is much easier, and it also matches how robots are actually built. An engineer designing a delivery robot does not begin by choosing a screw. She begins by deciding what the robot must sense, what it must decide, and how it must move.

There are three broad groups of parts in any robot, and the whole chapter is built around them.

The mechanical components are the parts you can hold — the body, the wheels, the arm, the joints. They give the robot its shape and let it move and push against the world.

The electronic components are the parts that carry and handle electrical signals — the sensing parts, the circuit board, the motor drivers, the battery and the wiring. They are what the robot senses and acts with.

The computational components are the parts that are not objects at all, but instructions — the program stored inside the board, and the steps it follows to work out what to do next. See Fig. 5.1-1.

Diagram

Fig. 5.1-1 – three labelled boxes side by side under the heading “A robot”, labelled Mechanical components, Electronic components and Computational components, with two or three example items listed inside each box (body and wheels; sensor, board and battery; the stored program), and a two-headed arrow between each pair of boxes to show they work together

Q. Is a table fan a system?

A. Yes, a simple one. Its motor, blades, switch and wiring all work together to move air. But a fan does the same thing whatever is happening around it. A robot takes in information about its surroundings and changes what it does. That is the difference we build on in this chapter.

One block cannot work alone

Because the blocks depend on one another, a robot fails as a whole. If the battery runs low, the motors turn weakly and the robot looks slow and clumsy, even though nothing is wrong with the motors or the program. If a sensing part comes loose, the program keeps running perfectly but takes decisions on wrong information.

This is an honest limitation of building anything as a system: a fault in one block often shows up as strange behaviour somewhere else. When a robot misbehaves, a good builder checks each block in turn instead of blaming the part that looks guilty.

Before you open a robot, unplug it from the computer and disconnect the battery. A robot that is still powered can start a motor the moment a loose wire touches something, and fingers near a wheel or a joint can get pinched.

5.2 The Block Diagram of a Robot

Suppose someone hands you a photograph of a robot. You can see its shape and its wheels, but you cannot see what happens inside it when it is switched on. Which part gets the information first? Which part acts last? A photograph cannot tell you.

So engineers draw the robot a second way. They draw one box for each block, write the block’s name inside it, and join the boxes with arrows to show which way information travels. A drawing like this is called a block diagram.

NoteDefinition

A block diagram is a drawing in which each block of a system is shown as a labelled box, and arrows between the boxes show the direction in which information or signals travel.

Filling a bucket, without thinking about it

Before reading the diagram, think about filling a bucket from a tap up to a mark near the rim. You know where you want the water to reach. You keep glancing at the actual level. Your eyes tell you how far the water still is from the mark, and that gap is what makes you keep the tap open. When the gap becomes zero, you close the tap.

Three things are going on there. You have a target. You measure what is really happening. You act on the difference between the two. A robot works in exactly the same way, and the block diagram is simply that idea drawn out.

Reading the diagram

The complete diagram is shown in Fig. 5.2-1. Follow it from left to right first, then follow the lower path back.

Diagram

Fig. 5.2-1 – block diagram of a robot drawn left to right: an arrow labelled “Given task” enters a box “Robot model”; its output goes to a small circle marked with a cross (the comparison point); from the circle an arrow labelled “Error signals” goes to “Controller”, then to “Actuators”, then to “Manipulator”, and out to the right as “Task done”. Below, an arrow from the manipulator’s output feeds back into a box “Sensors”, whose output goes to a box “Information processing unit”, whose output returns to the comparison circle

A task is given to the robot, such as “move the arm to this position”. The robot model is the robot’s own stored description of itself — how long its arm is, how its joints turn — and it uses this to work out what the given task means in terms the machine can use, such as how far each joint must turn.

That target then reaches the comparison point, drawn as a small circle with a cross. Here the target is compared with what the robot is actually doing at this moment. The difference between the two is the error signal.

The error signal goes to the controller, the block that decides what must be done to reduce that difference and sends out the electrical control signals.

Those signals reach the actuators, the blocks that convert electrical signals into movement, such as motors.

The actuators drive the manipulator, the mechanical arm or limb that actually touches the world and carries out the task.

Now follow the lower path. The sensors measure what is really happening — where the arm has reached, whether an object is in the way. Their readings go to the information processing unit, which cleans up the readings and works out the robot’s present state. That result is carried back to the comparison point, where it is compared with the target once more.

This return path is called feedback.

NoteDefinition

Feedback means sending information about what a system has actually done back to the part that decides what it should do next, so that the difference between the two can be corrected.

the feedback loop of a robot Input: the task given to the robot Output: the task carried out Steps:

1. Work out the target from the given task, using the robot model.
2. Read the sensors to find what the robot is actually doing.
3. Subtract the actual state from the target to get the error signal.
4. If the error is small enough, stop; the task is done.
5. The controller sends control signals based on the error.
6. The actuators move the manipulator.
7. Go back to step 2.

Why it works: as long as the error is not zero, the loop keeps acting; the loop stops acting only when the robot has reached what it was asked to do.

Q. What if the feedback line is cut?

A. The robot keeps sending out the same control signals and never learns what actually happened. An arm ordered to stop at a certain point would sail past it if the load was lighter than expected, because nothing tells it that it has already arrived.

What the diagram does not show

A block diagram shows which way information flows. It does not show where the parts sit inside the robot, how big they are, or how they are wired. Two robots with the same block diagram can look completely different.

The diagram also hides time. Every trip round the loop takes a small amount of time — reading the sensors, working out the error, driving the motor. So correction is never instant, and a robot moving quickly will always overshoot a little before it settles.

5.3 The Working Blocks of a Robot

You have now seen the whole loop at a glance. The next step is to open up each box in Fig. 5.2-1 and ask what it really does, and what it is made of.

It helps to compare the blocks with parts of your own body, as long as you remember that the comparison is only a way of remembering. Your skin, eyes and ears take in information about the world; the robot’s sensors do that job. Your muscles pull your bones; the robot’s actuators do that job. Your arm and hand reach out and hold things; the robot’s manipulator does that job. Your brain does two rather different things — it makes sense of what your senses report, and it decides what to do about it — and in a robot these two jobs are drawn as two separate blocks, the information processing unit and the controller.

Five working blocks make up the loop, and the four sub-sections that follow take them one at a time, in the order in which a robot uses them: the controller, the actuators, the manipulator, the sensing devices and the information processing unit.

Q. Why show the controller and the information processing unit as two blocks?

A. Because they do two different jobs. One works out what the situation is; the other works out what to do about it. In a small school robot both jobs run on the same little board. The diagram separates the jobs, not always the hardware.

5.3.1 The Controller

A sensing part can report that there is a wall 10 cm ahead. A motor can spin when current is sent to it. But the sensing part cannot start the motor, and the motor has no idea that a wall exists. Something must sit between them, take in the reading, apply a rule, and send out the right electrical signal.

That something is the controller. It is often called the brain of the robot, though it is better to say plainly what it does: it holds the robot’s instructions and turns incoming readings into outgoing signals.

NoteDefinition

The controller is the block of a robot that receives information from the sensing side, applies the rules stored in its program, and sends out control signals to the actuators.

What the controller does

The same block handles several jobs, one after another, many times a second.

  • It takes in sensory data from the robot’s sensors — a camera, a proximity sensor, a sensor that measures tilt — and reads them as numbers it can work with.
  • It builds up a picture of the surroundings from those numbers: how far the nearest object is, whether the path ahead is clear, how warm the air is. This is called environmental perception.
  • It chooses what to do next, by comparing those numbers against the rules written into its program.
  • It plans the path and the motion — which way to turn, how fast to run each motor — and sends the matching control signals out to the actuators.
  • It keeps checking the result through feedback, and adjusts the signals when the robot is not doing what was asked.
  • It handles safety and faults: stopping the motors when an emergency stop button is pressed, or when a reading shows something has gone wrong.
  • In robots that work near people, it also manages the interaction with the human operator — reading a button press, sending back a message on a screen.

In a robot meant to work without a person guiding it, all of this must happen without anyone stepping in. The controller is what makes that possible, because every rule it needs has already been written into it.

Q1. The robot has no brain of its own, so which part actually decides that it should stop?

A. The controller. It reads the number coming from the sensor, compares it with a limit written in its program — for example, “if the floor is not detected below, stop the motors” — and sends the stop signal to the actuators. The choice was written by a person; the controller applies it, thousands of times a second, without getting tired.

The board that holds the controller

In a school robot, the controller is a small board with a microcontroller on it — a single chip that contains a tiny processor, memory to store the program, memory to hold working data, and pins to connect to the outside world. One popular board of this kind is the Arduino Uno, shown in Fig. 5.3-1.

Diagram

Fig. 5.3-1 – photo of an Arduino Uno board seen from above, with the USB socket, the power socket, the rows of pin headers along both long edges, and the main rectangular microcontroller chip clearly visible

the Arduino Uno board What it is: An open-source microcontroller board, built around the ATmega328P chip, widely used in school and hobby robotics. How it works: The program is written on a computer, sent to the board through the USB cable, and stored in the board’s flash memory. Once stored, the program runs on its own every time the board is powered. Sensors and actuators are connected to the pins along the edges of the board, which the program reads from and writes to. Used for: Small robots and simple automatic systems, such as a bot that stops before an obstacle or an alarm that sounds when smoke is detected. Watch out: The board is small and cheap, and that is also its limit. It cannot hold large programs, and it cannot drive a motor directly from its pins — the current a motor needs would damage the board, so a separate motor driver is always used.

thinking the board itself is clever What goes wrong: Students often say the Arduino board “knows” when to stop the robot. Two identical boards can behave completely differently, so the cleverness cannot be in the board. The fix: The board only carries out the instructions stored in it. Change the program and the same board behaves in a new way. The rules come from the person who wrote the program.

An honest limit

A controller can only handle situations someone has already thought about. If a robot’s program has a rule for a wall in front but no rule for a wall on the side, the robot will drive into the side wall without hesitating. It is not confused — there is simply nothing in its program for that case.

5.3.2 The Actuators

The controller’s output is only a signal — a small voltage on a pin. A voltage cannot lift a box or turn a wheel. Something must take that electrical signal and turn it into a push, a pull or a spin.

That is the job of the actuators. In a robot, they are the parts that do the actual physical work.

NoteDefinition

An actuator is a part of a robot that converts an electrical signal into mechanical motion, so that the robot can move itself or move something else.

Q3. Once a decision is made, what turns that decision into real movement?

A. The actuators. The controller’s decision leaves the board as an electrical signal; a motor, or another actuator, turns that signal into rotation or a push. Without an actuator, a robot could sense and calculate perfectly and still sit completely still.

What actuators are used for

Actuators do four kinds of work in a robot.

They provide movement from place to place. Motors turn the wheels of a mobile robot, or drive the legs of a walking one, and also steer it.

They provide manipulation and grasping. In a robotic arm, actuators drive the joints, and a gripper at the end opens and closes to pick up, hold and release objects.

They set orientation and position. A camera that must tilt down to look at a table, or a sensor that must point in a chosen direction, is moved into place by a small actuator.

They also produce controlled, expressive movement in robots built to work near people — a nod of the head, a wave of the arm — so that a person can tell what the robot is about to do.

Common actuators in robots

The most common actuator by far is the electric motor. A direct current (DC) motor spins as long as current flows through it, and spins the other way when the connections are reversed. It is simple, cheap and easy to control, which is why school robots use it for wheels.

A plain DC motor has one weakness: it can spin, but it cannot be told to stop at a chosen angle. For that we use a servo motor, which is a DC motor packed together with gears and a built-in feedback part that keeps track of the shaft’s position. Tell a servo to go to a certain angle, and its own internal loop holds it there. Fig. 5.3-2 shows both types.

Diagram

Fig. 5.3-2 – photo showing a small geared DC motor with a rubber wheel fitted on its shaft, placed beside a hobby servo motor with a white plastic horn attached to its output shaft

Table 5.1 – DC motor vs servo motor | Feature | DC motor | Servo motor | |—|—|—| | What you control | How fast it spins, and in which direction | The exact angle the shaft turns to | | Feedback | None inside the motor | Built in, so it knows its own position | | Range of turning | Keeps spinning as long as power is supplied | Usually limited to a fixed range, such as half a turn | | Typical use in a robot | Wheels of a mobile robot | Joints of an arm, a gripper, a tilting camera mount | | Cost and wiring | Cheaper, needs a motor driver | Costlier, connects straight to a control pin |

Not every actuator is electric. A pneumatic actuator uses compressed air pushed into a cylinder to slide a piston in and out. Air-driven actuators are fast and give a strong push, so factory robots use them for gripping and lifting. A hydraulic actuator works the same way but uses pressurised oil instead of air. Oil does not squash, so hydraulic actuators give very large forces under close control, which is why they are found in heavy machines such as excavators and large industrial robots.

Pneumatic and hydraulic actuators hold fluid at high pressure and can move suddenly even after the power is switched off. They are not for school projects. With ordinary motors, disconnect the battery before changing any wiring, and keep fingers away from gears and wheels — a small geared motor has enough force to pinch skin.

Working out how far a wheel takes the robot

Once you know which motor is turning a wheel, you can work out how far one turn of that wheel carries the robot. Every full turn moves the robot forward by the distance around the rim of the wheel:

\[d = \pi D\]

Here \(d\) is the distance covered in one full turn and \(D\) is the diameter of the wheel.

distance covered by a robot wheel

Given: a robot wheel of diameter 6.5 cm (a typical size for a small school robot); the wheel makes 4 full turns

Find: the distance the robot moves forward

Working:

Distance in one turn \(= \pi D = 3.14 \times 6.5 \text{ cm} = 20.41 \text{ cm}\)

Distance in 4 turns \(= 4 \times 20.41 \text{ cm} = 81.64 \text{ cm}\)

about 81.6 cm

An honest limit

This calculation assumes the wheel grips the floor perfectly. On a dusty or polished floor the wheel slips, so it turns more than the robot actually moves. The robot has no way of knowing this from the motor alone — which is exactly why robots also carry sensors, as the next sections show.

5.3.3 The Manipulator

Wheels can carry a robot across a room. They cannot pick up a bottle from a table. For that, a robot needs something that reaches out from its body — something that can be extended, bent, turned and closed around an object.

Your own arm does this. Your shoulder swings, your elbow bends, your wrist turns, and your fingers close. The rigid parts in between — upper arm, forearm, hand — do not bend themselves; all the movement happens at the joints. A robot’s arm is built on exactly the same plan.

NoteDefinition

A manipulator is the mechanical arm or limb of a robot, made of rigid parts connected by joints, which reaches out and acts on objects in the robot’s surroundings.

How a manipulator is put together

A manipulator is a chain. Each rigid part is a link, and each place where two links meet and move is a joint. Fixed at the far end of the chain is the tool that actually touches the object, called the end-effector. Fig. 5.3-3 shows a common industrial arm with its parts named.

Diagram

Fig. 5.3-3 – side view of an industrial robotic arm standing on a base, labelled from the bottom upwards: base joint, shoulder joint, lower link, elbow joint, upper link, wrist joints, and end-effector at the tip

The joints are what give the arm its freedom. A joint near the base swings the whole arm left and right. Joints further up bend it and raise it. Small joints at the wrist tilt and twist the end-effector, so the tool can be brought to an object at whatever angle the job needs. The more joints an arm has, the more separate ways it can move — and the more awkward positions it can reach around.

the end-effector What it is: The tool fitted at the tip of a manipulator, chosen to suit the job the robot has to do. How it works: An actuator inside or behind the end-effector drives it. A gripper closes two or more fingers around an object and holds it until the controller signals release. A suction cup instead pulls air out from under itself so that air pressure holds a flat object against it. Used for: Grippers pick and place parts on an assembly line; suction cups lift glass sheets and cardboard cartons; welding torches, screwdrivers and cameras are fitted where the task calls for them. Watch out: An end-effector is built for one kind of object. A gripper sized for a steel bolt will crush an egg, and a suction cup will not hold anything with a rough or curved surface.

What manipulators are used for

The main use is handling objects. A manipulator can grasp an object, lift it, turn it to face a new direction, place it and let it go — and repeat that sequence identically, thousands of times, without getting bored or careless. This is why factory arms are used for tightening bolts, spraying paint and packing cartons.

The second use is reaching where a person should not go. A manipulator carrying a camera and sensors can be sent along a pipeline, under a bridge girder, or into the tail section of an aircraft, so that an inspection can be done without a person crawling into a cramped or dangerous space.

Q. Does every robot have a manipulator?

A. No. A cleaning robot that only drives around the floor has none. A manipulator is added when the robot must do something to an object, not just travel. And it need not look like a human arm — a mechanical body can be of any form that suits the task.

A large industrial manipulator moves fast and cannot see people, so it is kept inside a fenced area with a gate that cuts power the moment it is opened. Never stand within reach of a moving arm, and never lean into the working area of one to look more closely.

An honest limit

An arm can only work inside the space it can reach, and that space is fixed by the length of its links. It is also weakest when stretched out straight, in the same way that you can hold a full water bottle easily near your chest but find it heavy at arm’s length. A manipulator that lifts a load close in may not manage the same load at full stretch.

5.3.4 The Sensing Devices

A controller can hold the finest set of rules ever written, and still be useless. A rule such as “stop if a wall is 10 cm ahead” is worth nothing unless something actually measures how far the wall is. Rules need facts to work on, and those facts have to come from the real world.

Sensing devices supply them. A sensor is the robot’s way of noticing something and turning it into a number the controller can use.

NoteDefinition

A sensor is a device that measures a physical quantity — such as distance, light, temperature, force or tilt — and converts it into an electrical signal that a controller can read as a number.

Q2. A ceiling fan works perfectly well without any sensor. Why does a robot need one?

A. Because a fan always does the same thing, and a robot must not. A fan spins at the speed you set, whether the room is empty or crowded. A robot has to behave differently when the situation is different — stop for this obstacle, turn at that corner, grip this object gently. It cannot do that unless it can measure what is around it, and measuring is exactly what sensors do.

What sensing gives a robot

Sensors are used for several different jobs inside one robot.

They let the robot perceive its surroundings — how far away things are, how bright it is, how warm or damp the air is.

They let it detect and recognise objects. A camera collects an image, and the program looks through that image for the shape it has been trained to find, which is how a robot picks the right part off a moving belt.

They let it know about itself. An encoder fitted to a motor counts how far the shaft has turned, so the robot can work out how far it has travelled. An accelerometer measures how quickly its speed is changing, and a gyroscope measures how fast it is turning, so a two-wheeled robot can tell that it is tipping over and correct itself.

They warn it about nearby objects. A proximity sensor reports that something is close, without needing to touch it, which is what keeps a robot from driving into a wall.

They give it a sense of touch. A tactile sensor responds to contact or pressure, so a gripper can tell that it has actually caught hold of the object, and can stop squeezing before the object is crushed.

Finally, they close the feedback loop of Fig. 5.2-1. Every reading that goes back to the comparison point comes from a sensor. Without sensors there is no feedback at all, only guessing.

A sensor you can measure with: the ultrasonic sensor

The commonest proximity sensor in school robotics is the ultrasonic sensor, shown in Fig. 5.3-4. It works the way a bat finds its way in the dark: send out a sound, wait for it to bounce back, and use the waiting time to judge the distance.

Diagram

Fig. 5.3-4 – photo of an ultrasonic sensor module with its two round transmitter and receiver “eyes” facing forward and its four pins along the lower edge

the ultrasonic sensor What it is: A small module with two round faces, one that sends out sound and one that listens for it. The sound it uses is above the range human ears can hear, which is why it is called ultrasonic. How it works: The controller sends a short pulse to the module’s trigger pin. The module gives out a burst of sound, which travels forward, strikes an object and comes back. The module then holds its echo pin high for exactly as long as the sound was travelling. The controller measures that time and calculates the distance from it. Used for: Stopping a robot before an obstacle, and measuring how full a container is by how far down the surface lies. Watch out: Soft cloth and foam absorb the sound instead of reflecting it, and a smooth surface at a slant bounces the sound away sideways. In both cases the echo never comes back and the sensor reports nothing there, even though something is.

Turning time into distance

Sound travels through air at a speed of about 343 metres per second at ordinary room temperature. The sound the sensor sends out has to travel to the object and then all the way back, so it covers the distance twice. That is why the calculation has a 2 in it:

\[\text{distance} = \frac{v \times t}{2}\]

Here \(v\) is the speed of sound in air, \(t\) is the total time from sending the burst to receiving the echo, and the answer is the distance from the sensor to the object.

finding the distance to an obstacle

Given: speed of sound in air \(v = 343\) m/s (a typical value at about 20 °C); suppose the controller measures the echo time as \(t = 2.0\) milliseconds \(= 0.0020\) s

Find: the distance to the object

Working:

Total distance travelled by the sound \(= v \times t = 343 \text{ m/s} \times 0.0020 \text{ s} = 0.686 \text{ m}\)

This is the journey there and back, so the distance to the object \(= \dfrac{0.686 \text{ m}}{2} = 0.343 \text{ m}\)

0.343 m, that is 34.3 cm

forgetting the return journey What goes wrong: The 2 is left out, and the robot is told the wall is 68.6 cm away when it is really 34.3 cm away. A robot programmed to stop at 30 cm would then drive well past the wall before stopping. The fix: Always remember that the measured time covers both halves of the trip. Divide by 2 before using the answer as a distance.

A camera is also a sensor, and a robot carrying one records whoever walks past it, not only the object it was looking for. If a robot with a camera is used in a school corridor or a shop, the people there should be told it is there and what the recordings are used for, and images of people should not be kept once the job is done.

An honest limit

No sensor measures the world directly; it measures one physical effect and reports a number. An ultrasonic sensor does not detect a wall, it detects a returning sound. A light sensor does not detect a black line, it detects less reflected light. Whenever that effect is missing or misleading — a soft curtain, a shiny floor, a dark room — the number is wrong, and the robot acts confidently on a wrong number. This is why serious robots carry more than one kind of sensor.

5.3.5 The Information Processing Unit

A sensor does not hand the robot a neat sentence such as “there is a wall 25 cm ahead”. It hands over a stream of numbers, dozens of them every second, and some of those numbers are wrong. A stray echo, a loose wire or a passing shadow can produce a reading that belongs to nothing real.

You handle this yourself without noticing. If a shopkeeper’s weighing scale flickers between two figures, you wait a moment and take the value it settles on. You do not believe the flicker.

The block that does this for a robot is the information processing unit. It stands between the sensors and the decision, and its job is to turn raw readings into a clear, usable description of the situation.

NoteDefinition

The information processing unit is the block of a robot that takes the raw readings from the sensors, cleans them up, works out what they mean about the robot and its surroundings, and passes that result on for the decision.

Cleaning up the readings

Unwanted, meaningless variation in a set of readings is called noise. Noise is not a mistake by the person who built the robot; every real sensor has some. The information processing unit’s first job is to reduce its effect.

Suppose an ultrasonic sensor pointing at a wall sends in the five readings shown in Table 5.2, all taken within half a second while the robot stands still.

Table 5.2 – five distance readings from an ultrasonic sensor while the robot is stationary | Reading number | Distance (cm) | |—|—| | 1 | 24.8 | | 2 | 25.1 | | 3 | 24.9 | | 4 | 31.6 | | 5 | 25.0 |

The robot has not moved, so the wall cannot have jumped away and come back. Reading 4 is noise. There are two simple ways to deal with such a set, and they do not give the same answer.

getting one usable distance from five readings

Given: the five readings 24.8, 25.1, 24.9, 31.6 and 25.0 cm from Table 5.2

Find: the average of the readings, and the middle reading

Working:

Sum \(= 24.8 + 25.1 + 24.9 + 31.6 + 25.0 = 131.4\) cm

Average \(= \dfrac{131.4 \text{ cm}}{5} = 26.28\) cm

Arranged in order: 24.8, 24.9, 25.0, 25.1, 31.6 — the middle one of the five is 25.0 cm

average = 26.28 cm; middle reading = 25.0 cm

The average has been dragged more than a centimetre away from the wall’s real position by a single bad reading. The middle reading ignores that odd value completely, because it only cares which value sits in the centre when they are lined up in order. This is why processing units often use the middle value rather than the average when a sensor throws out occasional wild readings.

Q. Why not simply throw away any reading that looks odd?

A. Because a robot cannot tell an odd reading from a real change. If something suddenly moves into the robot’s path, the first reading of it looks exactly like noise. Ignoring surprises would make a robot dangerous, which is why processing rules are kept simple and quick rather than clever.

Working out what it all means

Cleaned readings are still only numbers. The next job is to combine them into a description of the situation: an encoder count becomes a distance travelled, a tilt reading becomes an angle, several distance readings together become a picture of where the free space is.

From that picture the unit works out the route the robot should take. Choosing a route from where the robot is to where it must go, while keeping clear of obstacles, is called path planning. Fig. 5.3-5 shows the idea for a robot crossing a room.

Diagram

Fig. 5.3-5 – plan view of a room seen from above, with a small robot at the bottom left, a goal marked at the top right, a table drawn as an obstacle in the middle, a straight dashed line from robot to goal passing through the table marked as blocked, and a curved solid line going around the table marked as the planned path

The straight line is shortest but goes through the table, so it is not usable. The curved line is longer and clear, so that is the one the robot is given. Planning also decides the timing — how fast to move along each part of the route, slowing down before a turn.

The result of all this goes back into the loop of Fig. 5.2-1, where it is compared with the target and turned into an error signal.

Q. Is the information processing unit a separate part inside a school robot?

A. Usually not. On a small robot the same microcontroller board does the processing and the controlling, one after the other, inside the same program. The two are drawn as separate blocks because they are separate jobs, not because they must be separate hardware.

An honest limit

All this work takes time. The more readings the unit collects before deciding, and the more carefully it filters them, the steadier its answer — and the later that answer arrives. A robot that averages a hundred readings before reacting will be very sure about an obstacle it has already hit. Every real design is a balance between being certain and being quick.

5.4 The Supporting Blocks of a Robot

The five blocks of Fig. 5.2-1 describe what a robot does. They do not, by themselves, make a robot that can stand on a table and work for an hour. Something has to supply energy. Something has to hold the parts in place. Something has to let a person start and stop it. And something has to stop it safely when things go wrong.

These are the supporting blocks, and Fig. 5.4-1 shows how they sit around the working loop.

Diagram

Fig. 5.4-1 – the working loop of Fig. 5.2-1 drawn small inside a large rounded rectangle, with five labelled boxes attached around the outside of the rectangle: Power supply, Mechanical structure, Communication interface, Software, and Safety systems

The power supply

Every block above runs on electricity. The power supply provides it — usually a rechargeable battery pack on a robot that moves about, a mains adapter on a robot that stays in one place, or both, with the adapter charging the battery.

Different parts want different voltages. A microcontroller board may run at 5 volts while the motors want 12 volts, so the power supply is often split into more than one line from the same battery.

The size of the battery decides how long the robot can work before it must be charged. Battery packs are marked with a capacity in milliampere-hours, written mAh, which tells you roughly how much current the pack can supply for how long.

how long a robot can run on one charge

Given: a battery pack of capacity 2000 mAh; the robot draws a steady current of 500 mA while driving (both are typical values for a small school robot)

Find: about how long the robot can run on one full charge

Working:

Running time \(= \dfrac{\text{capacity}}{\text{current drawn}} = \dfrac{2000 \text{ mAh}}{500 \text{ mA}} = 4 \text{ h}\)

about 4 hours

The real figure is always less than this. Motors draw extra current each time they start, and a battery’s voltage falls as it empties, so a robot that this sum says will run for 4 hours may in practice run for three or less.

Never join the two terminals of a battery pack directly with a wire — it heats up within seconds and can burst. Never run a school robot from a mains socket through home-made wiring; use only the adapter supplied for the board. Disconnect the battery before changing any connection.

The mechanical structure

The mechanical structure is the body of the robot: the base plate, the frame, the brackets and the covers. It carries every other block and decides where each one sits.

This block does more than hold things. It keeps the sensor pointing where the program assumes it points, keeps the wheels parallel so the robot drives straight, and keeps the whole machine from toppling when the arm reaches out. A well-planned structure also protects the electronics from dust and from knocks.

Q5. What holds all these loose parts together and keeps them from being damaged?

A. The mechanical structure — the chassis, frame, brackets and covers of the robot. It gives every block a fixed place, keeps the sensors and wheels correctly aligned, and shields the electronics from dust and knocks. It is easy to overlook because it does nothing exciting, but a robot with a wobbly frame behaves badly no matter how good its program is.

The communication interface

A robot has to be told when to start, and often has to report back. The communication interface is whatever lets that happen. It may be physical — a switch, a set of buttons, a small screen. It may be wireless, over Wi-Fi or Bluetooth, so that the robot can be driven from a phone or send its readings to a computer in another room. Robots that work in teams use the same kind of link to tell one another where they are.

The software

The firmware is the program stored inside the microcontroller, which runs every time the board is powered. Above it there may be larger control software running on a bigger computer, and in advanced robots, programs that recognise objects or speech.

Software is the block you cannot touch, and the block that matters most. Two robots built from identical parts do completely different jobs if different programs are loaded into them. Changing what a robot does usually means changing its software, not its hardware.

Q. If software is not a physical part, why call it a block?

A. Because a block is a job, not an object. The software’s job — holding the rules the robot follows — is as necessary as the battery’s job. Leave it out and the parts are just wired-together components that do nothing.

The safety systems

The last supporting block exists for the times when everything else fails. Safety systems include an emergency stop button that cuts power to the motors at once, sensors that detect a collision and halt the machine, and limits built into the program so that a motor can never push harder than a set amount.

On a factory floor these systems are what allow people to work near a machine at all. On a school robot they are simpler — often just a switch within easy reach — but the reason for them is the same. A robot that cannot be stopped quickly should not be switched on.

An honest limit

Supporting blocks are the ones most often left until last, and that is where many school projects come apart. A neat program will still fail if the battery is half charged, if the sensor bracket is held on with tape, or if there is no easy way to switch the robot off once it starts running across the table.

5.5 Mechanical Components

You have seen the blocks. From here to the end of the chapter we look at the actual parts those blocks are built from, group by group, starting with the ones you can hold in your hand.

The mechanical components are the parts that give a robot a shape, keep it standing, and let it move. It is easy to think of them as the boring half of robotics. In practice they decide whether the robot can climb a doorstep, whether the camera stays pointed where the program thinks it is pointed, and whether the machine survives a fall from a table.

Rather than learn a list by heart, it helps to ask what problem each part solves.

Parts that give shape and support

The chassis is the base of the robot — the plate or frame everything else is bolted to. It gives the machine its rigidity, so that the wheels stay parallel and the arm does not twist the body when it lifts something. Fig. 5.5-1 shows a simple two-wheeled chassis from above.

Diagram

Fig. 5.5-1 – plan view of a small robot chassis plate, labelled with two driven wheels with their motors on either side, a caster wheel at the front, a battery holder in the middle, rows of mounting holes along the plate, and a bracket at the front edge holding a sensor

Frames and mounting points are the brackets, pillars and rows of holes that fix each part in its place. They matter more than they look. A sensor that shifts by a few degrees reports about a different part of the room, and the program has no way of knowing it has moved.

Enclosures and covers close the robot in. They keep dust and stray drops away from the electronics, and they keep fingers away from moving parts, which is a safety job as much as a mechanical one.

Parts that move the robot along the ground

Wheels are the simplest answer. Two wheels, each driven by its own motor, can carry a robot forward and turn it by running one wheel faster than the other. Most robots of this kind add a caster — a small free-turning wheel that carries no drive at all and simply holds the third corner of the robot up, the way the small wheels under a hospital trolley do.

Tracks are the endless rubber or plastic belts that run around a set of wheels, as on an excavator. They spread the robot’s weight over a longer strip of ground.

Table 5.3 – wheels vs tracks | Feature | Wheels | Tracks | |—|—|—| | Surface they suit | Smooth, firm floors | Loose sand, mud, gravel, rubble | | Grip on soft ground | Sinks in and slips | Spreads weight, keeps moving | | Turning | Easy and quick | Slower; the belts scrub against the ground | | Speed on hard floor | Higher | Lower | | Wear and cost | Low | Higher; belts stretch and come off |

Legs are the third choice. A robot with legs can step over a broken kerb or climb stairs, which neither wheels nor tracks manage well. The price is complication: every leg needs several actuators and constant balancing, so legged robots are far harder to build and use much more power.

Q. Why do most small robots drive only two wheels and leave the third free?

A. Because it needs only two motors, and steering comes free — run the wheels at different speeds and the robot turns. Driving all the wheels would mean more motors, more wiring and more current, for a robot that only has to cross a classroom floor.

For rough ground, a suspension system is added: springs, or sprung arms, between the wheels and the body. It lets a wheel ride up over a stone while the body stays fairly level, so the electronics are not shaken and the wheels keep touching the ground.

Parts that let sections move relative to each other

Joints and links, which you met in the manipulator, belong to this group. So do hinges, which allow one part to swing about a fixed line — a lid that opens, a panel that folds down, a flap that closes over a stored tool.

A pan and tilt mechanism is a pair of small joints stacked one on the other, usually driven by two servo motors. One turns the mounted part left and right, the other tips it up and down. A camera or a distance sensor on such a mount can sweep a whole room without the robot moving at all, as in Fig. 5.5-2.

Diagram

Fig. 5.5-2 – photo of a small pan and tilt bracket assembled from two servo motors, with a camera module fitted on the upper bracket

Parts that soften movement

Springs store energy when squeezed and push back when released; they absorb sudden shocks. A damper does the opposite job — it resists quick movement and lets it happen slowly, the way the closer at the top of a school door lets it swing shut gently instead of banging.

Used together, they smooth out motion. Without them, an arm that stops suddenly would wobble for a while before settling, and every wobble is a small error the sensors have to report and the controller has to correct.

With the battery disconnected, roll a wheeled robot chassis by hand across a smooth floor, a carpet and a doormat. Watch where the wheels slip or stick, and say which of the three surfaces tracks would handle better, and why.

An honest limit

Mechanical parts are the ones that change with use. Screws loosen, plastic brackets bend in the heat, wheels collect dust and lose grip, and a bearing that has been running for months develops play. None of this shows up in the program. A robot that was accurate when it was assembled will drift away from that accuracy unless the mechanical parts are checked and tightened from time to time.

5.6 Electronic Components

The electronic components are the parts that carry electrical signals around the robot and change them into a form the next part can use. If the mechanical components are the bones, these are the nerves — thin, unimpressive to look at, and completely necessary.

You have already met the two most important groups: the microcontroller board that holds the controller, and the sensors that supply readings. This section deals with the parts that sit between them and everything else.

The board that carries the parts

Electronic parts have to be joined to one another, and joining hundreds of them with loose wires would be impossible to build and worse to repair. So they are soldered onto a flat board with thin copper lines printed on it, called a printed circuit board (PCB). The copper lines take the place of wires. A PCB is designed to keep signal paths short and neat, which saves space and keeps signals clean.

Diagram

Fig. 5.6-1 – photo of a green printed circuit board seen from above, showing the thin copper tracks running between the soldered components

The part that lets a small signal control a big one

A microcontroller pin is designed to send information, not power. A pin on a typical school board can safely supply only about 20 milliamperes. A small geared motor of the kind used on a robot wheel draws a few hundred milliamperes while running, and more at the moment it starts.

how far short a controller pin falls

Given: a microcontroller pin supplies about 20 mA safely; a small geared robot motor draws about 300 mA while running (both are typical values)

Find: how many times more current the motor needs than the pin can supply

Working:

\(\dfrac{300 \text{ mA}}{20 \text{ mA}} = 15\)

about 15 times more current than the pin can safely give

That is why every motor on a robot is driven through a motor driver — a small circuit that takes the weak signal from the controller and uses it to switch a much larger current from the battery through to the motor. It also lets the controller reverse a motor, by switching the battery’s connections around inside the driver. Fig. 5.6-2 shows how the pieces connect.

Diagram

Fig. 5.6-2 – block sketch showing a microcontroller board on the left with a thin arrow labelled “control signal, small current” going to a motor driver in the middle; a battery below the driver with a thick arrow labelled “battery current” going into it; and a thick arrow from the driver going to a motor on the right

joining a motor straight to a control pin What goes wrong: The motor either does not turn or turns feebly, and the board may be damaged for good, because the motor pulls far more current than the pin can supply. The fix: Always run motors through a motor driver. The control pin only tells the driver what to do; the battery, not the board, supplies the power for the motor.

A relay does a similar job in a different way. It is an electrically operated switch: a small current through a coil pulls a metal contact across and closes a separate circuit that may be carrying a much larger current. Relays are used where a robot has to switch a heavy load on and off, and where the two circuits must be kept completely separate from each other.

Q. If a relay can switch a big current, why use a motor driver at all?

A. A relay can only switch fully on or fully off, and it clicks a mechanical contact each time, so it wears out if switched rapidly. A motor driver has no moving parts and can also reverse a motor and vary its speed, which is what driving a robot needs.

The parts that hold information

The program has to be stored somewhere that survives a power cut. That is the job of flash memory inside the microcontroller, which keeps its contents when the power is off. While the program runs it needs scratch space for the values it is working with, and that comes from random access memory, which is fast but forgets everything the moment power is removed. Robots that record readings over a long period add storage such as an SD card.

The parts that carry signals about

Cables and wiring connect everything that is not on the same board — sensors at the front, motors at the sides, battery underneath. On a working robot they are the commonest cause of trouble, because a wire that is pulled tight each time an arm swings will eventually break inside its insulation, where the damage cannot be seen.

Where a signal has to travel a set path between two circuits, named links are used: serial communication over a UART for short connections between boards, Ethernet for a wired network link, and CAN in vehicles and industrial machines where many parts must share one line.

Finally, a sensor’s raw output is often too weak, too noisy, or at the wrong voltage for the microcontroller to read. Signal conditioning circuits sit in between and fix this — strengthening a weak signal, smoothing out unwanted variation, or bringing a voltage down into the range the board expects.

The parts a person touches

Buttons, switches, keypads, small screens and indicator LEDs make up the part of the electronics a user actually deals with. They matter more than their cost suggests. A robot with a clearly marked stop switch and a light that shows whether it is armed is far safer to work near than one with a single unlabelled button.

An honest limit

Electronic parts fail quietly. A cracked solder joint, a wire broken inside its insulation or a slightly loose connector produces a fault that comes and goes as the robot moves, and nothing on the outside looks wrong. When a robot behaves oddly only sometimes, the wiring is the first place to look, not the program.

5.7 Computational Components

You can weigh a chassis and hold a motor driver in your hand. The third group of components cannot be picked up at all. The computational components of a robot are the instructions it follows and the methods it uses — the part of the machine that exists only as stored steps.

A clear set of steps for doing something is called an algorithm.

NoteDefinition

An algorithm is a finite set of clear, ordered steps that takes some input and produces the required result.

You already know several without calling them that. Long division is an algorithm. So is the method a shopkeeper uses to work out change. So is the loop shown earlier in Section 5.2, which describes how a robot corrects itself over and over until the error is gone.

The part that carries the steps out

At the centre of the computational side is the processor inside the microcontroller. It does one thing, extremely quickly: fetch the next instruction, carry it out, move on. There is no cleverness in the chip itself. Everything the robot appears to work out has been written as instructions and handed to a part that follows them exactly, millions of times a second, without ever varying.

Managing many jobs at once

A small robot runs one program that does one job. A larger robot may have to read a camera, keep its balance, follow a route, watch a battery and listen for a stop command, all at the same time. Deciding which job gets the processor’s attention next, and how memory is shared between them, is the work of an operating system.

For robots, the timing of those decisions matters in a way it does not on a school computer. If a balancing robot’s correction runs a fraction of a second late, the robot has already fallen over. So many robots use a real-time operating system (RTOS), which is built to guarantee that important jobs run within a fixed time, rather than simply running everything as fast as it can on average.

Q. Does a small Arduino-based robot have an operating system?

A. No. Its program runs straight on the chip, and it is the only thing running. That is quite enough for one simple job, and it also means the timing is easy to predict. An operating system is only worth its cost when there are many jobs to juggle.

Knowing where it is, and what is around it

Suppose you are sent into an unfamiliar market to find a particular shop. As you walk, you build up a rough map in your head — this turning, that landmark — and at the same time you keep track of where you are on the map you are building. The two go together: you cannot place a landmark without knowing where you were standing when you saw it.

A robot faces exactly the same problem, and the two halves have names. Working out where the robot is at this moment is called localisation. Building up a description of the surroundings is called mapping. Doing both at once, in a place the robot has never been, is called simultaneous localisation and mapping, usually written SLAM. Fig. 5.7-1 shows a robot part way through the job.

Diagram

Fig. 5.7-1 – plan view of a room being mapped: a robot in the lower half with dashed sensor lines fanning out from it, the walls it has already detected drawn as solid lines, the walls it has not yet reached drawn as faint dotted lines, and the far corner of the room shaded and marked “not yet explored”

Once the robot knows where it is and where the free space lies, it can plan a route through that space, and then convert the route into motor commands — how fast to turn each wheel at each moment. This last step is motion control, and it is what finally reaches the actuators.

A robot that maps a building stores the layout of a place where people live or work, and often the times at which rooms are occupied. That information should be kept only as long as the robot needs it, kept on the machine rather than sent away without the owner’s knowledge, and never shared with anyone the owner has not agreed to.

An honest limit

An algorithm only works while its assumptions hold. A stored map is correct until someone moves the furniture; a route is safe until a chair is left in the corridor. The robot has no way of noticing that its assumptions have quietly stopped being true, so it will follow the plan into the chair with complete confidence. Sensors are what allow it to catch such changes — which is why the computational side can never be separated from the sensing side.

5.8 Design Aspects of Different Robots

Every robot in this chapter has been described with the same set of blocks. Yet robots do not look alike at all. A machine that crawls along the floor of a warehouse, one that walks on two legs, one that flies, and one that works far below the sea share almost nothing in appearance.

Designing a robot means choosing, for each block, the particular part that suits the job — and those choices are driven by two questions. Where will the robot work, and what must it do there? The surroundings decide how the robot moves, how it is protected and how it communicates. The task decides what it senses and what it carries at the end of its arm.

Fig. 5.8-1 shows the four kinds compared in the sub-sections that follow.

Diagram

Fig. 5.8-1 – four simple side-view outlines in a row, labelled Mobile robot (a low box on wheels), Humanoid robot (a two-legged figure with arms and a head), Aerial robot (a four-rotor drone) and Underwater robot (a sealed torpedo-shaped body with thrusters)

Q4. A flying drone and a factory robotic arm look nothing alike. Are they built from the same blocks?

A. Yes. Both have sensors, a controller, actuators, an information processing unit, a power supply, a structure and software. What differs is the choice made for each block. The arm’s actuators drive joints; the drone’s actuators spin propellers. The arm’s structure is a heavy fixed base; the drone’s is as light as it can be made. The blocks are the same; the parts filling them are chosen to suit the job and the surroundings.

A mechanical body, then, can take any form at all. Wheels, legs, propellers and thrusters are not four different ideas about what a robot is — they are four answers to the same question of how to move through a particular place.

5.8.1 Mobile Robots

A mobile robot is one that travels about on a surface — a warehouse floor, a hospital corridor, a field. Its whole design follows from one fact: it must carry everything it needs with it, including its own energy.

Start with the structure. A mobile robot is usually built low and wide, on a flat chassis, with the battery — the heaviest single item — mounted near the bottom. Anything tall and top-heavy tips over when it starts, stops or turns quickly. Fig. 5.8-2 shows the usual shape.

Diagram

Fig. 5.8-2 – photo of a small wheeled mobile robot standing on a floor, seen from the front, low and flat, with an ultrasonic sensor mounted at the front edge of its chassis

Q. Why does keeping the weight low help?

A. The lower the weight sits, the harder it is to tip the robot over. You use the same rule when you crouch to steady yourself in a moving bus instead of standing upright.

For movement, two driven wheels and a caster are the usual choice indoors, because they are simple and turn on the spot. Outdoors, on loose ground, tracks or larger wheels with suspension are chosen instead. The motors are almost always fitted with gearboxes, which trade speed for turning force so that the robot can start moving with a load on it.

The sensing is chosen around one main danger: hitting something. Proximity sensors at the front report obstacles in time to stop. Encoders on the wheels count how far each wheel has turned, so the robot can estimate how far it has come. A robot that follows a painted line adds a downward-facing sensor that watches the reflected light from the floor.

The controller runs the same short loop over and over — read the sensors, decide, drive the motors — and the software holds the rules for what to do at an obstacle, at a junction and at the goal. Communication is usually wireless, so that a person or a central computer can send it a new destination without stopping it.

Mobile robots of this kind are already ordinary. Warehouses use fleets of low, flat robots that drive under a shelving unit, lift it, and carry the whole shelf to a packing station. Hospitals use taller versions with lockable trays to move linen and medicines between floors. The floor-cleaning robot sold for homes is the same design made small.

A mobile robot working in a corridor shares space with people who did not choose to be there. It should move slowly enough to stop in time, make some sound or show a light so that it is noticed, and give way to people rather than expecting people to give way to it.

An honest limit

Counting wheel turns tells a robot how far its wheels have gone, not how far it has gone. On a wet or dusty floor the wheels slip, and the small errors add up over a long run until the robot’s idea of its position is well away from the truth. This is why a mobile robot that has to work for hours needs something outside itself to check against — a line on the floor, a marker on a wall, or a map built from what its sensors can see.

5.8.2 Humanoid Robots

A humanoid robot is built roughly to the plan of a human body: a torso, two arms, two legs and a head. This is a hard shape to build and an inefficient way to move, so it is worth asking why anyone chooses it.

The answer is that the world is already built for that shape. Stairs, doorways, handles, switches and tools are all sized for people. A machine with the same reach and the same joints can use them without anything being rebuilt. The second reason is that people find a human-shaped machine easier to read — you can tell at a glance which way it is facing and what it is about to pick up.

Fig. 5.8-3 shows where the main blocks sit in such a robot.

Diagram

Fig. 5.8-3 – front view sketch of a small humanoid robot with labels pointing to a camera and microphone in the head, shoulder, elbow and wrist joints in the arms, hip, knee and ankle joints in the legs, a tilt-measuring sensor and the controller board in the torso, and the battery low in the torso

The actuator count is what sets a humanoid apart. Every joint needs its own actuator, and there are many joints — several in each arm, several in each leg, one or two in the neck. Small humanoid robots of the kind used in schools and competitions typically use around fifteen to twenty servo motors, each holding its own commanded angle.

Balance is the central design problem, and it is a sensing and computation problem rather than a mechanical one. A tilt-measuring sensor in the torso reports how the body is leaning, sensors in the feet report where the weight is pressing, and the controller adjusts several joints together, many times a second, to keep the robot’s weight over the foot that is on the ground.

Q. Why is standing on two legs so much harder than standing on wheels?

A. A wheeled robot rests on three or four points spread wide apart, so it stays put by itself. A walking robot has only one small foot on the ground for much of each step, and it stays up only because it keeps correcting. Switch off a wheeled robot and it stops; switch off a walking one and it falls.

The structure has to be light, because every gram must be lifted by the leg actuators at each step, and stiff, because a bending link makes the balance calculation wrong. The power supply is under heavy demand, since a dozen or more motors are working continuously even when the robot is standing still.

Humanoid robots are used where the interaction matters as much as the work: greeting visitors at an exhibition counter, guiding people at a public information desk, and in research on how machines might one day work in buildings meant for people.

An honest limit

For nearly every practical job on a flat floor, a wheeled robot does better — it is cheaper, steadier, faster and uses far less power. Humanoids remain expensive, slow and fragile; a fall that a person would shrug off can break several joints at once. The shape is chosen for the places and the tasks where being human-shaped is the whole point, not because it is the better machine.

5.8.3 Aerial Robots

An aerial robot works in the air. That single fact changes every design choice, because nothing holds the machine up. A wheeled robot that loses power simply stops; an aerial robot that loses power falls. Its motors must keep working every second it is in the air.

The commonest design is the four-rotor type shown in Fig. 5.8-4. Four motors, each with a propeller, are fixed at the ends of four arms, with the control board and battery in the middle.

Diagram

Fig. 5.8-4 – top view of a four-rotor aerial robot: a central square body containing the control board and battery, four arms reaching out to four motors with propellers, curved arrows showing that the two propellers on one diagonal spin one way and the two on the other diagonal spin the opposite way

There are no steering flaps or rudders. The machine is steered entirely by changing the speeds of the four motors relative to one another. Running the two motors on one side a little faster tips the machine towards the other side, and it slides that way. Because the propellers on one diagonal spin one way and those on the other diagonal spin the opposite way, their twisting effects cancel; speed up one diagonal pair and the whole machine turns on the spot.

Weight rules the structure. Every gram has to be lifted continuously, so frames are made of thin plastic or carbon fibre, and nothing is carried that is not needed. This is the opposite of the mobile robot, where a heavy battery low down was an advantage.

Sensing is dominated by keeping level. A gyroscope and an accelerometer report how the machine is tilting and turning, and the controller adjusts the four motor speeds hundreds of times a second in response. A pressure sensor measures height by the fall in air pressure, and outdoors a satellite positioning receiver reports the machine’s position over the ground. Indoors, where satellite signals are weak, a downward-facing camera or distance sensor is used to hold position instead.

The communication link is a safety item, not a convenience. If the radio link to the operator is lost, a well-designed aerial robot does not simply carry on; its software brings it down or returns it to where it took off.

Aerial robots are used for photography and surveying, for inspecting power lines, bridges and tall towers without putting a person on a rope, for spraying crops, and for carrying small loads to places that are hard to reach by road.

Propellers spin fast enough to cut skin, and they are dangerous even on a small machine. Never hold or start an aerial robot with the propellers fitted while anyone is close by, and remove the propellers before testing motors on the bench. Flying is also governed by law in India and in most countries — machines must be registered and there are areas where flying is not allowed — so a school project must be flown only in a permitted place, with permission, and away from people and their homes.

An honest limit

Flight time is short. A small machine of this kind typically stays up for something like twenty to thirty minutes on a charge, because lifting itself uses far more energy than rolling would. Adding a bigger battery adds weight, which uses more energy again, so there is a limit to how far that trade can be pushed. Wind, rain and cold all cut the time further.

5.8.4 Underwater Robots

An underwater robot works in a place that is actively hostile to electronics. Water gets into any opening, presses harder the deeper you go, blocks radio signals within a short distance, and swallows light so that visibility is poor even in daytime. Every design choice is an answer to one of those four problems. Fig. 5.8-5 shows the usual arrangement.

Diagram

Fig. 5.8-5 – side view of an underwater robot: a sealed cylindrical body containing the controller and battery, thrusters mounted at the rear and on top, a camera with a lamp beside it at the front, a depth sensor on the underside, and a tether cable running up from the body to a boat drawn at the water surface

The structure begins with a sealed housing. Every joint, window and cable entry is fitted with a rubber seal, and the housing is made strong enough for the depth the robot must reach, because water presses in harder the further down it goes.

The robot must also be balanced against floating and sinking. Designers add foam blocks to make it more buoyant and weights to make it less, until it is close to neutral — it neither rises nor sinks on its own. That way the thrusters only have to move it, not hold it up, which saves a great deal of energy.

For movement it uses thrusters — small propellers in sealed housings, pointed in different directions. One pair drives it forward and turns it; another, mounted to push up or down, controls depth. There are no wheels and nothing to push against but water itself.

The sensing is chosen to suit water rather than air. A pressure sensor gives the depth directly, since pressure rises steadily with depth. Sound is used for looking around, because it travels well through water where light does not: a sonar sends out a pulse and times the echo, which is the same method as the ultrasonic sensor in Section 5.3.4, working over a much greater distance. Cameras are carried too, but they are useless without a lamp beside them.

Q. Why not simply use radio, as robots on land do?

A. Water absorbs radio waves within a short distance, so a radio link fails almost as soon as the robot goes under. That is why these robots are either connected by a cable to a boat, or send slow messages by sound, or store their readings and report only when they surface.

Underwater robots are used to inspect ship hulls, undersea pipelines and the walls of dams, to survey the sea floor, to study marine life without a diver disturbing it, and to search in water too deep or too dangerous for people.

Table 5.4 – how the four designs differ | Feature | Mobile robot | Humanoid robot | Aerial robot | Underwater robot | |—|—|—|—|—| | How it moves | Wheels or tracks | Two legs | Propellers in air | Thrusters in water | | Main design worry | Grip and stability | Balance | Weight | Sealing and pressure | | Key sensing | Proximity and encoders | Tilt and foot pressure | Tilt and height | Depth and sonar | | Behaviour if power fails | Stops where it is | Falls | Falls out of the sky | Floats up or sinks | | Usual link to operator | Wi-Fi or Bluetooth | Wi-Fi | Radio | Cable, or sound |

An honest limit

Position is the hard problem underwater. Satellite positioning does not work below the surface, so the robot has to estimate where it is from its own speed and heading, and those estimates drift further from the truth the longer it stays down. A cable solves the communication problem but limits how far the robot can travel, and can snag on wreckage or rock. Sending messages by sound frees the robot from the cable, but sound carries far less information than a cable does, so the robot must be able to work for long stretches without being told anything.

5.9 All the Blocks Working Together

Everything in this chapter has been described one block at a time. The only way to see that the blocks really do work as a system is to build the smallest possible robot system and watch it run.

The job we will give it is simple: warn when something comes too close. It is the first half of what an obstacle-avoiding robot does, and it uses every block you have met, in miniature. The sensing device is an ultrasonic sensor. The controller and the information processing unit are both the microcontroller board. The actuator is a small buzzer, which converts an electrical signal into sound instead of motion. The power supply is the computer’s USB cable. The structure is whatever the parts are mounted on. The software is the program we are about to write.

The method, before the program

Always settle the method in words first. Writing code before you know what the code must do is how most projects go wrong.

warning when an object comes too close Input: the echo time measured by the ultrasonic sensor Output: a buzzer that sounds while an object is nearer than the chosen limit Steps:

1. Send a short trigger pulse to the sensor.
2. Measure how long the echo pin stays high.
3. Convert that time into a distance in centimetres.
4. If the distance is less than the limit, switch the buzzer on.
5. Otherwise, switch the buzzer off.
6. Wait a short while, then go back to step 1.

Why it works: the loop measures again and again, so the buzzer follows what is actually in front of the sensor at that moment rather than what was there when the robot started.

Notice that this is the feedback loop of Fig. 5.2-1 in its simplest form. There is a target, taken from a rule we choose; there is a measurement; and there is an action that depends on the difference between the two.

Connecting the parts

The circuit uses an Arduino Uno board, an ultrasonic sensor module and a small active buzzer, wired as in Fig. 5.9-1. The sensor’s power pins go to the board’s 5 V and GND pins. Its trigger pin goes to digital pin 9 and its echo pin to digital pin 10. The buzzer’s positive lead goes to digital pin 8 and its other lead to GND. Unplug the USB cable from the board before making or changing any of these connections.

Diagram

Fig. 5.9-1 – wiring diagram showing an Arduino Uno board, an ultrasonic sensor module with its four pins joined to 5V, GND, pin 9 and pin 10, and a small buzzer joined to pin 8 and GND, with each wire labelled

The program

The distance is worked out with the same rule as in Section 5.3.4, written in units that suit a microcontroller. Sound travels about 343 metres per second, which is 0.0343 centimetres in every microsecond, and the time measured covers the trip there and back — so the time is multiplied by 0.0343 and then halved.

sounding a buzzer when an object comes within 20 cm Problem: measure the distance to the nearest object about twice a second, show it on the computer, and sound a buzzer whenever that distance is less than 20 cm.

const int trigPin = 9;      // sends the pulse that starts a measurement
const int echoPin = 10;     // goes high while the echo is on its way
const int buzzerPin = 8;
const int limitCm = 20;     // warn when something is nearer than this

void setup() {
  Serial.begin(9600);
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  pinMode(buzzerPin, OUTPUT);
}

void loop() {
  // give the sensor a clean 10 microsecond trigger pulse
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);

  // measure how long the echo pin stays high, in microseconds
  long echoTime = pulseIn(echoPin, HIGH);

  // 0.0343 cm per microsecond, halved for the return journey
  float distanceCm = echoTime * 0.0343 / 2;

  Serial.print("Distance: ");
  Serial.print(distanceCm);
  Serial.println(" cm");

  if (distanceCm < limitCm) {
    digitalWrite(buzzerPin, HIGH);
  } else {
    digitalWrite(buzzerPin, LOW);
  }

  delay(500);
}

Output: The Serial Monitor shows a fresh line about twice a second, each line giving the word Distance, the measured value in centimetres, and the unit. Move your hand slowly towards the sensor and the printed values fall. As soon as a value drops below 20, the buzzer sounds and keeps sounding; move your hand away and it stops.

Reading the program block by block

The three lines at the top give names to the pins, so that the rest of the program never has to mention a bare number. If you rewire the buzzer to another pin, one line changes instead of several.

setup() runs once when the board is powered. It opens the link to the computer and tells the board which pins are outputs and which is an input. Getting this wrong is the commonest reason a working circuit does nothing at all.

loop() runs over and over, for as long as the board has power. That endless repetition is the feedback loop, and it is why the robot keeps up with a moving hand.

pulseIn() does the timing. It waits for the echo pin to go high, times how long it stays high, and hands back that time in microseconds. Everything after it is arithmetic and a decision.

swapping the trigger and echo pins What goes wrong: The wires are crossed, so the pulse is sent to the pin that should be listening. pulseIn() waits, hears nothing and eventually gives up, so the distance is printed as 0.00 and the buzzer sounds as though something were pressed against the sensor. The fix: Check the sensor’s own markings, not the wire colours. The pin marked Trig must go to the pin named trigPin in the program, and the pin marked Echo to echoPin.

Change limitCm from 20 to 40, upload the program again, and predict before you test it how much earlier the buzzer will start. Then try pointing the sensor at a cushion instead of a book and explain what you see.

An honest limit

This system reports and warns, but it cannot get out of the way, because it has no actuator that moves anything. Replace the buzzer with two motors and a motor driver, and the same six steps become an obstacle-avoiding robot. That is the point of thinking in blocks: the method stays, and only the part filling one block is exchanged.

5.10 Summary

  1. A robot is a system: a set of parts joined so that each does one job and the whole does something no single part could do alone.
  2. The parts of any robot fall into three groups — mechanical components, electronic components and computational components.
  3. A block diagram shows each block as a labelled box, with arrows for the direction in which information travels. It shows the flow of information, not the physical layout.
  4. A task is turned into a target using the robot model. The target is compared with what the robot is actually doing, and the difference is the error signal.
  5. Feedback means sending information about what the robot has actually done back to the part that decides what it should do next. Without feedback a robot acts blindly.
  6. The controller holds the robot’s rules, takes in sensor data, chooses what to do, and sends control signals to the actuators. It can only handle situations someone has already written a rule for.
  7. Actuators convert electrical signals into movement. DC motors are used for wheels; servo motors hold a commanded angle and are used for joints and grippers; pneumatic and hydraulic actuators use compressed air and pressurised oil for greater force.
  8. The manipulator is the robot’s arm, made of rigid links joined at movable joints, with an end-effector such as a gripper or suction cup at its tip.
  9. Sensors measure a physical quantity and turn it into a number. Proximity, tactile, position and vision sensors each report a different kind of fact, and every sensor measures an effect rather than the object itself.
  10. An ultrasonic sensor times the echo of a sound burst. Because the sound travels there and back, the measured time must be halved before it becomes a distance.
  11. The information processing unit cleans up noisy readings, works out what they mean, and plans the robot’s path. More filtering gives a steadier answer but a later one.
  12. Supporting blocks keep the robot working: the power supply, the mechanical structure, the communication interface, the software and the safety systems.
  13. Mechanical components give shape and support, move the robot along the ground, allow parts to move relative to one another, and soften sudden motion.
  14. Electronic components carry and change signals. A motor driver lets a weak control signal switch a large battery current; a relay switches a separate circuit; signal conditioning makes a sensor’s output fit for the controller to read.
  15. Computational components are the stored instructions and methods. An algorithm is a finite set of clear, ordered steps producing a required result from some input.
  16. A real-time operating system is used where a job must run within a fixed time, such as keeping a robot balanced.
  17. Localisation means working out where the robot is; mapping means building a description of the surroundings; doing both at once in an unknown place is simultaneous localisation and mapping.
  18. Robots of very different shapes are built from the same blocks. Wheels, legs, propellers and thrusters are four answers to the question of how to move through a particular place.
  19. A mobile robot is kept low and stable and worries about grip; a humanoid worries about balance; an aerial robot worries about weight; an underwater robot worries about sealing and pressure.
  20. A complete working system can be as small as one sensor, one board and one buzzer, running a loop that measures, decides and acts, over and over.

5.11 Key Terms

  1. Accelerometer: A sensor that measures how quickly the speed of a body is changing, used to detect movement and tilt.
  2. Actuator: A part that converts an electrical signal into mechanical motion.
  3. Algorithm: A finite set of clear, ordered steps that takes some input and produces the required result.
  4. Arduino Uno: An open-source microcontroller board built around the ATmega328P chip, widely used in school robotics.
  5. Block: A group of parts that share one job, treated as a single unit when a system is studied.
  6. Block diagram: A drawing in which each block is a labelled box and arrows show the direction in which information travels.
  7. Caster: A small free-turning wheel that carries no drive and simply supports part of a robot’s weight.
  8. Chassis: The base plate or frame of a robot, to which all other parts are fixed.
  9. Communication interface: The block through which a robot receives instructions and sends information out, by wire or wirelessly.
  10. Computational components: The stored instructions and methods a robot follows, which have no physical form.
  11. Controller: The block that applies the rules stored in its program and sends control signals to the actuators.
  12. Damper: A part that resists quick movement so that motion happens slowly and smoothly.
  13. Direct current (DC) motor: A motor that spins while direct current flows through it, and spins the other way when the connections are reversed.
  14. Electronic components: The parts that carry electrical signals around a robot and change them into a usable form.
  15. Encoder: A sensor fitted to a motor that counts how far its shaft has turned.
  16. End-effector: The tool fitted at the tip of a manipulator, such as a gripper or a suction cup.
  17. Error signal: The difference between what a robot has been asked to do and what it is actually doing.
  18. Feedback: Sending information about what a system has actually done back to the part that decides what it should do next.
  19. Firmware: The program stored inside a microcontroller, which runs every time the board is powered.
  20. Flash memory: Memory that keeps its contents when the power is switched off, used to store a robot’s program.
  21. Gyroscope: A sensor that measures how fast a body is turning.
  22. Hydraulic actuator: An actuator that uses pressurised oil to produce large, closely controlled forces.
  23. Information processing unit: The block that cleans up raw sensor readings, works out what they mean, and plans the robot’s path.
  24. Localisation: Working out where a robot is at the present moment.
  25. Manipulator: The mechanical arm or limb of a robot, made of rigid links joined at movable joints.
  26. Mapping: Building up a description of a robot’s surroundings from its sensor readings.
  27. Mechanical components: The parts that give a robot its shape, hold it together and let it move.
  28. Mechanical structure: The block made up of a robot’s body, frame, brackets and covers, which carries every other block.
  29. Microcontroller: A single chip containing a small processor, memory and input/output pins, which runs a robot’s program.
  30. Motor driver: A circuit that uses a weak control signal to switch a much larger battery current through to a motor.
  31. Noise: Unwanted, meaningless variation in a set of sensor readings.
  32. Operating system: Software that decides which job gets the processor’s attention next and how memory is shared between jobs.
  33. Pan and tilt mechanism: A pair of small joints that together turn a mounted part left and right and tip it up and down.
  34. Path planning: Choosing a route from where a robot is to where it must go, while keeping clear of obstacles.
  35. Pneumatic actuator: An actuator that uses compressed air to push a piston, giving fast straight-line movement.
  36. Power supply: The block that provides electrical energy to every other block of a robot.
  37. Printed circuit board (PCB): A flat board with thin copper lines printed on it, which joins soldered electronic parts together.
  38. Proximity sensor: A sensor that reports that an object is close without needing to touch it.
  39. Real-time operating system (RTOS): An operating system built to guarantee that important jobs run within a fixed time.
  40. Relay: An electrically operated switch in which a small current through a coil closes a separate, larger circuit.
  41. Robot model: A robot’s stored description of itself, used to turn a given task into targets the machine can work with.
  42. Safety systems: The parts and rules that stop a robot quickly and limit what it can do when something goes wrong.
  43. Sensor: A device that measures a physical quantity and converts it into an electrical signal a controller can read as a number.
  44. Servo motor: A motor packed together with gears and a position-measuring part, which turns to a commanded angle and holds it.
  45. Signal conditioning: Circuits that strengthen, smooth or shift a sensor’s output so that a controller can read it correctly.
  46. Suspension system: Springs or sprung arms between a robot’s wheels and its body, which absorb shocks on rough ground.
  47. System: A set of parts joined together, each doing one job, which together do something no single part could do alone.
  48. Tactile sensor: A sensor that responds to contact or pressure, giving a robot a sense of touch.
  49. Tracks: Endless belts running around a set of wheels, which spread a robot’s weight over a longer strip of ground.
  50. Ultrasonic sensor: A sensor that measures distance by sending out a burst of sound above the range of human hearing and timing its echo.

5.12 Objective Questions

  1. Choose the correct option. The block of a robot that converts an electrical signal into mechanical motion is the

    1. sensor
    2. actuator
    3. controller
    4. printed circuit board
  2. Choose the correct option. A caster fitted to a small wheeled robot is used to

    1. drive the robot forward
    2. steer the robot round corners
    3. support the robot’s weight while turning freely
    4. measure how far the robot has travelled
  3. Fill in the blanks.

    1. The difference between the target given to a robot and what it is actually doing is called the ________ .
    2. Unwanted, meaningless variation in a set of sensor readings is called ________ .
  4. State whether each statement is true or false.

    1. A block diagram of a robot shows where each part is physically placed inside it.
    2. A servo motor can be told to turn to a chosen angle and hold that position.
    3. Radio signals travel well through water, which is why underwater robots are controlled by radio.
  5. Match each part in Column A with the job it does in Column B.

    Column A Column B
    a. Encoder i. Switches a large battery current using a weak control signal
    b. Motor driver ii. Slows down quick movement so that motion is smooth
    c. End-effector iii. Counts how far a motor shaft has turned
    d. Damper iv. Touches and holds the object a manipulator works on
  6. An ultrasonic sensor measures an echo time of 1.0 millisecond. Taking the speed of sound in air as 343 m/s, write the distance from the sensor to the object, in centimetres.

  7. In an Arduino program, state in one line what the instruction pinMode(echoPin, INPUT); tells the board to do.

5.13 Concept Questions

  1. Define feedback, and give one example of feedback from a robot described in this chapter.

  2. Give two differences between a DC motor and a servo motor, and state which of the two you would choose for the elbow joint of a robotic arm, with a reason.

  3. A student connects a small geared motor directly to a digital output pin of a microcontroller board and finds that the motor barely turns. Explain what is wrong and what should be used instead.

  4. A robot stands still and its distance sensor sends in five readings, one of which is far larger than the rest. Explain why using the middle reading may be safer than using the average of all five.

  5. What would happen to a robotic arm if the feedback path in its block diagram were broken, while every other block kept working? Explain with an example.

  6. The warning program in this chapter sounds a buzzer when an object is nearer than 20 cm. Write the changed part of that program so that it instead warns when the object is nearer than 15 cm, and also prints the word Warning on the Serial Monitor each time the buzzer is switched on.

5.14 Case-Based Questions

  1. A school library wants a small robot to carry returned books from the issue counter along a straight aisle to the shelving area. The floor is smooth, the aisle is narrow, and students walk through it all day.

    1. Name two kinds of sensor the robot should carry, and say what each one is for in this situation.
    2. Explain why the chassis should be kept low and the battery mounted near the bottom of the robot.
    3. Suggest one safety feature the robot must have, and give the reason for it.
  2. A dairy farm fits an ultrasonic sensor above a cattle water trough, pointing down at the water. The distance from the sensor to the water surface tells the farmer how full the trough is. Five readings taken within one second, while nothing was moving, are given below.

    Reading number Distance (cm)
    1 12.4
    2 12.6
    3 12.5
    4 19.8
    5 12.5
    1. Work out the average of the five readings and also the middle reading, and state which of the two you would use as the trough’s real level, with a reason.
    2. Name the block of the robot system that does this cleaning up of readings before any decision is taken.
    3. The trough is later covered with a floating layer of straw. Explain why the sensor’s readings may become unreliable.