Along a bustling yard at the Port of Los Angeles’ TraPac terminal, robots rule.

Four-stories tall, mammoth two-legged machines scurry around the terminal, snagging shipping containers the size of delivery vans and stacking them like shoeboxes — and occasionally bumping into each other.

The expansive concrete container terminal, where humans are blocked from entering, looks more like a “Star Wars” backlot where all the AT-AT Walkers scurried loose.

But this is no special effect. It’s real-live port-side automation. And, most experts agree, it’s the future of cargo handling.

“If not for automation, we would become obsolete,” said Robert Owens, vice president of automation and information technology at TraPac LLC, the terminal operators owned by Japanese shipping carrier Mitsui O.S.K. Lines Ltd. and Canadian Brookfield Asset Management.

The robots ferry 40-foot-long shipping containers to massive shipside stacks. From there, more megamachines roll in to place the containers on trucks bound for warehouses in the Inland Empire and retailers across the country.

Most of this commercial waltz is orchestrated by programmed algorithms, with no human interference.

Such automation allows the terminal to handle greater volumes of goods in a tighter, more efficient space, Owens said. The electric- and hybrid-powered equipment also produces lower emissions.

Labor advocates, however, see no beauty in this gargantuan choreography. For the union representing dockworkers, new-age terminals are job killers that threaten Southern California’s shrinking blue-collar class.

“Those robots represent hundreds of (lost) jobs,” said Bobby Olvera Jr., president of International Longshore and Warehouse Union Local 13. “It means hundreds of people that aren’t shopping. They aren’t paying taxes and they aren’t buying homes.”

Owens takes another view. TraPac largely morphs routine jobs into more specialized roles, including mechanics who maintain and repair these iron giants.

The opposing perspectives on automation — arriving late to Southern California’s ports compared with some other industries — provide a snapshot of a larger debate playing out on factory floors, in grocery warehouses, even along assembly-line sushi bars, ­and at family kitchen tables where workers wonder where they fit in among their robotic counterparts.

Experts say the change is inevitable — especially for local ports — to keep pace with international competitors and the swiftly shifting marketplace.

“There are few new terminals (in the world) that aren’t automated,” said Mark A. Sisson, a senior port planner and analyst with engineering firm AECOM.

Falling behind isn’t an option, Owens said.

“If the ports become irrelevant,” he said, “all the jobs are going to go.”

Future ports

Over the past four years, the 210-acre terminal that sits at one of the innermost sections of the Port of Los Angeles has been undergoing the transformation. By 2018, the port terminal (or Trapac) will be mostly automated.

Two years later, the $1.3 billion Middle Harbor, Long Beach’s automated terminal, should be up and running. Operated by the Long Beach Container Terminal, a subsidiary of Hong Kong-based Orient Overseas Container Line, the container yard is the port’s largest development project.

Together, the two terminals could handle about a third of the twin ports’ cargo volume.

Across the world, dozens of ports have opted for human-free machines. Rotterdam’s port has been automated for decades.

“The pace of automated terminals is accelerating,” Sisson said. “They are building at record pace at a global level.”

Why are American ports behind the pace?

Shipping companies that lease terminals were hamstrung in recent years by sluggish trade growth that left behind little capital to install the expensive machinery. In addition, unions have strongly resisted supply lines where technology muscles out manpower.

But the door was left ajar when West Coast dockworkers signed a 2008 contract that made automated cargo-handling machines an option.

“We are determined to prevent any automation from coming to the waterfront in the future,” said Olvera, whose family’s history at the ports dates back generations. “We are going to make sure there are no taxpayer dollars spent on automation.”

The towering “straddle carriers” supplant men and women driving forklifts and other cargo-hauling vehicles inside the terminal.

The terminal still requires workers to partner with the robots. They monitor the machines, fix them when they break, and program and adjust their precise movements.

But, yes, fewer workers are required.

“We are looking at a point now with this new equipment that technology is phasing out humans,” said union official Mondo Porras. “It’s like sci-fi movies we used to watch. It is coming to the future.”

The human factor

The appeal of robotics to operators is clear. It drives down labor costs, enhances safety, consumes cleaner-burning energy and provides faster service to truckers streaming in and out of ports.

“It is a day-and-night difference between conventional style of operation and the automated,” Sisson said.

At Middle Harbor, a trucking trade group’s analysts estimated that automation cut in half the time big-rig drivers idled while waiting to pick up loads.

Wait times are down at TraPac, too. That cuts congestion at the port, where volumes are expected to rise steeply in coming decades.

