Robotics

Chapter 2
Mathematical and Computational Foundations

Bachelors Program in Machine Technology
Robotics   •   Bachelor

Mathematical and Computational Foundations

Introduction

Robots operate in physical space, but their behaviour is described through mathematical models and computed by digital systems. A robot controller must represent position and orientation, transform measurements between coordinate frames, calculate velocities and forces, solve differential equations, estimate uncertain states, and obtain numerical solutions quickly enough for real-time operation. These tasks depend on a connected set of mathematical ideas rather than on isolated formulas.

This chapter develops the foundations required for robotic modelling and computation. Vectors describe geometric quantities, matrices encode linear operations, coordinate frames establish reference systems, and homogeneous transformations combine rotation and translation. Rotation matrices, Euler angles, and quaternions provide alternative orientation representations. Calculus and differential equations describe motion, while probability supports sensing and estimation. Finally, numerical methods convert continuous mathematical models into algorithms that can run on a computer.

The notation used here is conventional. Vectors are usually column vectors, a superscript identifies the reference frame in which a quantity is expressed, and a transformation from frame B to frame A is written as ^A T_B.

Learning Objectives

By the end of this chapter, a student should be able to:

  1. Use vectors, dot products, cross products, and matrices in robotic calculations.
  2. Construct and interpret coordinate frames and homogeneous transformations.
  3. Compare rotation matrices, Euler angles, axis–angle descriptions, and quaternions.
  4. Relate position, velocity, acceleration, and state-space differential equations.
  5. Apply probability and basic estimation concepts to uncertain robotic measurements.
  6. Select appropriate numerical methods and identify sources of computational error.
  7. Analyse a simple robotic modelling problem from frame definition through numerical implementation.

1. Vectors and Matrices in Robotics

A vector has magnitude and direction. In three-dimensional Cartesian space, a position or displacement vector can be written as

p = [x, y, z]ᵀ

where x, y, and z are components measured in a specified frame, usually in metres. A velocity vector has units of metres per second, and a force vector has units of newtons. The same algebra applies, but physical interpretation and units differ.

The Euclidean norm, or length, of a vector is

||v|| = √(v₁² + v₂² + v₃²)

For a nonzero vector, the corresponding unit vector is v̂ = v/||v||. Normalisation is valid only when ||v|| ≠ 0.

The dot product of vectors a and b is

a · b = a₁b₁ + a₂b₂ + a₃b₃ = ||a||||b||cos θ

where θ is the angle between the vectors. It is useful for projection, angle measurement, and checking perpendicularity. If a · b = 0, the vectors are orthogonal.

The cross product is defined only for three-dimensional vectors:

a × b = [a₂b₃ − a₃b₂, a₃b₁ − a₁b₃, a₁b₂ − a₂b₁]ᵀ

Its direction follows the right-hand rule, and its magnitude is ||a × b|| = ||a||||b||sin θ. In robotics, r × F is the moment produced by force F applied at displacement r from a reference point. The cross product is anti-commutative: a × b = −(b × a).

A matrix is a rectangular array of numbers. Matrix multiplication is defined only when the inner dimensions agree. If A is m × n and B is n × p, then AB is m × p. Matrix multiplication is generally not commutative: AB ≠ BA.

A linear mapping can be written as y = Ax. For example, a 3 × 3 rotation matrix maps coordinates expressed in one orientation into coordinates expressed in another orientation. A square matrix is invertible if it has an inverse A⁻¹ satisfying AA⁻¹ = A⁻¹A = I. Singular matrices have no inverse and often indicate redundant or poorly conditioned calculations.

The transpose of A is Aᵀ. A matrix is orthogonal when RᵀR = I. For a proper three-dimensional rotation, it also satisfies det(R) = +1. Consequently, R⁻¹ = Rᵀ, which is computationally preferable to a general matrix inversion.

Worked Example 1: Projection and Moment

Let a = [3, 4, 0]ᵀ and b = [1, 0, 2]ᵀ. Their dot product is a · b = 3. Since ||b|| = √5, the scalar projection of a onto b is (a · b)/||b|| = 3/√5 ≈ 1.342.

