Wheels. As there are gears in the wheel motor assembly.  As the machine running state in the hard floor is different from the carpet, the machine can determine the floor category from the  running state of the wheels. Because the carpet is rough it senses that more effort is needed to move forward