Imagine that an earthquake strikes, and you’re trapped under rubble. You’re hoping a firefighter or maybe a rescue dog will show up. But the first responder who shines that light on your face turns out to be a sensor-studded robot that looks a lot like a cockroach.

Roach-like rescue robots like this aren’t here yet. But mechanical “roachbots” are in development — and for good reason: The same abilities that make roaches so hard to exterminate are inspiration for roboticists. Unnervingly fast and able to squeeze through impossibly small cracks, roaches also seem able to survive a good stomping.

But bugs aren’t bots, and design challenges remain. One is locomotion.

Wheels vs. legs

For smooth surfaces, wheels remain the most efficient way to move. But on steep or uneven terrain — the kind often seen in disaster zones — wheeled bots are limited. As Tom Weihmann, a zoologist at the University of Cologne in Germany and the lead author of a new paper on roach running styles, told NBC News MACH in an email, “Wheel-driven vehicles are energetically costly and quickly reach physical limits.”

So legs are probably a better bet for rescue bots. But how many legs should they have? And what kind of gait is best?

To better understand the insects’ uncanny locomotion abilities, a team lead by Weihmann built a sort of narrow cockroach racetrack and used a high-speed camera to film speckled cockroaches (Nauphoeta cinerea) as they ran.

The researchers discovered that the roaches change gait as they gain speed, in much the same way that horses switch from a trot to a gallop.

Switching gaits

It’s well known that animals, including insects, adjust their gait to be more energy-efficient as they move faster. It was thought that insects run fastest when they use a so-called "tripod" gait, in which three legs are always touching the ground. (The front left, middle right, and rear left legs move forward at the same time, and then the front right, middle left, and rear right all take a step in coordination.)

The gait of a cockroach is studied at Tom Weihmann's lab at the University of Cologne. Courtesy of Tom Weihmann

But Weihmann’s research, published Dec. 6 in the journal Frontiers in Zoology, showed that while the roaches use the tripod gait at intermediate speeds, they switch at faster speeds to something more like a tölt. That’s the smooth gait made famous by Icelandic horses.

In this gait, the bugs’ legs move in a metachronal or wave-like pattern, Weihmann explained in a blog post. And he thinks that roach-inspired robots should be designed and programmed so that their gait changes in a similar way; if they were simply to speed up their legs without changing gait, their movement might be unstable and interfere with their machine vision.

In Weihmann’s view, highly mobile bug-inspired robots could one day play a key role in locating and coordinating the rescue of people not just in disaster areas but also deep in caves, high atop mountains, and in other extreme environments.

FOLLOW NBC NEWS MACH ON TWITTER, FACEBOOK, AND INSTAGRAM.