0%

Chapter 1 · Section 4 of 4

The map of techniques

25 min read4 of 45 in Programming Techniques
On this page

This book describes 34 programming techniques, and they have different names, take in different things and give back different answers. This page is the map of all of them, because it sorts them into seven kinds, which this book calls categories. For each category it then says what the techniques do and where to read about them.

It answers three questions. What are the seven categories, and which techniques are in each? Where does each category do its job when one robot arm does one task? And in what order should you read the chapters of this book?

It is for a reader who has read the earlier pages of this chapter, especially programmed, not learned. You can also come back to it at any time, when you want to see where one technique fits among the others. Book 6 has a page with the same shape for learned models, the map of models.

Contents#

  1. One task, seven kinds of technique
  2. The seven categories · Geometry and cameras · Searching and matching · Fitting and estimation · Image and point cloud processing · Planning and search · Control and motion · Decisions and task logic
  3. All 34 techniques in one table
  4. When each kind does its job
  5. How the categories connect
  6. Find a method by job
  7. A suggested reading order
  8. Where to read next
  9. Using it in Python

1. One task, seven kinds of technique#

The easiest way to see all seven categories is to follow one task from start to finish. A robot arm has a camera on its wrist, and there are three mugs on a table with a rack of pegs at one end. The task is to find the mugs with the wrist camera and hang each one on the rack.

To do this, the robot must do several separate things. It must turn what the camera sees into positions measured from its own base, and it must pick the mug pixels out of the picture and ignore the table. It must find the table top and keep each mug's position steady while the camera moves, and then decide which mug is which from one picture to the next. After that it must find a path to each mug and on to the rack that hits nothing, and drive its motors smoothly along that path. Finally it must keep track of the whole job: which mug is next, and what to do if a grasp fails.

Each of these jobs is done by a different kind of technique, and those kinds are the seven categories.

A robot arm with a wrist camera above three mugs and beside a rack, with seven numbered markers and a legend naming each category of technique
A robot arm with a wrist camera above three mugs and beside a rack, with seven numbered markers and a legend naming each category of technique

The picture shows the task with the seven categories numbered; each number sits next to the part of the scene that its techniques work on: the camera, the mugs, the table top, the mug pixels, the path to the rack, the joints and the task list.

A real arm does not always use every technique in this book, and a simple pick-and-place arm may use only six or seven of them. However, almost every arm task uses at least one technique from each of the seven categories.


2. The seven categories#

Section 1 numbered the seven categories on the picture, so this section describes each of them in turn. Each category below has one paragraph that says what its techniques do, followed by a link to the chapter overview, which explains each technique in one line and compares them.

Inside each chapter, the technique pages are split into two groups. The most used group holds the techniques that nearly every arm program needs, or that matter most when they go wrong. However, the also used group holds techniques that are used often, but only for some tasks or some kinds of arm. So read the most used group of a chapter first, and each paragraph below names the most used techniques first and then the also used ones.

Geometry and cameras#

Geometry and cameras turn pixels, frames and joint angles into positions you can trust, and four of these techniques are most used. The pinhole camera model says which pixel a point in space lands on, and turns a pixel and its depth back into a point. Rigid transforms move a position from one frame to another, such as from the camera to the arm's base. Calibration measures the numbers that the other two need: the camera's own settings, and where the camera sits on the arm. Pose from points finds where a known object sits from a few of its points seen in one picture, a problem called perspective-n-point (PnP). One technique is also used: multi-view geometry combines pictures taken from different places to find where points are in space. So in the mug task, these techniques turn each mug's pixels into a position the arm can reach. Read the geometry and cameras overview.

Searching and matching#

Searching and matching find the closest thing, and decide which thing is which, and three of these techniques are most used. Nearest-neighbour search finds the point or object closest to a given one, as in the closest-mug example on the first page. Iterative closest point lines up two sets of points, such as a stored 3D model of a mug and a fresh scan. Assignment and matching pairs up two lists, such as the mugs seen in this picture and the mugs seen in the last one. One technique is also used: image features and matching finds the same small spots in two pictures and pairs them up. So in the mug task, these techniques make sure that "mug 2" in one picture is still "mug 2" in the next. Read the searching and matching overview.

Fitting and estimation#

Fitting and estimation get a clean shape or a steady number out of noisy measurements, and four of these techniques are most used. Least-squares fitting finds the line, plane or circle that is closest to many points. Random sample consensus (RANSAC) does the same while ignoring points that are plainly wrong. The Kalman filter combines each new reading with what it already knew, to give a steady estimate of something that may be moving. Sensor streams covers how to handle readings that arrive one after another from many sensors, at different rates and times. One technique is also used: system identification measures the numbers inside a physical model of the arm, such as a joint's friction or the mass in the gripper. So in the mug task, RANSAC finds the table top, and a Kalman filter keeps each mug's position steady as the camera moves. Read the fitting and estimation overview.