Now let r = [0.2, 0, 0]ᵀ m and F = [0, 10, 0]ᵀ N. The moment is

τ = r × F = [0, 0, 2]ᵀ N·m

The positive z direction follows from the right-hand rule. The units are metres multiplied by newtons, giving newton-metres.

2. Coordinate Frames and Homogeneous Transformations

A coordinate frame consists of an origin and three mutually perpendicular unit axes. Robotic systems commonly use a world or base frame, link frames, a tool frame, and sensor frames. A geometric quantity is not fully specified until its reference frame is known. The same physical point has different numerical coordinates in different frames.

Suppose frame B is rotated and translated relative to frame A. A point with coordinates ^B p can be expressed in frame A by

A p = A RB B p + A pB

Here, ^A R_B is the orientation of B relative to A, and ^A p_B is the position of B's origin expressed in A. The rotation matrix changes orientation; the translation changes origin.

Homogeneous coordinates combine these operations:

A TB = [ A RB A pB
0 0 0 1 ]

A point is augmented as ph = [px, py, pz, 1]ᵀ. Thus,

A ph = A TB B ph

The last coordinate is 1 for a point and 0 for a free vector. This distinction is important: translations affect points but do not affect free vectors such as velocity directions or forces considered independently of their application point.

Transformations compose through matrix multiplication. If frame C is related to B and B to A, then

A TC = A TB B TC

The order must not be changed. The inverse transformation is

A TB⁻¹ = [ (A RB)ᵀ −(A RB)ᵀ A pB
0 0 0 1 ]

This expression assumes that the upper-left block is a valid rotation matrix. It follows from R⁻¹ = Rᵀ.

Worked Example 2: A Planar Transformation

Let frame B be translated 2 m along the x-axis of A and rotated 90° counter-clockwise about the z-axis. The rotation is

Rz(90°) = [0 −1 0
1 0 0
0 0 1]

Therefore,

A TB = [0 −1 0 2
1 0 0 0
0 0 1 0
0 0 0 1]

For a point with coordinates B p = [1, 0, 0]ᵀ m,

A p = Rz(90°)B p + [2, 0, 0]ᵀ = [2, 1, 0]ᵀ m

The point is one metre along B's x-axis, which points along A's y-axis after rotation.

3. Representing Orientation

Rotation Matrices

A rotation matrix R is a 3 × 3 matrix satisfying

RᵀR = I, det(R) = +1

The columns of R are the axes of the rotated frame expressed in the original frame. Rotation matrices avoid singularities and compose efficiently, but they require nine numbers subject to six constraints, so they are redundant for storing three degrees of freedom.

Elementary rotations are

Rx(α) = [1 0 0
0 cos α −sin α
0 sin α cos α]
Ry(β) = [ cos β 0 sin β
0 1 0
−sin β 0 cos β]
Rz(γ) = [cos γ −sin γ 0
sin γ cos γ 0
0 0 1]

Angles must be interpreted in radians when used in most software libraries, unless the library explicitly specifies degrees.

Euler Angles and RPY Angles

An orientation can be represented as a product of three elemental rotations. For example, a fixed-axis XYZ convention may be written R = Rx(α)Ry(β)Rz(γ). Other conventions use intrinsic rotations or a different order. The convention must always be stated because changing the order changes the result.

Euler-angle descriptions are compact and intuitive, but they can suffer from gimbal lock. In a ZYX yaw–pitch–roll convention, pitch near ±90° causes two rotational axes to align, making some orientation changes impossible to represent uniquely using the local angle coordinates.

Axis–Angle Representation

Any proper three-dimensional rotation can be described by a unit axis u and angle θ. Rodrigues' formula is

R = I cos θ + (1 − cos θ)uuᵀ + [u]× sin θ

where [u]× is the skew-symmetric matrix satisfying [u]×v = u × v. This representation is geometrically meaningful and useful for deriving orientation errors.

Quaternions

A unit quaternion may be written q = [w, x, y, z]ᵀ, where w = cos(θ/2) and [x, y, z]ᵀ = u sin(θ/2). A quaternion must satisfy

w² + x² + y² + z² = 1

