udacity / sdc-issue-reports

29 stars 6 forks source link

Term 3 - 5.30 Polynomial Trajectory Generation Playground lacks python requirements or instructions #1179

Closed CodingCanuck closed 6 years ago

CodingCanuck commented 6 years ago

It appears that the python code available as a zip linked to from the "Polynomial Trajectory Generation Playground" lesson of the Trajectory Generation contains python 2 code.

Running this in python 3 gives the following error: $ python evaluate_ptg.py Traceback (most recent call last): File "evaluate_ptg.py", line 3, in from ptg import PTG File "/foo/trajectoryexercise2/TrajectoryExercise2/ptg.py", line 85 print "cost for {} is \t {}".format(cf.func_name, new_cost) ^ SyntaxError: invalid syntax

The lesson doesn't have any setup or environment instructions: it looks like we need python 2, and also matplot lib.

This probably means the author wrote this in some sort of environmental setup like anaconda. The setup recommended in term 1 won't work ( https://github.com/udacity/CarND-Term1-Starter-Kit/blob/master/doc/configure_via_anaconda.md ) because it uses python 3 ( https://github.com/udacity/CarND-Term1-Starter-Kit/blob/master/README.md )

Can we add python environment setup instructions to this exercise, and/or upgrade the example to python 3?

CodingCanuck commented 6 years ago

If we want to port this to python 3, the following changes are required:

ptg.py:85 print "cost for {} is \t {}".format(cf.func_name, newcost) should be print("cost for {} is \t {}".format(cf.\_name__, new_cost))

And I think that's all (once I change that line, the program seems to run successfully)

If there's anything else that needs porting from python2 to python3 syntax, here's a guide: http://www.diveintopython3.net/porting-code-to-python-3-with-2to3.html

baumanab commented 6 years ago

Yes, print as a function in python 3 will get you every time. Thanks for troubleshooting this.

baumanab commented 6 years ago

Thanks for helping with this, a python 3 version has been placed in the classroom.