# Pathfinding on a 2D Grid based on minimal direction changes

I’m a high school student and I’ve been working on a new Arduino project inspired by the Amazon warehouse robots that lift and transport shelves of products. I’m doing a simpler version of the robot, as there will only be one instead of a network, and the program will assume that the entire grid is known (i.e. what spaces are blocked and unblocked). I’m familiar with the basics of programming and I’ve been working with Robotics for about four years, but while I’ve grown to understand some of the basics of Arduino’s programming language, I’m still largely unfamiliar.

In order to progress, I need to know how to create a proper pathfinding algorithm that will accommodate the robot well. I’ve looked into the A* search and B tree search algorithms, but I’m unsure how well they will fit the exact needs of this program. It needs to be able to move in a cycle of points A-B-C-A with a minimal number of directional changes, because the robot must stop and reorient its wheels every time it needs to change direction.

I’ve attached a concept map I drew up a while back. While the accuracy of it might be outdated, it does show some potential scenarios that would need to be addressed during the decision-making, especially an issue at the beginning, where moving north or east would mathematically get the robot closer to the first goal initially, but ultimately the best direction is away from the goal, south. I need to figure out how to write an algorithm that will allow the robot to address these kinds of decisions and find the best route that changes direction the least number of times, assuming it already knows the details of the environment. There are other concerns, such as its ability to identify each square in the grid, but that problem is separate and should be easily handled once the algorithm itself is finished. Any assistance on this matter would be appreciated.

OPs image

Hi and welcome to the forum.