scottpletcher / deepracer

AWS DeepRacer Experimentation
MIT License
280 stars 57 forks source link

can only concatenate list (not "int") to list; name 'math' is not defined #2

Open 5ervant opened 5 years ago

5ervant commented 5 years ago

Upon rewriting "PurePursuit" for the current Reward function's Code editor, I'm getting these errors:

Is this the latest conversion for the declaration of rabbit? rabbit = [waypoints[closest_waypoints[1]][0],waypoints[closest_waypoints[1]][1]] or rabbit = [waypoints[closest_waypoints[0]][0],waypoints[closest_waypoints[0]][0]]

And also how can we use math if it's not defined on the current AWS DeepRacer model's code editor?

scottpletcher commented 5 years ago

That version of PurePursuit was written back when we had to train on SageMaker directly. If you are training on the console, the closest waypoint param changed. Might try something like this:

waypoint_ahead = params['closest_waypoints'][1]
rabbit_x = params['waypoints'][waypoint_ahead][0]
rabbit_y = params['waypoints'][waypoint_ahead][1]
rabbit = [rabbit_x, rabbit_y]

As for the math module being undefined, that means that import math isn't contained anywhere in the context of the reward function. Seems as though it was in the old SageMaker version. You might try just a simple import math at the top of your function. If that isn't allowed, you can always use the elemental math functions rather than the math functions. A little googling will reveal the proper formula in Python.