Image and point cloud processing#

Image and point cloud processing clean up and cut up pictures and point clouds so objects stand out, and three of these techniques are most used. Thresholding and colour masks keep the pixels whose colour or depth is in a chosen range. Morphology and the distance transform tidy up those pixels, and find the point most central in a shape. Clustering groups nearby points into separate objects. Two techniques are also used, and the first of them, edges and contours, finds the outline of each shape. The second, volumetric maps, divides the space around the arm into small cubes and records which ones are full, empty or not yet seen. So in the mug task, a depth threshold removes the table, and clustering splits the remaining points into one group per mug. Read the image and point cloud processing overview.

Planning and search find a way for the arm to get from here to there without hitting anything, and three of these techniques are most used. Sampling-based planning tries random arm poses and joins the safe ones into a path. Numerical inverse kinematics finds the joint angles that put the gripper at a chosen pose. Trajectory optimisation takes a path and makes it shorter, smoother and further from obstacles. Three techniques are also used, and the first of them, graph search, finds the shortest route through a grid or a graph of poses. Sampling-based optimisation and model predictive control (MPC) tries many random plans, keeps the best, and plans again a moment later from where the arm now is. Visibility and next best view works out what a camera can see from a pose, and chooses where to look next. So in the mug task, inverse kinematics turns "gripper above mug 2" into joint angles, and a planner finds a path to the rack that does not hit the rack itself. Read the planning and search overview.

Control and motion#

Control and motion turn a planned path into smooth, safe motor commands, and four of these techniques are most used. Proportional-integral-derivative (PID) control makes each joint follow its target angle, many times a second. Trajectory generation decides how fast to move along the path at each moment, so the arm starts and stops smoothly. Arm dynamics works out the torque each joint needs to hold the arm up and to speed it up, so the controller does not have to wait for an error. Safety monitoring checks the arm's limits in software and stops it when one is broken or a person comes too close. One technique is also used: impedance and force control makes the arm give way when it touches something, and stop if it pushes too hard. So in the mug task, these techniques move the arm to each mug, and let it feel the peg when it hangs the mug on the rack. Read the control and motion overview.

Decisions and task logic#

Decisions and task logic decide what the robot does next, and in what order, and two of these techniques are most used. A finite state machine moves the robot from one named step to the next, such as "looking", "picking" and "hanging". A behaviour tree arranges the steps as a tree, which makes it easier to add retries and fallbacks. Two techniques are also used, and the first of them, greedy algorithms and set cover, makes a good choice quickly by taking the best-looking option at each step. Optimisation solvers find the best order or assignment when the greedy choice is not good enough. So in the mug task, a state machine runs the job, and a greedy rule picks the closest mug next. Read the decisions and task logic overview.


3. All 34 techniques in one table#

Section 2 described the categories one at a time, and the table below now gathers every technique page in the book into one place, in the order of the chapters. Read each row across: the category, the technique, whether it is in the chapter's most used or also used group, what it does in one line, and what it does in the mug task. The technique names are links to their pages.