The associated rotation matrix is

R(q) = [1−2(y²+z²) 2(xy−wz) 2(xz+wy)
2(xy+wz) 1−2(x²+z²) 2(yz−wx)
2(xz−wy) 2(yz+wx) 1−2(x²+y²)]

for a unit quaternion. Quaternions avoid Euler-angle singularities and are efficient for interpolation, but they require normalisation and have a double-cover property: q and −q describe the same physical orientation.

4. Calculus and Robotic Motion

For a time-varying position p(t), velocity and acceleration are derivatives:

v(t) = dp(t)/dt, a(t) = dv(t)/dt = d²p(t)/dt²

Position has units of metres, velocity metres per second, and acceleration metres per second squared. For a joint coordinate q(t), the same relationships apply, but q may be measured in radians or metres depending on the joint type.

The integral reverses differentiation. If velocity is known,

p(t) = p(t₀) + ∫[t₀ to t] v(τ)dτ

where τ is a dummy time variable. Numerical integration accumulates measurement errors and bias, a major issue in inertial navigation.

For a planar revolute joint with link length L and joint angle θ,

x = L cos θ, y = L sin θ

Differentiating gives

[ẋ, ẏ]ᵀ = [−L sin θ, L cos θ]ᵀ θ̇

The matrix multiplying θ̇ is the Jacobian J(θ). In general robotic systems,

ẋ = J(q)q̇

where q is the joint-coordinate vector, x is a task-space coordinate vector, and J maps joint velocities to task-space velocities. The Jacobian depends on configuration and may lose rank at a singularity. Near a singularity, some desired Cartesian velocities require very large joint velocities or cannot be produced.

5. Differential-Equation Models

A differential equation relates a state and its derivatives. A robot's state may include joint positions and velocities:

x = [qᵀ, q̇ᵀ]ᵀ

A general first-order state-space model is

ẋ = f(x, u, t), y = h(x, u, t)

where x is the state, u is the input, y is the measured output, and f and h are model functions. For a linear time-invariant approximation,

ẋ = Ax + Bu, y = Cx + Du

The matrices A, B, C, and D must have compatible dimensions. This model is local or exact only when the physical system is linear in the selected variables.

A basic joint model with inertia J_m, viscous coefficient b, applied torque τ, and angular position θ is

Jm θ̈ + b θ̇ = τ

This neglects friction nonlinearities, flexibility, gravity, and load variation. Such assumptions must be checked before using the model for design.

6. Probability, Uncertainty, and Estimation

Robotic sensors are affected by noise, calibration errors, quantisation, latency, and environmental interference. Probability provides a language for representing uncertainty. A random variable X has mean

μ = E[X]

and variance

σ² = E[(X − μ)²]

The standard deviation σ has the same units as X, whereas variance has squared units. Covariance between X and Y is

Cov(X,Y) = E[(X−μX)(Y−μY)]

For a vector x, uncertainty is represented by a covariance matrix Σ. Diagonal elements are component variances; off-diagonal elements indicate correlation. A covariance matrix must be symmetric and positive semidefinite.

A Gaussian distribution is commonly written X ~ N(μ, σ²). Approximately 68%, 95%, and 99.7% of observations lie within one, two, and three standard deviations of the mean, respectively, when the Gaussian model is appropriate. These percentages are not universal laws and should not be applied to strongly non-Gaussian data.

For independent random variables X and Y,

E[X + Y] = E[X] + E[Y]

and variances add only under independence:

Var(X + Y) = Var(X) + Var(Y)

With correlation, covariance terms must be included.

A simple weighted fusion of a prior estimate x̂ with variance P and a measurement z with variance R is

x̂new = (R/(P+R))x̂ + (P/(P+R))z

assuming unbiased, independent scalar Gaussian uncertainties and P + R > 0. The estimate gives greater weight to the quantity with smaller variance. This is the scalar form of a Bayesian measurement update and illustrates the principle behind Kalman filtering.

7. Numerical Methods for Robotic Computation

Computers approximate continuous mathematics using finite precision and discrete time. Three important error categories are modelling error, truncation error, and round-off error. Modelling error comes from simplifying physics; truncation error comes from approximating a mathematical operation; round-off error comes from finite numerical representation.

