An unmanned aerial vehicle, UAV (200, 500, 600), configured to land, take off, and magnetically perch on a ferromagnetic cylindrical surface, the UAV (200, 500, 600) comprising: - a body (205, 605); - a plurality of articulated magnetic legs configured to land the UAV (200, 500, 600) on the ferromagnetic cylindrical surface and to magnetically perch the UAV (200, 500, 600) on the ferromagnetic cylindrical surface after the landing, each magnetic leg (110, 210, 310, 410, 510, 610) having a fixed portion (120, 320) coupled to the body (205, 605) and a pivoting portion (130, 330, 430) pivotably coupled to the fixed portion (120, 320) at a pivot axis (305, 350, 405, 450), wherein each magnetic leg (110, 210, 310, 410, 510, 610) further comprises an angle rotation sensor configured to measure a pivot of the pivoting portion (130, 330, 430) about the pivot axis (305, 350, 405, 450) after the pivoting portion (130, 330, 430) contacts the cylindrical surface, the pivoting portion (130, 330, 430) comprising: - a switchable magnet whose magnetism is switched on to magnetically attach the UAV (200, 500, 600) to the ferromagnetic cylindrical surface at an end of the landing and throughout the perching, and switched off to magnetically detach the UAV (200, 500, 600) from the ferromagnetic cylindrical surface at a beginning of the takeoff; and - a single articulation joint configured to provide the pivoting portion (130, 330, 430) with a single degree of freedom about the pivot axis (305, 350, 405, 450) in order to passively orient the pivoting portion (130, 330, 430) inward and tangent to the cylindrical surface in response to the pivoting portion (130, 330, 430) contacting the cylindrical surface during the landing, and to passively maintain the inward orientation of the pivoting portion (130, 330, 430) during the takeoff; and - a control circuit configured to - determine a diameter of a cylinder corresponding to the cylindrical surface using the measured pivots of the pivoting portions (130, 330, 430) of the magnetic legs (110, 210, 310, 410, 510, 610) or - a distance from the body (205, 605) to the cylindrical surface using the measured pivots of the pivoting portions (130, 330, 430) of the magnetic legs (110, 210, 310, 410, 510, 610). - a body (205, 605); - a plurality of articulated magnetic legs configured to land the UAV (200, 500, 600) on the ferromagnetic cylindrical surface and to magnetically perch the UAV (200, 500, 600) on the ferromagnetic cylindrical surface after the landing, each magnetic leg (110, 210, 310, 410, 510, 610) having a fixed portion (120, 320) coupled to the body (205, 605) and a pivoting portion (130, 330, 430) pivotably coupled to the fixed portion (120, 320) at a pivot axis (305, 350, 405, 450), wherein each magnetic leg (110, 210, 310, 410, 510, 610) further comprises an angle rotation sensor configured to measure a pivot of the pivoting portion (130, 330, 430) about the pivot axis (305, 350, 405, 450) after the pivoting portion (130, 330, 430) contacts the cylindrical surface, the pivoting portion (130, 330, 430) comprising: - a switchable magnet whose magnetism is switched on to magnetically attach the UAV (200, 500, 600) to the ferromagnetic cylindrical surface at an end of the landing and throughout the perching, and switched off to magnetically detach the UAV (200, 500, 600) from the ferromagnetic cylindrical surface at a beginning of the takeoff; and - a single articulation joint configured to provide the pivoting portion (130, 330, 430) with a single degree of freedom about the pivot axis (305, 350, 405, 450) in order to passively orient the pivoting portion (130, 330, 430) inward and tangent to the cylindrical surface in response to the pivoting portion (130, 330, 430) contacting the cylindrical surface during the landing, and to passively maintain the inward orientation of the pivoting portion (130, 330, 430) during the takeoff; and - a switchable magnet whose magnetism is switched on to magnetically attach the UAV (200, 500, 600) to the ferromagnetic cylindrical surface at an end of the landing and throughout the perching, and switched off to magnetically detach the UAV (200, 500, 600) from the ferromagnetic cylindrical surface at a beginning of the takeoff; and - a single articulation joint configured to provide the pivoting portion (130, 330, 430) with a single degree of freedom about the pivot axis (305, 350, 405, 450) in order to passively orient the pivoting portion (130, 330, 430) inward and tangent to the cylindrical surface in response to the pivoting portion (130, 330, 430) contacting the cylindrical surface during the landing, and to passively maintain the inward orientation of the pivoting portion (130, 330, 430) during the takeoff; and - a control circuit configured to - determine a diameter of a cylinder corresponding to the cylindrical surface using the measured pivots of the pivoting portions (130, 330, 430) of the magnetic legs (110, 210, 310, 410, 510, 610) or - a distance from the body (205, 605) to the cylindrical surface using the measured pivots of the pivoting portions (130, 330, 430) of the magnetic legs (110, 210, 310, 410, 510, 610). - determine a diameter of a cylinder corresponding to the cylindrical surface using the measured pivots of the pivoting portions (130, 330, 430) of the magnetic legs (110, 210, 310, 410, 510, 610) or - a distance from the body (205, 605) to the cylindrical surface using the measured pivots of the pivoting portions (130, 330, 430) of the magnetic legs (110, 210, 310, 410, 510, 610).