We present an adaptive training procedure for a spiking neural network, which is used for control of a mobile robot. Because of manufacturing tolerances, any hardware implementation of a spiking neural network has non-identical nodes, which limit the performance of the controller. The adaptive training procedure renders the input-output maps of these non-identical nodes practically identical, therewith recovering the controller performance. The key idea is to replace the nodes of the spiking neural network by small networks of synchronizing neurons that we call clusters. The networks (and interaction weights) are generated adaptively by minimizing the errors in the collective input-output behavior of the cluster relative to that of a known reference. By means of numerical simulations we show that our adaptive training procedure yields the desired results and, moreover, the generated networks are consistent over trials. Thus, our adaptive training procedure generates optimal network structures with desired collective input-output behavior.