For a time step Δt, forward Euler integration approximates

xk+1 = xk + Δt f(xk, uk, tk)

It is simple and inexpensive, but its accuracy is first order: reducing Δt generally reduces local approximation error, though computational cost increases. Euler integration can become unstable for stiff or rapidly changing systems.

For a scalar differential equation ẋ = λx, the exact solution is x(t) = x(0)eλt. Euler produces xk+1 = (1 + λΔt)xk. Stability requires the numerical multiplier to remain within the unit circle; for real negative λ, this means |1 + λΔt| < 1, or 0 < Δt < 2/|λ|. This condition concerns numerical stability, not merely accuracy.

The central-difference approximation for a derivative is

f′(t) ≈ [f(t+Δt) − f(t−Δt)]/(2Δt)

It is generally more accurate than a one-sided difference for smooth functions, but it requires data on both sides of the evaluation point and can amplify measurement noise.

The Newton–Raphson method solves g(x) = 0 iteratively:

xk+1 = xk − g(xk)/g′(xk)

It requires a differentiable function and a nonzero derivative near the iterate. Convergence is not guaranteed from an arbitrary starting value; poor initialisation can lead to divergence or convergence to an undesired root.

For linear systems, direct methods such as Gaussian elimination are appropriate for moderate, well-conditioned problems. Iterative methods may be preferable for large sparse systems. Conditioning measures how sensitive a solution is to perturbations in the input. A mathematically correct algorithm can still produce unreliable results when the problem is ill-conditioned.

Best Practices in Computational Robotics

Use SI units consistently, document frame conventions, test transformations with known cases, normalise quaternions, monitor matrix orthogonality, choose time steps based on the fastest relevant dynamics, and distinguish sensor noise from model error. Numerical simulations should be validated against analytical special cases or experimental data. Software should include dimensional checks, bounds checking, logging, and reproducible test cases.

8. Integrated Applied Case: Visual Servoing of a Two-Link Arm

The following is an illustrative case rather than a report of a particular commercial system.

Background and Problem

A two-link planar robot must move its camera-mounted end-effector to a visual target. The links have lengths L₁ = 0.50 m and L₂ = 0.40 m. Joint angles are q₁ and q₂, measured counter-clockwise from the positive x-axis for the first link and relative to the first link for the second link. A camera estimates the target position, but its measurements contain uncertainty.

The objective is to compute the end-effector position, determine joint velocities that reduce the position error, and update the target estimate as new images arrive.

Kinematic Analysis

The forward position model is

x = L₁ cos q₁ + L₂ cos(q₁+q₂)
y = L₁ sin q₁ + L₂ sin(q₁+q₂)

The Jacobian is

J(q) = [−L₁sin q₁ − L₂sin(q₁+q₂) −L₂sin(q₁+q₂)
L₁cos q₁ + L₂cos(q₁+q₂) L₂cos(q₁+q₂)]

Suppose q₁ = 30° and q₂ = 60°. Then q₁ + q₂ = 90°, giving

x = 0.50cos30° + 0.40cos90° ≈ 0.433 m,

y = 0.50sin30° + 0.40sin90° = 0.650 m.

The target is measured at xd = 0.50 m and yd = 0.60 m, so the error is e = [0.067, −0.050]ᵀ m, approximately.

A proportional task-space controller may specify

ẋcmd = K e

where K is a positive diagonal gain matrix with units s⁻¹. To obtain joint velocity, one may solve Jq̇ = ẋcmd. If J is square and nonsingular, q̇ = J⁻¹ẋcmd. Near singularities, a damped least-squares solution is safer:

q̇ = Jᵀ(JJᵀ + λ²I)⁻¹ẋcmd

where λ > 0 is a damping parameter. This formula produces an approximate solution and limits excessive velocities near rank loss; λ must be selected in relation to units, velocity limits, and desired tracking accuracy.

Probabilistic Measurement Update

Assume the camera's scalar x-coordinate estimate has variance R = 0.0009 m², while the prior estimate has variance P = 0.0025 m². With prior estimate x̂ = 0.48 m and measurement z = 0.50 m,