On an overcast afternoon at TraPac, three men in safety vests and hard hats sit outside during a break. Asked about the high-tech portscape, they are in no mood to talk.

After a long silence, a worker pipes up. “It’s less jobs for us.”

He waves off a second question.

Porras isn’t as guarded.

“We understand that automation is the future,” he said. “We understand that the companies are trying to get more efficient. But I am losing utility truck drivers. This hurts.”

Those jobs won’t suddenly disappear. It will take six to nine years to install a wave of automation at the twin ports, Sisson said, and that’s only if the money’s there to pay for it.

Nonetheless, workers know change is coming.

“The manning (of equipment) that we know today is going to be off,” Porras said. “Technology is moving faster than we have ever seen it. The future is slim.”

Smarter robots

It’s been called the fourth wave of industrialization, the new machine age.

Robots and automation are a reality not just on the docks but for truck drivers, auto workers and retailers.

McKinsey Global Institute estimates nearly 60 percent of all occupations can at least be partially automated with current technology.

By 2055, the company’s analysts say, at least half of all U.S. work activities could be automated.

The jobs most easily replicated by machines involve not just predictable physical activities — like those in factories or warehouses — but also collecting and processing data, as in the financial industry.

Alec Levenson, a research scientist at the USC Marshall School of Business, said that the biggest push for automation is often where large numbers of employees work on a single, similar process, such as the tasks in customer-service centers and warehouses.

Automakers such as General Motors used to be the principal employers of robots, largely along their assembly lines, turning screws and fastening parts.

They’ve got company now.

Robotics operate retail-distribution centers, package food products, perform precise aerospace tasks and even pick crops and plow fields.

“Ten or 12 years ago, that would have been a science project,” said Michael Rabina, an engineering manager at Fanuc America, the U.S. arm of the Japanese robotics company. “Before robots were just doing pick-and-place movements that were repeatable and programmable. Now they are using vision to guide them to locations.”

About 80 percent of the robots he sells can “see” and detect when a product or item is either good or bad.

Futurists see roles such as helping doctors interpret X-rays and ultrasound images or laboring in high-risk roles along oil-production lines.

“The robots,” Rabina said, “have become a lot more intelligent.”

No stopping them now

Among the most aggressive advocates for robotics is Jeff Bezos, founder of Amazon.

In 2012, Bezos bought Kiva Systems, a Boston robotics firm, and has equipped his warehouses with tens of thousands of robots that work alongside humans.

He’s made headlines for encouraging consumers to order oft-used products with key-ring-style push buttons and for advocating drone-to-home deliveries.

At Bezos’ enormous fulfillment centers, including the facility in Tracy that stretches the length of 28 football fields, robots “recognize” products and shuttle them on their way.

The company says its superhuman robots create far more jobs than they’ve taken as the company grows amid the warehouse-to-your-house retail boom. Amazon shipped more than a billion items last holiday shopping season, according to the company, and robots did much of the heavy lifting.

Southern California hosts the largest number of Amazon’s fulfillment centers in its California network, centered largely in the Inland Empire, where thousands of workers process online orders and pack items to be sent to customers.

Amazon’s Eastvale location and the newer San Bernardino facility last year added hundreds of orange-hued wheeled robots — already in service at fulfillment centers in Tracy and Patterson — that cruise around the company’s expansive warehouses and carry shelving and products to workers, instead of workers trekking to the shelves themselves to collect products to ship. There are now more than 45,000 robots being used in 20-plus fulfillment centers worldwide, according to Amazon.

The plummeting costs of robots, coupled with their improved capabilities, makes them more and more attractive to industry’s leaders, said Ajay Agrawl, a professor at the University of Toronto’s Roman School of Management who specializes in the economics of artificial intelligence.

“They can now think and handle a situation,” Agrawl said. “It is prediction technology.”

That won’t do much to ease worries about job losses. Even former President Barack Obama warned of the aftershocks of automation.

“Automation is relentless, and it’s going to accelerate,” he said on a podcast hosted by his former aides.

But, unlike some, Alec Levenson, a research scientist at the USC Marshall School of Business, doesn’t have a dystopian view of this robot invasion.

Job losses are inevitable, he said, but not all jobs can be automated because creativity can’t be programmed.

And economic and industrial change is nothing new. It’s blurred our lives for years, he said.

Just as the internet reshaped lives around the world, it also created new economic models and jobs, he said.

“We have already had a lot of automation,” he said. “The computer was automation; it just doesn’t look like a robot.”

Staff writer Neil Nisperos contributed to this report.