The focus of this study is on the design of feedback control laws for swarms of robots that are based on models from fluid dynamics. We apply an incompressible fluid model to solve a pattern generation task. Possible applications of an efficient solution to this task are surveillance and the cordoning off of hazardous areas. More specifically, we use the smoothed-particle hydrodynamics (SPH) technique to devise decentralized controllers that force the robots to behave in a similar manner to fluid particles. Our approach deals with static and dynamic obstacles. Considerations such as finite size and nonholonomic constraints are also addressed. In the absence of obstacles, we prove the stability and convergence of controllers that are based on the SPH method. Computer simulations and actual robot experiments are shown to validate the proposed approach.