The company has not had any accidents or injuries involving the driverless cars, said Ryan Chin, a co-founder of Optimus Ride and the chief executive.

“Most accidents are caused by human error,” said Mr. Chin, including people driving while texting or intoxicated, and falling asleep behind the wheel. “Those are all human characteristics we can actually program out of the vehicle. Our computers will never get tired as long as there’s power.”

Mr. Chin met David Ehrenberg, the president and chief executive of the Brooklyn Navy Yard Development Corporation, a nonprofit that manages the site, at a conference several years ago. The two started talking, and soon Mr. Chin was touring the yard where battleships like the Missouri were once built.

The yard has become a laboratory for urban technology, in part because fewer regulations and restrictions exist there than on public streets. It is a city within a city, with 400 companies and 10,000 workers. Citi Bike, the bike-share program, was first tried out at the yard before launching in Manhattan. Drones have also been used to inspect buildings.

“I said, ‘This is the perfect landing spot for an autonomous car in New York,’” Mr. Ehrenberg recalled telling Mr. Chin. “There is — we think — no better place than the Navy Yard to test and learn about new technologies.”

Mr. Ehrenberg’s organization contracted with Optimus for two years to provide shuttles for a recently launched city ferry landing — there have been 40,000 ferry trips since May — and to support local job development. It declined to disclose how much it paid, citing the confidentiality of the agreement. No public money was used.

Optimus opened an office at the yard, and hired 18 local operations workers with salaries ranging from $20 to $65 an hour, including recent engineering graduates of the New York City College of Technology, which is part of the City University of New York. It is also working with a high school at the yard to create an internship program.