x̂new = (0.0009/0.0034)(0.48) + (0.0025/0.0034)(0.50)
≈ 0.4947 m

The measurement receives more weight because its variance is smaller. A complete implementation would update both coordinates and their covariance, account for camera calibration, and reject measurements inconsistent with physical limits.

Outcome and Learning Points

The case links frames, trigonometry, matrices, Jacobians, control-oriented differential relationships, probability, and numerical computation. It also shows why a mathematically valid formula is not sufficient by itself. Frame conventions, singularity handling, sensor uncertainty, actuator limits, sampling time, and validation determine whether the computation is safe and useful.

9. Limitations, Safety, and Contemporary Practice

Mathematical models are abstractions. Rigid-link models omit compliance; ideal sensors omit bias and latency; Gaussian assumptions may fail during occlusion or contact; and numerical solutions may become unstable when sampling is too slow. A responsible robotic system therefore quantifies uncertainty, detects invalid states, limits commanded velocities and forces, and uses independent safety mechanisms where failure could harm people.

Modern robotics increasingly combines geometric models with data-driven methods. Machine-learning systems can estimate perception features or compensate for unmodelled dynamics, but they do not eliminate the need for coordinate consistency, physical constraints, uncertainty analysis, and verification. Training data may be biased, and a model that performs well in one environment may fail under changed lighting, objects, or calibration. Human oversight, traceable software versions, access control, and audit logs are important governance practices for deployed systems.

Contemporary implementations commonly use automatic differentiation, sparse linear algebra, Lie-group methods for rigid-body motion, and probabilistic filters such as the extended Kalman filter and factor-graph optimisation. These tools extend the foundations presented here; they do not replace the underlying requirements of correct modelling and numerical validation.

Chapter Summary

Robotic computation begins with vectors, matrices, and clearly defined coordinate frames. Dot and cross products support geometric reasoning, while matrix multiplication represents linear mappings and frame changes. Homogeneous transformations combine rotation and translation and compose through ordered matrix multiplication.

Orientation may be represented by rotation matrices, Euler angles, axis–angle parameters, or unit quaternions. Each has benefits and limitations: matrices are robust but redundant, Euler angles are intuitive but may have singularities, axis–angle coordinates are geometric, and quaternions are compact and avoid gimbal lock but require normalisation.

Calculus relates position, velocity, and acceleration. Differential equations and state-space models describe robot dynamics and support simulation and control. Probability represents sensor uncertainty through means, variances, covariances, and distributions. Numerical methods, including Euler integration, finite differences, Newton–Raphson iteration, and linear-system solvers, make models computationally usable but introduce stability, conditioning, truncation, and round-off considerations.

A professional roboticist must therefore treat equations, units, frames, assumptions, uncertainty, and software implementation as one integrated modelling problem.

Key Terms

Vector: A quantity with magnitude, direction, and components expressed in a reference frame.

Dot product: A scalar product used for projection and angle relationships.

Cross product: A three-dimensional vector product used for moments and perpendicular directions.

Matrix: A rectangular array representing numbers or a linear mapping.

Rotation matrix: An orthogonal 3 × 3 matrix with determinant +1 representing orientation.

Coordinate frame: An origin and an oriented set of basis axes.

Homogeneous transformation: A 4 × 4 matrix combining rotation and translation.

Pose: The position and orientation of a rigid body.

Euler angles: Three sequential angles used to parameterise orientation.

Quaternion: A four-parameter orientation representation constrained to unit norm.

Axis–angle: An orientation described by a rotation axis and rotation angle.

Jacobian: A matrix mapping joint velocities to task-space velocities.

Singularity: A configuration where a Jacobian loses rank or motion capability.

State: The variables required, with inputs, to describe system evolution.

Covariance: A measure of joint uncertainty and correlation.

Gaussian distribution: A probability model characterised by mean and variance in the scalar case.

Truncation error: Error caused by replacing an exact mathematical operation with an approximation.

Conditioning: Sensitivity of a problem's solution to perturbations in its data.

