There’s an increasing fear that robots may one day take our jobs, but some tasks they are welcome to – namely, assembling flatpack furniture.

After years of trying – and failing – roboticists in Singapore have finally designed a machine capable of building an IKEA chair in under nine minutes, a feat that is much harder than it sounds. Using 3D cameras, mechanical arms, force sensors and algorithms, the robot can autonomously assemble the Stefan chair without interruption or human intervention.

It was built by assistant professor Pham Quang Cuong and his team at Nanyang Technological University, Singapore’s School of Mechanical and Aerospace Engineering. In tests, the robot used three open-source libraries as instruction manuals to identify the pieces and put together a plan of action.

Prior to assembly, the robot took 11 minutes and 21 seconds to plan the so-called “motion pathways” needed to complete the task, three seconds to locate the parts and eight minutes and 55 seconds to finish the project.

“For a robot, putting together an IKEA chair with such precision is more complex than it looks,” said assistant professor Pham. “The job of assembly, which may come naturally to humans, has to be broken down into different steps, such as identifying where the different chair parts are, the force required to grip the parts, and making sure the robotic arms move without colliding into each other. Through considerable engineering effort, we developed algorithms that will enable the robot to take the necessary steps to assemble the chair on its own.”

READ NEXT: Is it time we began taxing the robots taking our jobs?

The same researchers have been plugging away at solving this particular problem since 2015. Robots are now commonplace in assembly lines for complex, large items, such as cars due to the repetive nature of the job in hand. They’re not so great at seeing the world as we do, and being able to plan out courses of action for more random, unique tasks.

The team’s first attempts at building the chair saw the robot come undone when it tried to insert the different sized wooden dowls into the relevant slots. It did manage it, eventually, but it was a slow and tedious process as you can see in the video below.

The researchers built the robot to mimic what they call human “hardware”, namely it has “eyes” thanks to a 3D camera, “arms” capable of six-axis motion and grippers that act as fingers to pick up objects. Mounted on the robots “wrists” are additional force sensors that know how strongly the “fingers” are gripping and how powerfully they push objects into contact with each other.

“The way we have built our robot, from the parallel grippers to the force sensors on the wrists, all work towards manipulating objects in a way humans would,” assistant professor Pham said.

It begins by taking 3D photos of the parts laid out on the floor to build a “map” of the estimated positions of the different pieces. This, according to the team, is to replicate the “cluttered environment after humans unbox and prepare to put together a build-it-yourself chair”.

Next, using algorithms, the robot “plans a two-handed motion that is fast and collision-free”. To make sure its arms can grip the pieces correctly and perform tasks, such as inserting wooden plugs into the frame, the wrist sensors monitor the amount of force being exerted.

“We have shown that robots can autonomously achieve a highly complex manipulation task: assembling an IKEA chair frame in an unstructured environment by leveraging existing developments in vision, planning, and control,” the team explained. “There is still an important limitation: although all the steps were automatically planned and controlled, their sequence was hard-coded through a considerable engineering effort.”

“We are looking to integrate more artificial intelligence into this approach to make the robot more autonomous so it can learn the different steps of assembling a chair through human demonstration or by reading the instruction manual, or even from an image of the assembled product,” added assistant professor Pham.

It’s not the first robot to build IKEA furniture – MIT robots built a Lack table in 2013 – but it is the first to assemble something as complicated as a chair. The NTU team believes its robot could be of greatest value in performing specific tasks with precision in industries where tasks are varied and don’t suit assembly lines.

The results are published in the journal Science Robotics.