Catching sight of a cockroach tends to make us behave chaotically, what with the running and screaming and throwing of shoes. But it appears that chaos might actually explain how we, and the cockroach itself, behave.

An interdisciplinary team of scientists from Germany have created a robotic cockroach that autonomously behaves in a way reminiscent of a real cockroach. The robot independently changes gait depending on the surface it is walking on, avoids obstacles and can even extricate its leg from a hole or run away from predators. Recreating lifelike behaviour is not new, but this robot reproduces a huge
range of behaviours and quickly reacts to new situations and switches between them. And the secret to its success is controlled chaos in its robotic brain.

An autonomous robot works by taking inputs from sensors (such as light, floor contact for each leg, and object recognition cameras) and generating outputs to the motors that control the robot's movement. But deciding exactly which combination of inputs should lead to which combination of outputs rapidly becomes very difficult as more inputs and outputs are considered. In contrast, a living
cockroach processes information from a large number of sensors (such as touch, vision, smell, temperature and vibration) to control the 100 or so muscles responsible for its movement. Therefore, the researchers noted in their paper, nature has apparently solved the difficult
problem of coordinating a large number of inputs and outputs.

In humans and animals, periodically recurring movements like walking or breathing are controlled by small neural circuits called central pattern generators (CPGs). Scientists have been using this principle in the development of walking machines. To date, typically one separate CPG was needed for every gait. Previously robots received information about the environment via several sensors
and selected the CPG that would produce the gait appropriate for the current situation.

There is growing evidence that the CPGs in real biological systems exploit chaos. Mathematically something is chaotic if a tiny change in starting conditions produces vastly different results. For example, one starting point for a mathematical function could produce a steady repeated pattern of outputs, but a slight nudge (called a perturbation) might result in wildly different
output.

It seems that individual neurons may behave in a chaotic way, but when connected to other neurons they interact, pushing and pulling each other, to create the patterned neural output of a CPG. And operating at the very edge of chaos seems to be an advantage: the organism can flip between behaviours in an instant, and even into chaos itself. For example it is thought that the CPG that produces
steady flight in some moths also controls the erratic fluttering and tumbling that help the insect dodge predators. (You can read more in Lewis Dartnell's Plus article Chaos in the brain.)

Silke Steingrube, Marc Timme, Florentin Wörgötter and Poramate Manoonpong have tried to
install this controlled chaos into their robotic cockroach. Inspired by the biology of the insect itself, they used a very simple neural network of two neurons to act as a CPG. The outputs of this CPG controlled the movement of the 18 mechanical muscles of the robot.

This simple neural network was defined mathematically, where the state of each of the two neurons at any time (each a real value between 0 and 1) was dependent on the state of both neurons an instant before. This mathematical system was tuned so that the network behaved chaotically: a tiny change in the value of the starting states would result in vastly different output.

To control this chaos, the researchers introduced an extra term in their equations that would essentially provide nudges to move the system from one type of behaviour to another. For example if the input sensors indicated the robot was on level floor, the control parameter would push the system into a periodic pattern of length 5, resulting in a walking style called a tetrapod gait (see
movie). Different inputs from the sensors, such as that it was on a hill, on rough terrain, and predator attack stimulated a different periodic output. If the input did not fit a known situation the control parameter was turned off, turning the output of the CPG back to chaotic and allowing the robot to flail about until it found itself in one of its known situations again. This chaotic behaviour
turned out to be ideal for many situations, for example when the robot is turned on its back, or its leg is trapped in a hole, as the chaotic behaviour eventually righted the robot and enabled it to quickly switch back to a stable gait.

The connection between sensory properties and CPG can either be preprogrammed or learned by the robot from experience. The scientists use a key example to show how this works: the robot can autonomously learn to walk up a slope with as little energy input as possible. As soon as the robot reaches a slope, a sensor shows that the energy consumption is too high. Thereupon, the connection between
the sensor and the control input of the CPG is varied until a gait is found that allows the robot to consume less energy. Once the right connections have been established, the robot has learned the relation between slope and gait. When it tries to climb the hill a second time, it will immediately adopt the appropriate gait.

In the future, the robot will also be equipped with a memory device which will enable it to complete movements even after the sensory input ceases to exist. In order to walk over an obstacle, for instance, the robot would have to take a large step with each of its six legs. "Currently, the robot would not be able to handle this task — as soon as the obstacle is out of sight, it no longer knows
which gait to use," says Marc Timme. "Once the robot is equipped with a motor memory, it will be capable to use foresight and plan its movements".

By mathematically controlling chaos these researchers have developed an elegant neural network that autonomously mimics real insect behaviour. The robot provides further proof that a chaotic ground state CPG is key in producing a wide range of behaviours and instinctively switching between them, whether in a robot, a roach, or even ourselves.