I am working on a navigation task for an autonomous rover. Right now, the rover can calculate the shortest path between the current position and a final destination given certain obstacles. I am using dijkstra's algorithm to find the shortest path and it's working well.
The rover has a fixed range with which it can identify that there is an obstacle infront of it or not. The problem I am facing is that the rover gets stuck in an infinite loop of same path (from point A to B, then point B to A) when an the final destination happens to be on a region that cannot be reached or seen by the vision of the rover.
My question is how should I detect that I am stuck in this loop and I can't reach the destination now that I should get a new final destination or just quit.
It depends on your application, if the destination cannot be reached you can detect this checking that all the reachable places in your map are visited and the destination is not one of them. Otherwise if you just missed some possible path, once you detect that you are stuck you can try to change your rover behavior. For example trying to go close to walls with sensors (if you have one) pointing to it.