0
$\begingroup$

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.

$\endgroup$

2 Answers 2

2
$\begingroup$

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

$\endgroup$
1
  • 1
    $\begingroup$ If this solved your problem then please mark the answer as accepted. $\endgroup$ Mar 30, 2018 at 12:22
0
$\begingroup$

Adafruit.com has a version of python that will work on the Arduino, Circuit Python. It's downloadable for free. I'm not sure who created it.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.