I've almost been hit by cars in SF for the exact same reason. Cities need to designate places for encampments to stop them from blocking sidewalks or disrupting residential areas. And they need to rapidly remove any that do block public access or disrupt residences.
Homeless people should be interviewed and those with mental illnesses treated by the state as they are objectively sick people in need of help. Homeless people under 18 should be taken into care. Homeless people over 65 showing senile ageing conditions should be asked if they want to go into retirement homes.
Outside of this homeless people should be treated with decency and respect as adults capable of full agency. They should face the consequences of their disregard of the rules. Punishments should be scaled but society should not feel sorry for drug addicted homeless people and actively enable them to keep ruining theres and others lives. This provides an easy scapegoat for homeless people who have nothing wrong with them.