Autonomous robots may be able to adapt their behavior in response to changes in the environment. This is useful, for example, to efficiently handle limited resources or to respond appropriately to unexpected events such as faults. The architecture of a self-adaptive robot is complex because it should include automatic mechanisms to dynamically configure the elements that control robot behaviors. To facilitate the construction of this type of architectures, it is useful to have general solutions in the form of software tools that may be applicable to different robotic systems. This paper presents an original algorithm to dynamically configure the control architecture, which is applicable to the development of self-adaptive autonomous robots. This algorithm uses a constraint-based configuration approach to decide which basic robot behaviors should be activated in response to both reactive and deliberative events. The algorithm uses specific search heuristics and initialization procedures to achieve the performance required by robotic systems. The solution has been implemented as a software development tool called Behavior Coordinator CBC (Constraint-Based Configuration), which is based on ROS and open source, available to the general public. This tool has been successfully used for building multiple applications of autonomous aerial robots.