(CNN) A rookie police officer who, according to authorities, said he had "f----d up" and "didn't know what to do" when he fatally shot an unarmed man in Pennsylvania has been charged with voluntary manslaughter, prosecutors said Tuesday.

South Whitehall Township Police Officer Jonathan Roselle, 33, whose US Army service included a tour in Afghanistan, had been on the job about six months when he encountered 44-year-old Joseph Santos on the afternoon of July 28, Lehigh County District Attorney Jim Martin said in a statement.

Moments earlier, a motorist pulled up alongside the officer and said a man had tried to get into her car, according to the statement. When Roselle pulled his car up to Santos, Santos was bleeding. He banged on the officer's side window, mounted the hood and banged on the windshield.

The officer drew his gun, repeatedly ordered Santos to get away from the car and radioed for help, Martin said. Santos walked away a short distance before turning around and walking back toward the officer.

"Get down on the ground," Roselle, now standing outside his car, told the man.

Read More