An IMU contains accelerometers, which measure linear acceleration including gravity, and gyroscopes, which measure rotation rate. Many add a magnetometer as a compass. The same component sits in every smartphone.
Integrating those signals gives orientation and, in theory, position, but small errors accumulate quickly. That drift is why an IMU is almost always fused with another sensor: wheel encoders on a mobile robot, GNSS outdoors, or camera and lidar features indoors.
On a balancing or legged robot the IMU runs the fastest loop in the system, reporting tilt hundreds of times per second so the controller can correct before the machine falls.
