Skip to content
SDB
Modelling in ROS, AI and Machine Learning

2 hours

Neural Networks and Genetic Algorithms in Robotics

Evolutionary and Learning-Based Control Methods

Subhendu Datta BhowmikRobotics Tutorials

Artificial Neural Networks in Robotics

Artificial Neural Networks (ANNs) are universal function approximators — given enough neurons and layers, they can represent any continuous mapping. In robotics, this makes them valuable for encoding complex relationships that are difficult to model analytically.

Feedforward networks (MLPs) map a fixed-size input vector to an output vector through one or more hidden layers. Applications: mapping joint angles to end-effector forces (learned forward dynamics), mapping sensor readings to motor commands (end-to-end control), and terrain classification from IMU vibration signatures.

Recurrent networks (LSTM, GRU) maintain internal state across time steps, making them suited for temporal sequences: gesture recognition from joint angle trajectories, predicting slip from tactile sensor time series, and learning robot odometry from raw IMU data sequences.

Training uses backpropagation — the chain rule applied recursively through the network to compute the gradient of the loss with respect to every weight. Stochastic gradient descent (SGD) and its adaptive variants (Adam, RMSprop) update weights iteratively to minimise the loss. Training requires a dataset of (input, desired-output) pairs, which for robotics may come from: human demonstrations (imitation learning), physics simulation runs, or real robot trials.

Neuron Model, Loss Function, and Gradient Descent

Fundamental equations of artificial neural network training

Neuron output:  y = f(∑ wᵢxᵢ + b)
MSE Loss:       L = (1/N) ∑ᵢ (yᵢ - ŷᵢ)²
GD weight update: w ← w - α · ∂L/∂w
f: activation function (ReLU, tanh, sigmoid); wᵢ: weight for input xᵢ; b: bias term; N: number of training samples; yᵢ: ground-truth label; ŷᵢ: network prediction; α: learning rate (hyperparameter, typically 1e-4 to 1e-2)

The learning rate α is the most critical hyperparameter. Too large: training diverges. Too small: training converges very slowly. Adaptive optimisers (Adam) use per-parameter learning rates that automatically adapt, making them more robust to this choice.

Neural Network Applications in Robotics

Neural networks are deployed throughout the robot software stack:

Inverse kinematics (IK) learning: Analytical IK has no closed-form solution for kinematically redundant arms (>6 DOF). An MLP trained on (end-effector pose → joint angles) pairs from a forward kinematics dataset provides fast, approximate IK. The ELMAN network and more recently transformer-based models achieve sub-millimetre accuracy on 7-DOF arms.

Grasping quality prediction: Given a candidate grasp pose and object point cloud, a GraspNet-style network predicts the probability of a successful grasp, replacing hand-engineered force-closure metrics. Enables generalisation to previously unseen object geometries.

Terrain classification for legged robots: CNNs or LSTMs applied to IMU, foot force, and joint torque data classify terrain type (gravel, grass, stairs, slope) and adjust gait parameters accordingly. Demonstrated on Boston Dynamics Atlas and ANYmal.

End-to-end driving (DAVE-2, NVIDIA PilotNet): A CNN maps raw front-facing camera images directly to steering angle and throttle, bypassing explicit perception-planning-control decomposition. Trained on hours of human driving data.

Adaptive PID gain scheduling: An RNN observes tracking error and system response, outputting PID gain adjustments in real time — a form of learned adaptive control that outperforms fixed-gain controllers on varying payloads.

Genetic Algorithms and Evolutionary Robotics

Genetic Algorithms (GAs) are population-based optimisation methods inspired by Darwinian natural selection. They are gradient-free, making them applicable where the objective function is non-differentiable, discontinuous, or stochastic — common in robotics.

GA mechanics:

  1. Initialisation: Create a population of N chromosomes — each encoding a candidate solution (e.g. a vector of robot controller parameters, a neural network weight vector)
  2. Evaluation: Run each chromosome (test the controller on the robot or simulator), compute a fitness score measuring performance (e.g. distance covered, task completion time)
  3. Selection: Preferentially select higher-fitness chromosomes for reproduction (tournament selection, roulette wheel selection)
  4. Crossover: Combine two parent chromosomes to produce offspring (e.g. swap parameter sub-vectors at a random crosspoint)
  5. Mutation: Randomly perturb offspring genes (add Gaussian noise to parameter values, flip bits) to maintain diversity and escape local optima
  6. Repeat until fitness converges or generation budget exhausted

Neuroevolution applies GAs to evolve neural network weights and/or topologies. NEAT (NeuroEvolution of Augmenting Topologies) starts with minimal networks and evolves both weights and architecture simultaneously using innovation numbers to protect structural innovations while allowing crossover between topologically different networks. NEAT has evolved locomotion controllers for multi-legged robots from scratch in simulation.

Evolutionary Robotics Methods

MethodOptimisesStrengthsWeaknessesRobot Application
Genetic Algorithm (GA)Discrete or real-valued parametersSimple, parallelisable, handles discontinuous search spacesLarge population needed, slow convergenceEvolving gait parameters, PID gains, path waypoints
Evolution Strategy (ES)Continuous real-valued parametersSelf-adaptive step sizes, fast on smooth continuous functionsLess effective on discrete or combinatorial problemsTrajectory optimisation, controller parameter tuning
Neuroevolution / NEATNeural network weights and topologyDiscovers novel architectures, no backprop neededVery slow on large networks, needs many evaluationsEvolving locomotion controllers, game-playing agents
CMA-ESContinuous parameters with covariance adaptationState-of-the-art on moderate-dimension continuous problemsScales poorly beyond ~1000 parametersRobot arm joint trajectory optimisation, bipedal walking
Differential EvolutionContinuous parameters via differential mutationSimple implementation, competitive with CMA-ESSensitive to control parameters F and CRSensor fusion calibration, hyperparameter optimisation

Neural Network Learning vs Genetic Algorithm Optimisation

Neural Network (Gradient-Based)

  • Requires differentiable loss function and gradient computation via backpropagation
  • Sequential updates — parallelism limited to mini-batch gradient computation
  • Black-box weights — limited interpretability of learned representation
  • Sample efficient — learns from thousands to millions of examples via gradient steps
  • Local search — gradient descent finds local optima; may miss global optimum
  • Scales to millions of parameters (deep networks) efficiently
  • Best when: large labelled dataset available, differentiable objective, supervised/RL tasks

Genetic Algorithm (Evolutionary)

  • Gradient-free — works on any evaluable fitness function, including black-box simulators
  • Highly parallelisable — evaluate entire population simultaneously on cluster/GPU
  • Interpretable solutions possible if chromosome encoding is human-readable
  • Sample inefficient — requires many fitness evaluations (thousands to millions)
  • Global search — population diversity and mutation help escape local optima
  • Scales poorly to very high-dimensional parameter spaces (>10k parameters)
  • Best when: no gradient available, topology optimisation needed, simulation is cheap

Modelling in ROS, AI and Machine Learning