Damped least squares: A regularised method for solving near-singular inverse-kinematic problems.

Review Questions

Short Answer Questions

  1. Why must a vector's reference frame be specified in a robotic calculation?
  2. State the defining properties of a proper three-dimensional rotation matrix.
  3. What is the difference between a point and a free vector in homogeneous coordinates?
  4. What physical quantities are related by the Jacobian equation ẋ = Jq̇?
  5. Why can a numerical integration method become unstable even when the physical system is stable?

Long Answer Questions

  1. Explain how homogeneous transformations are constructed, composed, and inverted. Include the assumptions required for the inverse formula.
  2. Compare rotation matrices, Euler angles, axis–angle representations, and quaternions for robotic orientation computation.
  3. Derive the Jacobian of a two-link planar manipulator from its forward-kinematic equations.
  4. Explain how mean, variance, and covariance represent uncertainty in a robot sensor measurement.
  5. Discuss modelling error, truncation error, round-off error, and conditioning in robotic computation.

Analytical / Application Questions

  1. A planar link of length 0.8 m is at 45° and rotates at 2 rad/s. Derive and calculate the Cartesian velocity of its endpoint.
  2. A frame is translated by [0.3, 0.2, 0]ᵀ m and rotated 90° about z. Construct its homogeneous transformation and transform the local point [0.1, 0, 0, 1]ᵀ.
  3. For the scalar system ẋ = −5x, determine the forward-Euler step-size condition for numerical stability and explain the practical implication of selecting a step near the limit.

Multiple Choice Questions with Answers

Question 1

Which condition identifies a proper three-dimensional rotation matrix?

A. RᵀR = 0 and det(R) = 0

B. RᵀR = I and det(R) = +1

C. RᵀR = R and det(R) = −1

D. R² = I and det(R) = +1

Correct Answer: B. RᵀR = I and det(R) = +1

Question 2

A force of 10 N acts along y at a point 0.2 m along x from the origin. What moment is produced about the origin?

A. 2 N·m along +z

B. 2 N·m along −z

C. 50 N·m along +z

D. 0 N·m

Correct Answer: A. 2 N·m along +z

Question 3

In a homogeneous transformation, what does the last coordinate 1 represent for a point?

A. The point has zero mass

B. The point is expressed in radians

C. The point is affected by translation

D. The point lies on the z-axis

Correct Answer: C. The point is affected by translation

Question 4

Which orientation representation is specifically associated with gimbal lock?

A. Rotation matrices

B. Unit quaternions

C. Euler angles

D. Homogeneous coordinates

Correct Answer: C. Euler angles

Question 5

For ẋ = λx with real negative λ, forward Euler is stable under which condition?

A. Δt > 2/|λ|

B. Δt = 0 only

C. 0 < Δt < 2/|λ|

D. Δt < −2/|λ|

Correct Answer: C. 0 < Δt < 2/|λ|

Question 6

What does a covariance matrix's diagonal contain?

A. Component variances

B. Rotation angles only

C. Frame translations only

D. Control gains

Correct Answer: A. Component variances

Question 7

If two vectors have a zero dot product, what can be concluded?

A. They are parallel

B. They are orthogonal, provided both are valid Euclidean vectors

C. They have equal magnitudes

D. Their cross product is zero

Correct Answer: B. They are orthogonal, provided both are valid Euclidean vectors

Question 8

What is the main purpose of damping in a damped least-squares Jacobian solution?

A. To increase sensor noise

B. To remove all translation

C. To limit excessive joint velocities near singularities

D. To convert degrees to radians

Correct Answer: C. To limit excessive joint velocities near singularities

Question 9

A unit quaternion representing a rotation must satisfy which condition?

A. w + x + y + z = 0

B. w² + x² + y² + z² = 1

C. w² + x² + y² + z² = −1

D. w = x = y = z

Correct Answer: B. w² + x² + y² + z² = 1

Question 10

Which operation generally requires compatible inner matrix dimensions?

A. Matrix multiplication

B. Vector normalisation

C. Taking a transpose

D. Computing a scalar norm

Correct Answer: A. Matrix multiplication

Robotics
Chapter 2 of 15