The control architecture of autonomous robots can be developed by programming and integrating multiple software components that individually control separate behaviors. This approach requires additional mechanisms to coordinate their concurrent execution. This paper presents a programming method for such components that has been designed to facilitate their coordinated execution. Each component is programmed as a module that controls a separate robot behavior together with a set of functions for execution management. The details of this proposal are formulated in the form of a ROS-based software library called \textit{behaviorlib}. This solution has been used to program general behavior controllers that have been successfully reused to build multiple applications in aerial robotics.