CategoryTechniqueGroupWhat it doesIn the mug task
Geometry and camerasPinhole camera modelmost usedturns a point into a pixel, and a pixel plus its depth into a pointturns a mug's centre pixel and depth into a 3D point
Geometry and camerasRigid transformsmost usedmoves a position from one frame to anotherturns the mug's camera position into a base position
Geometry and camerasCalibrationmost usedmeasures the camera's settings and where it sits on the armdone once, before the task, so the first two are right
Geometry and camerasPose from pointsmost usedfinds a known object's pose from a few of its points in one picture (PnP)finds the rack's pose from the corners of a marker on it
Geometry and camerasMulti-view geometryalso usedfinds points in space from pictures taken from different placesfinds the depth of a mug's rim from two wrist-camera views
Searching and matchingNearest-neighbour searchmost usedfinds the closest point or objectfinds which mug is closest to the gripper
Searching and matchingIterative closest pointmost usedlines up two sets of pointslines up a stored mug model with the scan to find the handle
Searching and matchingAssignment and matchingmost usedpairs up two lists at the lowest total costmatches each mug in this picture to one in the last picture
Searching and matchingImage features and matchingalso usedfinds the same small spots in two pictures and pairs themfinds a printed label on the rack in a new picture
Fitting and estimationLeast-squares fittingmost usedfinds the line, plane or circle closest to many pointsfits a circle to a mug's rim to find its centre
Fitting and estimationRANSACmost usedfits a shape while ignoring wrong pointsfinds the table top, with the mugs ignored
Fitting and estimationKalman filtermost usedcombines each new reading with what it knewkeeps each mug's position steady as the camera moves
Fitting and estimationSensor streamsmost usedhandles readings that arrive at different rates and timespairs each camera picture with the joint angles at the moment it was taken
Fitting and estimationSystem identificationalso usedmeasures the numbers inside a physical model of the armmeasures the mass of a full mug from the joint torques
Image and point cloud processingThresholding and colour masksmost usedkeeps pixels in a chosen colour or depth rangekeeps the pixels closer than the table
Image and point cloud processingMorphology and distance transformmost usedtidies a mask, and finds its most central pointremoves speckles from the mug mask
Image and point cloud processingClusteringmost usedgroups nearby points into objectssplits the points above the table into three mugs
Image and point cloud processingEdges and contoursalso usedfinds outlines and their shapestraces the outline of each mug in the picture
Image and point cloud processingVolumetric mapsalso usedrecords which small cubes of space are full, empty or unseenmarks the space around the rack as full, for the planner
Planning and searchSampling-based planningmost usedtries random poses and joins the safe onesfinds a path round the rack
Planning and searchNumerical inverse kinematicsmost usedfinds joint angles for a gripper posefinds the joint angles for "gripper above mug 2"
Planning and searchTrajectory optimisationmost usedmakes a path shorter, smoother and safersmooths the path from the mug to the peg
Planning and searchGraph searchalso usedfinds the shortest route through a graph or gridfinds a route between stored safe poses
Planning and searchSampling-based optimisation and MPCalso usedtries many random plans, keeps the best, and plans again as the arm movesadjusts the reach while the mug is still sliding
Planning and searchVisibility and next best viewalso usedworks out what a camera sees from a pose, and where to look nextchooses a second view that shows the handle hidden behind a mug
Control and motionPID controlmost usedmakes a joint follow its targetholds each joint on its planned angle
Control and motionTrajectory generationmost useddecides the speed along a path at each momentstarts and stops the arm smoothly with a full mug
Control and motionArm dynamicsmost usedworks out the torque each joint needs for a motionadds the full mug's weight to the torques so the arm does not sag
Control and motionSafety monitoringmost usedchecks limits in software, and stops or slows the armslows the arm when a person reaches for a mug
Control and motionImpedance and force controlalso usedmakes the arm give way on contact, and limits forcefeels the peg and stops pushing
Decisions and task logicFinite state machinesmost usedmoves between named stepsruns look, pick, hang, next mug
Decisions and task logicBehaviour treesmost usedarranges steps as a tree with fallbackstries a second grasp if the first one slips
Decisions and task logicGreedy algorithms and set coveralso usedtakes the best-looking option at each steppicks the closest mug next; picks the fewest camera views that see every mug
Decisions and task logicOptimisation solversalso usedfinds the best order or assignmentchooses which peg each mug goes on

So of the 34 pages, 23 are in a most used group and 11 are in an also used group.

A few of these do the same job in two ways. For example, finite state machines and behaviour trees both run the task, least squares and RANSAC both fit shapes, and graph search and sampling-based planning both find paths. So the choosing a technique page explains how to pick between them, and each technique page compares itself with its neighbour.


4. When each kind does its job#

The map picture in section 1 shows where each category works, but it is also useful to see when each one works. So the task for one mug can be split into seven steps: look from above, find the mugs, choose the next mug, plan the reach, reach and grasp, carry the mug to the rack, and hang it and let go.

A timeline of seven steps for one mug, with a coloured bar for each category showing the steps in which it is busy
A timeline of seven steps for one mug, with a coloured bar for each category showing the steps in which it is busy

Each coloured bar shows the steps during which one category is busy; decisions and task logic run for the whole task, perception techniques are busy at the start, and control is busy from the reach to the end.

Read the picture from left to right. At the start, image and point cloud processing and geometry turn the camera's pictures into mug positions. Fitting and searching then tidy those positions and match them to the mugs seen before, and planning works out the reach. After that, control drives the arm for the rest of the task. Geometry and fitting come back during the grasp, because the camera takes a closer look as the gripper comes down. Decisions and task logic run from start to finish, because they decide when every other step begins.

This is one way to build the task, not the only one. For example, a task where the mugs are always in the same place would not need the perception bars at all. However, a task where the arm must avoid people would have planning running during the carry as well.


