I start a swarm robotic project, and there's something I don't understand.
If each robot is equiped with a sonar (SR04 for example), how may "robot A" ignore the square wave emitted by "robot B" ?
Well - it may not be able to. That's one of the challenges - how to deal with the cross-talk. One way to do it would be to set up on each robot some kind of receiver, then on each robot, when it pings, it transmits a signal to all the other receivers (and doesn't listen to its own receiver of course!). Basically yelling to all the other robots "hey, I'm talking here - everybody else shut up!" - so the other robots know not to ping for a bit (nor listen for a ping).
If line-of-sight can be guaranteed, that signal could be a simple IR LED and the receiver an IR remote control receiver module (with appropriate optics added to both to allow for 360 degree coverage and reception). Alternatively, if line-of-sight isn't possible - then using small radio transmitter and receiver to communicate.