In wireless sensor networks (WSNs), mobile sink-driven data acquisition can mitigate hotspot issues, which further increases WSN efficiency, such as throughput, lifetime, and energy efficiency, while reducing delay and packet loss. Recently, most mobile sink algorithms have focused on efficient paths, and few consider obstacles in the network environment. Nevertheless, constructing an obstacle-aware trajectory in a WSN is challenging. In this context, this paper proposes a bug algorithm based on an obstacle-aware intelligent trajectory (CSOBUG) for a mobile sink to acquire data from sensor nodes in WSNs efficiently with the help of cat swarm optimization (CSO). The proposed CSOBUG algorithm has two phases: selecting visiting points and constructing a trajectory. A CSO-based clustering approach is used to select visiting points, and a bug algorithm is used to select a trajectory. Comparing CSOBUG with existing techniques, it is found that CSOBUG is less computationally intensive than the existing techniques. As well as outperforming traditional methods based on multiple performance metrics, the CSOBUG achieves superior results in a variety of scenarios.