A robotic system for delivering energy for medical or cosmetic treatment of a region of skin of a subject includes a multi-axis robotic arm mounted on a base and terminating at a holder. An applicator for delivering energy to the skin is mounted in the holder. The holder has at least three range sensors generating outputs of a distance to at least three spaced apart locations on the surface of the skin. A controller associated with the robotic arm and the range sensors processes the outputs from the at least three range sensors to determine an orientation of the holder relative to the skin, and actuates the robotic arm to adjust an orientation of the holder such that an orientation of the applicator relative to the skin is maintained within a predefined range of desired angles.