5. How the categories connect#

Section 4 showed when each category is busy, and this section shows how they hand work to each other. The seven categories are separate chapters, but the techniques in them depend on each other, because the output of one is very often the input of the next.

First a threshold and clustering cut the mugs out of the depth picture, and then the pinhole camera model turns each mug's pixels into points. A rigid transform moves those points into the base frame, and RANSAC and least squares fit the table and the mug's rim. Nearest-neighbour search and assignment then keep track of which mug is which, so that a greedy rule can choose the next mug. After that, inverse kinematics and a planner find the joint angles and the path. Then trajectory generation and PID control drive the motors, with arm dynamics supplying most of the torque and safety monitoring watching every command. A state machine or behaviour tree runs all of it in order, and this chain, from picture to motors, is the most common way to build a programmed picking robot.

Many of the categories also share the building blocks from the building blocks. Planning and decisions both use graphs, while fitting, planning and optimisation solvers all minimise a cost function, and geometry and planning both use transforms. So once you know one chapter, the next one is easier.

The categories also connect to Book 6, because some steps in the chain are often done by a learned model instead of a written technique. The table below shows the most common swaps, so read each row as one job: the written technique in this book, and the kind of learned model that can replace it.

JobWritten technique (this book)Learned model (Book 6)
cut the objects out of the picturethresholding, clusteringsegmentation
find where objects areedges and contoursobject detection
follow objects between picturesassignment and matching, Kalman filtertracking and motion
find an object's poseiterative closest pointkeypoints and object pose
find a pathsampling-based planninglearned motion planners
work out the torque the joints needarm dynamicslearned arm models
decide the steps of a taskbehaviour treeslanguage models as planners

Even when a learned model takes over one job, the written techniques around it usually stay. For example, a detection model gives only a box in the picture, so the pinhole camera model and a rigid transform still have to turn that box into a position the arm can reach.


6. Find a method by job#

Most people come to these books with a job in mind rather than a method, so this section starts from the job instead of the technique. Read each row across: a job the arm must do, the Book 2 or Book 3 page that helps you choose how to do it, the written techniques in this book that can do it, and the learned models in Learned Models that can do it.

Job on the armBook 2 or 3 page that helps chooseWritten technique, in this bookLearned model, in Learned Models
find an object in a pictureobject perception (Book 2)thresholding and colour masks, clustering, edges and contoursobject detection, segmentation, open-vocabulary models
turn a pixel into a position the arm can reachframes and conventionspinhole camera model, rigid transforms, calibrationdepth from pictures
measure an object's posemodels that measure (Book 2)pose from points, iterative closest pointkeypoints and object pose, point cloud models
build a 3D map of the space round the armthe planning scenevolumetric maps, multi-view geometryscene reconstruction, shape completion, 3D feature maps
track an object over timetracking and association (Book 2)Kalman filter, assignment and matching, sensor streamstracking and motion
choose a graspchoosing a grip, models that graspmorphology and distance transform, least-squares fittingsix-DoF grasps, suction and affordance, grasp quality models, linear and logistic regression, decision trees and forests
check the arm can reach a posereaching and reachabilitynumerical inverse kinematicsnone in common use
plan a motion that hits nothingplanning a pathsampling-based planning, trajectory optimisation, graph searchlearned motion planners
correct a sensor's readingssensors (Book 2)calibration, least-squares fittinglinear and logistic regression, Gaussian processes and Bayesian optimisation
control the joints along the plancontrolling the movetrajectory generation, PID control, arm dynamicslearned arm models, Gaussian processes and Bayesian optimisation, nearest neighbours and locally weighted regression
tune a controller's gains or a grip forcecontrolling the movePID control, sampling-based optimisation and MPCBayesian optimisation
go straight from what the camera sees to a movementlearned motionsampling-based optimisation and MPCbehaviour cloning, diffusion and flow policies, reinforcement learning policies
learn a motion from a few demonstrationslearned motiontrajectory generationmovement primitives, mixture models and hidden Markov models, behaviour cloning
react to contact and forceholding onimpedance and force controlforce and slip models, touch sensing models, mixture models and hidden Markov models, support vector machines
notice a collision and stopwhat "the move failed" actually meanssafety monitoringcollision and failure detection, decision trees and forests
decide the next stepscripted logicfinite state machines, behaviour treeslanguage models as planners
choose the order to deal with objectsordering and rearrangementgreedy algorithms and set cover, optimisation solverslanguage models as planners
follow an instruction in wordsdirected by languagenone: a written program only accepts commands it was given in a fixed formvision-language-action models, vision-language models
predict what happens nextlearned world modelsarm dynamics, system identificationlearned dynamics models, video prediction models, learned simulators
check that the task workedjudging whether it worksbehaviour trees, thresholding and colour masksvision-language models, reward and progress models

