Yanez took the witness stand on the fifth day of testimony in his manslaughter trial.
Joseph Dutton, an officer for 31 years who now teaches classes on the use of force, said he is convinced that Yanez saw the gun before he shot Castile.
In the minutes after the shooting, Yanez told a supervisor variously that he didnt know where Castiles gun was and that he told Castile to get his hand off it. Dutton said he concluded that Yanezs statements meant that he didnt see the gun at first, but soon saw Castile trying to pull it out of his right pocket.
He went on to say that Yanez used "due caution" to avoid injury to the two passengers in the auto - Castile's girlfriend, Diamond Reynolds, and her 4-year-old daughter - when he stepped to the left of the vehicle and pointed his gun downward before firing.
On the squad auto video, Castile can be heard saying, "I'm not pulling it out", as Yanez opened fire.
Prosecutors argue that Yanez didnt see it and that he acted unreasonably in shooting Castile, a 32-year-old elementary school cafeteria worker who had a permit to carry the gun.
Closing arguments are set for Monday.
Castile told the officer that he was carrying a firearm, and whether Yanez saw it is a key issue in his manslaughter trial.
Yanez responded, "OK, don't reach for it then", followed by, "Don't pull it out", according to the squad vehicle recording.
The groceries Reynolds had bought with her sister the day of the shooting were left in Castile's vehicle and had been placed in evidence after the incident.
ST. PAUL, Minn. (AP) - A Minnesota police officer charged in the death of a black motorist testified Friday that he was "scared to death" and fired because the man was pulling out his gun and ignoring commands to stop.
The defense said Yanez didn't have the time to do so, because the situation escalated so quickly.
Ramsey County Attorney John Choi announced the charges against Yanez in November, saying that "no reasonable officer knowing, seeing and hearing what Officer Yanez did at the time would have used deadly force under these circumstances".
Paulsen also questioned the thoroughness of Dutton's report, asking him why he didn't include statements made by Reynolds and Castile as Castile was dying that he wasn't reaching for his gun. "If he comes across as being sympathetic, reasonable and doing the best he could, that could be the thing that carries the day for him", Mike Bryant, a criminal defense attorney, said. Castile had a permit for the gun. Dusterhoft said that was significant because it would have meant Castile had the gun all the way out of his pocket when he was shot. The autopsy report found traces of marijuana in Castile's system.
Castile had told the officer moments earlier he was carrying a gun.
A use-of-force expert says a Minnesota police officer used reasonable force when he shot and killed a black motorist a year ago in the seconds after the motorist told him he was carrying a gun. The matter was debated when defense toxicologist Glenn Hardin took the witness stand.
Emanuel Kapelsohn is the second such expert to testify on behalf of Officer Jeronimo Yanez.
Prosecutor Jeffrey Paulsen noted during cross-examination that Minnesota law does not require permit holders to disclose the presence of a permit or gun.
Castile died, insisting that he hadn't been reaching for his handgun.
Yanez has not spoken publicly about the shooting before Friday, though his comments to investigators have been reported in the media.
Yanez's chief, Jon Mangseth, defended the officer when he took the witness stand on Thursday, saying Yanez had a record free of disciplinary problems as well as "a real sound ability when it comes to communicating and relating to people", according to NBC affiliate KARE 11.
Philando Castile was shot and killed after being pulled over in the Twin Cities..
Various toxicology experts called by the state and defense differed on whether postmortem blood samples can accurately indicate recent marijuana use.