The standard for investigatory stops of citizens is set for all of the states by the US Supreme Court under the Fourth and Fourteenth Amendments. It requires at least "reasonable suspicion" that a crime is being or about to be committed. There is some latitude given to areas which are close to borders, as well as airports, but still there must be some articulable basis for the stop. So any charge, including a failure to ID would be unlawful if it arose from an unlawful stop. However, police often will articulate some basis for any stop, like weaving or rolling through a stop sign in order to justify a stop and any arrest that follows. Then it becomes your word against the officer's. Sometimes you win, but the odds generally favor the officer in court. Indignation is a noble cause, but if you choose to take on the police be prepared to martyr yourself, at least in the sense of paying some fines and court costs for the tickets you'll get. Another tactic would be to cooperate at the scene and make complaints to the police department and media
whenever it occurs, with the officers' names and badge numbers. You may make some enemies, but you will have a better chance of making a difference taking the slow approach through the system. My clients who try to take the quick route to relieve their indignations by butting heads with the police always make their lives much worse.