Most jobs have both a written and a learned answer, and the Book 2 or Book 3 page says which one suits which case. However, two rows have only one side. No learned model is in common use to check whether the arm can reach a pose, because inverse kinematics already gives an exact answer quickly. And no written technique can follow an instruction in free wording, because a person can say the same thing in too many ways to list them all. Many real arms therefore mix the two sides, so that a learned model finds the object and written techniques do the rest.

The learned column also includes the methods of Book 7's classical machine learning chapter, which are not neural networks. They appear in the rows where the input is only a few measured numbers: correcting a sensor, tuning a controller's gains, learning a motion from a few demonstrations, and scoring grasps or spotting faults from logged numbers.


7. A suggested reading order#

Section 6 lets you jump to a technique by job, but if you want to read the book through, the chapters are numbered in the order this book suggests. Read them from 01 to 08, which is the same order as the folders. Each chapter explains its own terms, so you can also start anywhere, and the list below gives the reason for each step.

  1. This chapter, starting with programmed, not learned. Everything else uses its words: technique, parameter, frame, graph, noise, cost and loop.
  2. Geometry and cameras. Every other chapter needs positions in the right frame.
  3. Searching and matching. It finds the closest thing and decides which thing is which.
  4. Fitting and estimation. It turns noisy pixels and points into clean shapes and steady numbers.
  5. Image and point cloud processing. It cuts the objects out of a picture or a point cloud.
  6. Planning and search. It needs positions and shapes from the chapters before it.
  7. Control and motion. It carries out what the planner decided.
  8. Decisions and task logic. It ties all the others together into a whole task.

Chapters 03, 04 and 05 lean on each other, so you can read those three in any order, because each one uses a little of the other two. For example, clustering in chapter 05 uses the nearest-neighbour search from chapter 03, while RANSAC in chapter 04 is often run on the points that chapter 05 cut out. And the matching in chapter 03 often works on positions that a Kalman filter from chapter 04 has made steady. So whichever of the three you read first, the other two will be easier after it.

So if you have one job in mind, you can jump straight to its chapter. For example, if you only want the arm to move smoothly to a known pose, read planning and search, and then control and motion.



9. Using it in Python#

Section 3 listed all 34 techniques in one table and section 6 lets you find one by the job you have. This section adds the practical layer under both of them, which is the library you would actually import for each of the seven categories. After reading it you should be able to look at a job on your arm and know which package to install first.

Each line below is the usual starting point for one category in Python, and the whole block is a real set of imports rather than a picture of one.

import cv2                                       # geometry and cameras: cv2.solvePnP
from scipy.spatial import KDTree                 # searching and matching: tree.query
from scipy.optimize import least_squares         # fitting and estimation: a robust fit
import open3d as o3d                             # image and point cloud processing
from moveit.planning import MoveItPy             # planning and search, through ROS 2
from ruckig import Ruckig, InputParameter, OutputParameter   # control and motion
import py_trees                                  # decisions and task logic

Those seven cover the mug task from section 1 almost completely. OpenCV and Open3D turn the wrist camera's pictures into mug positions, SciPy's KDTree and least_squares tidy those positions and match each mug to the mug seen in the last picture, MoveItPy plans a reach that hits nothing, Ruckig turns the plan into joint commands that respect the arm's speed and acceleration limits, and py_trees holds the order of the whole job. Book 3's tools and libraries shows working code for MoveItPy and py_trees on a six-joint arm.

What the libraries do for you is the hard arithmetic inside each technique, which is why this book explains the steps rather than asking you to write them. What you write yourself is everything between the seven lines: the code that carries numbers from one library to the next in the right frame and the right unit, and the code that decides what to do when a step returns nothing. That glue is usually larger than all seven calls together, and it is where the bugs live, because no library checks that the pose you hand to MoveItPy is measured from the base rather than from the camera.

What you have to decide first is which of the seven you need at all. As section 1 said, a simple pick-and-place arm uses only six or seven of the 34 techniques, so importing all seven libraries into one program before you need them buys you trouble. It is real trouble, too, because these packages do not arrive together: MoveItPy and Ruckig come with a ROS 2 installation, while OpenCV and Open3D come from pip or conda, and two of them in one Python process can insist on different versions of NumPy. Adding one library at a time, and checking the arm still runs after each one, is slower to start and much faster to finish.