Abstract In this paper, we propose a decentralized algorithm to form arbitrary repeating formations of multiple robots. Methods are known to form specific kinds of repeating structures such as squares, triangles, and hexagons by modeling each robot as a particle that responds to attractive and repulsive forces generated by nearby robots. However, such methods are generally designed by hand for one specific type of lattice. Our approach is more general, in the sense that we present a single algorithm, for which a description of the desired repeating pattern is part of the input. We represent this pattern as a directed graph, in which edges show the desired rigid body transformations between the local frames of pairs of neighbor robots. The robots autonomously organize themselves into a family of rooted trees, and use these trees to perform task assignments locally and without conflicts. We show, via our simulated implementation, that our algorithm works for robot systems with hundreds of robots to form various lattice patterns. Our experiments also show that the approach can recover rapidly from robot failures, even if those failures impact a large fraction of the robot population.