Rotary device with endless rotation function