Local encounters in robot swarms: From localization to density regulation