# Can the A* Algorithm be implemented on an Arduino easily?

I am not very experienced in working with C++. Working with Python is much more easier for me because of the large number of built-in mathematical functions present such as multidimensional array sorting and more. I went through the Udacity document on Motion Planning (Programming a Robotic Car) in Python and it seemed simple enough for me to implement. However, I would like to use the Arduino due to its simplicity and my need to interface other modules with it. Can someone suggest me an easier way or lead me to some resources that can help me code it in C++ for the Arduino? All the A* algorithm C++ source codes I've found online are either huge or difficult to understand. In my case, I'm planning to use a simple grid based implementation of the A* Algorithm. Thanks in advance.

You're welcome to steal the AStar class from my C++ highway driving project.

https://github.com/ericlavigne/CarND-Path-Planning

I used AStar to control a car driving on a simulated highway with traffic. In my case, state included position (along and across the highway), speed (along the highway), and time (which implicitly included the expected positions of other cars at that time). However, this AStar class supports any definition of state, including the more common case of position-only that you are interested in.

Here are the file that contains the AStar class:

https://github.com/ericlavigne/CarND-Path-Planning/blob/master/src/astar.h

You'll need to represent the state in order to use the AStar class. As an example, here are the files that represented my state. Your state with position only should be a trimmed down version of this.

https://github.com/ericlavigne/CarND-Path-Planning/blob/master/src/trajectory_state.h

https://github.com/ericlavigne/CarND-Path-Planning/blob/master/src/trajectory_state.cpp

And these files show how to combine the AStar class and a state class (TrajectoryState in my case) to perform A* optimization:

https://github.com/ericlavigne/CarND-Path-Planning/blob/master/src/discrete_trajectory_planner.h

https://github.com/ericlavigne/CarND-Path-Planning/blob/master/src/discrete_trajectory_planner.cpp

• If this solved your problem then please mark the answer as accepted. Mar 30 '18 at 12:22