Problems about the original Motion Planner A_star

Hello! I was trying to use the original Motion Planner in the tutorial_commonroad-search.ipynb to search for solutions. It works quite well with automata.MotionPlanner_gbfs, but there are some problems with automata.MotionPlanner_Astar. At the very beginning it does head to the destination, but it sometimes breaks down midway during the searching process and reports errors like this:

Process Process-32:
Traceback (most recent call last):
File “/home/kejia/anaconda3/envs/commonroad-py37/lib/python3.7/multiprocessing/process.py”, line 297, in _bootstrap
self.run()
File “/home/kejia/anaconda3/envs/commonroad-py37/lib/python3.7/multiprocessing/process.py”, line 99, in run
self._target(*self._args, **self._kwargs)
File “…/…/GSMP/motion_automata/automata/HelperFunctions.py”, line 129, in execute_search
result = motion_planner.search_alg(initial_motion_primitive.Successors, max_tree_depth, dict_status_shared)
File “…/…/GSMP/motion_automata/automata/MotionPlanner_Astar.py”, line 716, in search_alg
if path_primitive_translated[0].time_step > self.desired_time.end:
TypeError: ‘NoneType’ object is not subscriptable

I don’t find that the problem lies in the heuristic function, since normally when the motionplanner can’t find a solution it reports “timeout” instead of failing out midway. I tried to look for the problem But I failed. Could anyone offer some advice? Thanks in advance!

p.s: I didn’t make any change to any of the original motion planner.

1 Like

Hi kejia,
It seems at some point the path_primitive_translated variable is of NoneType.
You can add a simple if statement to avoid that:
If path_primitive_translated is None:
continue

However, the root cause of that should be further investigated.

I encountered the same problem just now with a fresh CommonRoad VM. The only two statements I modified in the tutorial_commonroad-search notebook was commenting out the GBFS import and uncommented A* instead.

Same error after “Restart & Run All”.

After applying Edmond’s if-statement, the A* algorithm failed to terminate after running for over an hour, although it might be due to the size of the search tree rather than being an actual error.

Lastly, when you diff the code in MotionPlanner_Astar.py vs MotionPlanner_gbfs.py, it should be evident that the code in the A* search is significantly out of date, because even the helper functions are implemented differently. Is it possible to simplify the codebase by creating a superclass/interface such that the users only need to implement calc_heuristic_cost() and search_alg()? The code is so unnecessarily complex.

('Cost so far:', 40.4, 'Time step:', 50, 'Orientation:', -1.3, 'Velocity:', 1.0)0))

Process Process-4:
Traceback (most recent call last):
  File "/usr/lib/python3.6/multiprocessing/process.py", line 258, in _bootstrap
    self.run()
  File "/usr/lib/python3.6/multiprocessing/process.py", line 93, in run
    self._target(*self._args, **self._kwargs)
  File "../../GSMP/motion_automata/automata/HelperFunctions.py", line 142, in execute_search
    result = motion_planner.search_alg(initial_motion_primitive.Successors, max_tree_depth, dict_status_shared)
  File "../../GSMP/motion_automata/automata/MotionPlanner_Astar.py", line 715, in search_alg
    if path_primitive_translated[0].time_step > self.desired_time.end:
TypeError: 'NoneType' object is not subscriptable

Search finished.
Finding solution failed :(
time: 5min 59s

Hi tk,

thanks for the suggestion. the original codes were developed by different persons.
as for now, i think it is easier that you make a copy of gbfs planner and implement your a* algorithm based on that.