Research in Unmanned Surface Vehicles (USVs) and Autonomous Mobile Robots navigation has demonstrated some success in navigating flat indoor environments while avoiding obstacles. But in common resilience to unsafe conditions, unmanned surface vehicles (USVs) and autonomous mobile robots have wide applications in security reconnaissance, investigation of an obscure domain, and crisis reaction. Various examinations have been directed on the driving mechanism, motion planning, and trajectory tracking strategies for robots, yet restricted investigations have been led with respect to the obstacle detection and avoiding ability of robots. However, for little scale robots that contain sensitive surveillance sensors and can't afford to utilize heavy defensive shells, the nonappearance of obstacle avoidance solutions arrangements would leave the robot helpless before possibly risky hindrances. In this paper, we present an algorithm for obstacle detection and avoidance system has been developed for miniature Unmanned Surface Vehicles (USVs) and autonomous mobile robots. We show an investigation differentiating heading build rules and relative course directions dodging distinctive operators in multi-specialist conditions, estimating separation between the two robots. The integration of distance measurement and avoiding other robots or obstacles is our observation in a multi-robot environment, where obstacles are also available. In this paper, we have discussed two algorithms, one will try to avoid other robot or obstacles and another will try to measure the distance between main agents to another agent. It utilizes an algorithm so that the system is both compact and power efficient. The proposed system can detect not only the presence, but also the approaching direction of a ferromagnetic obstacle. Therefore, an intelligent avoidance behavior can be generated by adapting the trajectory tracking method with the detection information. Design optimization is conducted to enhance the obstacle detection performance and detailed avoidance strategies are devised. Experimental results are also presented for validation purposes.