In this article, a controller based on a Robot Operating System (ROS) for a two-wheeled self-balancing robot is designed. The proposed ROS architecture is open, allowing the integration of different sensors, actuators, and processing units. The low-cost robot was designed for educational purposes. It used an ESP32 microcontroller as the central unit, an MPU6050 Inertial Measurement Unit sensor, DC motors with encoders, and an L298N integrated circuit as a power stage. The mathematical model is analyzed through Newton-Euler and linearized around an equilibrium point. The control objective is to self-balance the robot to the vertical axis in the presence of disturbances. The proposed control is based on a bounded saturation, which is lightweight and easy to implement in embedded systems with low computational resources. Experimental results are performed in real-time under regulation, conditions far from the equilibrium point, and rejection of external disturbances. The results show a good performance, thus validating the mechanical design, the embedded system, and the control scheme. The proposed ROS architecture allows the incorporation of different modules, such as mapping, autonomous navigation, and manipulation, which contribute to studying robotics, control, and embedded systems.