Darius McCollum can explain the complicated workings of the New York City transit system with the precision of a veteran conductor. He knows every subway stop, every line, every train.

It’s an obsession that has dominated his life. But instead of becoming a transit worker, he’s become a transit impostor. Twenty-nine times, beginning when he was a teenager, he’s been arrested for crimes that include piloting a subway train, stealing a bus and donning uniforms to pose as a conductor and even track worker.

“I’ve always loved trains, ever since I can remember. I had the whole subway map memorized by the time I was 8. People would call me to ask how to get somewhere,” said the 49-year-old McCollum, who has spent nearly a third of his life behind bars.

He’s been at Rikers Island jail since his 2010 arrest for his latest escapade — stealing a Trailways bus. He was arrested behind the wheel on the highway that leads to Kennedy International Airport.

The case, for him, is typical. But he hopes the outcome this time will be different.

Attorney Sally Butler says McCollum’s actions are the result of uncontrolled impulses, a byproduct of what was until recently called Asperger’s syndrome but is now considered an autism spectrum disorder.

She says the district attorney’s office agrees, and they have worked on a solution: McCollum pleaded guilty to stealing the bus, and instead of being sentenced Thursday to 15 years as a habitual offender, he will get 2 ½ to 5 years and voluntarily undergo cognitive behavioral therapy.

“I really do want to change,” McCollum said from jail. “I have motivation and people behind me — I think I can do it this time.”

McCollum was first handed literature about Asperger’s about 10 years ago by a former lawyer. But before he could be evaluated, McCollum was sentenced by a Manhattan judge who said she had looked up the disorder online and decided he didn’t have it. He has since been diagnosed by doctors on both sides, and it took awhile before it started to make sense to him.

“I knew I was different from people, but I didn’t realize what was making me different,” he said.

McCollum is friendly, articulate and intelligent. He thanks the guard who takes off his handcuffs, then shakes hands through the small opening in the metal grating of the interview room. He seems unaffected by his environment, though he says he doesn’t much like jail, and some have suggested he’s too used to the routine of prison. Routine is something many with the disorder crave.

His arrests sound vaguely like tall tales where he plays the well-meaning folk hero. In his most recent case, he says he was hired by Trailways to pick up a crew of flight attendants because the driver didn’t show up for work, a version prosecutors dispute. When he was arrested, he was alone.

At 15, he piloted an E train from 34th Street — his favorite subway station — six stops to the World Trade Center without any passengers noticing. It started the cycle he’s been in for years. He’s never held a steady job. He took the civil service exam to work for the Metropolitan Transit Authority but didn’t pass. It wouldn’t matter anyway, said an MTA spokesman: “We would not hire anyone who has previously stolen one of our trains.”

McCollum’s story has been well-chronicled. A documentary is being filmed about his life. He has his own Wikipedia page. His mother, Elizabeth, and others believe the celebrity has only hurt him. She’s sick of reporters constantly calling.

“My son doesn’t benefit from all these stories written about him. It only confuses the issue. He needs help is what he needs,” she said from her home in Winston Salem, N.C., where she moved more than two decades ago, in part to get her son away from trains — but he kept going back. She fears he believes if he keeps up his antics, someone will make him rich.

McCollum presents a confusing challenge for the criminal justice system. He’s not violent. He just drives the routes, fixes broken tracks and works alongside other transit employees without an official job. But, as prosecutors have long said, he could cause an accident or injure someone.

Butler, his current attorney, said it’s really up to McCollum to get better — or be rearrested and face a longer sentence.

“If I went to a jury trial and argued mental illness, we’d win, but the problem is, they put you in the mental hospital, they keep you there until cured,” Butler said. “This can’t be cured. It can only managed.”

For what it’s worth, McCollum said he doesn’t want to operate trains anymore when he gets out — they’ve become too computerized.

“They’re doing away with everything from the old days, it seems,” he said.