My copy of the "Anarchist's Cookbook" explains exactly what to do when you are approached by police. It explains how they think, what to expect should you be booked, how to cooperate and keep your mouth shut. Do those things and no harm will come to you. As a matter of fact, judges appreciate those who comply with the police but do the explaining to attorneys and judges.
You must be a willing participant if your experience with the police turns bad. Avoid all instincts to show any emotion. Emotional actions will always end badly for all.