The evolution of bionic machines into intelligent robots to adapt to real scenarios is inseparable from positioning sensors. However, traditional positioning methods such as camera arrays, ultrasound, or GPS are limited in narrow concealed spaces, harsh temperatures, or dynamic light fields, which hinder the practical application of special robots. Here, we report a flexible sensor inspired by Gnathonemus petersii that enables robots to achieve contactless and high-precision spatial localization independent of the unstructured features of the environment. Sensors are obtained from lowcost materials (carbon nanotubes and polyimides) and simple structures (fibers) and preparation processes (spin-coating). Experiments and simulations confirmed the high resolution (<1 mm) of the sensor over a large distance detection range (>150 mm) and high bandwidth (0−520 MPa) of contact force. Moreover, the sensing capability is still feasible when the sensor is bent to various curvatures and not affected under harsh conditions such as ultralow temperatures (below −78 °C), ultrahigh temperatures (over 250 °C), darkness, or brightness. We demonstrate the practical potential of the proposed sensors for a biomimetic hyperredundant continuum robot to locate and avoid collisions in unstructured environments.