Apress / Beginning-Robotics-with-Raspberry-Pi-and-Arduino

source code
Other
7 stars 6 forks source link

pi_roamer_01.py in Chapter 7 #1

Open MVL62 opened 2 years ago

MVL62 commented 2 years ago

I've followed the book carefully, and now when I try to run "pi_roamer_01.py" file (Chapter 7), I get numerous errors. I think I've solved some but now I get "TypeError: 'NoneType' object is not callable for line 54 motors[0].throttle(motorSpeed[0])", which I can't solve. Any help would be appreciated.

Other errors include indentation errors for lines 68 onwards, missing parentheses on line 69, NameError: name 'motors' is not defined on line 51, Unused variable 'm1Speed' etc on lines 40 through 59 etc.

Many code errors in this book. These errors existed in the 1st edition and now more in the 2nd edition.

Nick268 commented 1 year ago

I agree. The code is littered with errors. It clearly hasn't been tested. The changes to the code to accommodate the changes to adafruit MotorKit seem to have been done by guess work. I had used the code from the 1st Edition for the ultrasonics in Chapter 7 successfully (well after I had worked through the errors present there). I have tried to use the Chapter 8 code for the IR line followed. It's riddled with errors, and seems to hang when I think I have sorted the errors. I would rate this code as "Must try harder".

Nick268 commented 1 year ago

I have cracked the "TypeError: 'NoneType' object is not callable for line 54 motors[0].throttle(motorSpeed[0])" error. It doesn't like that its "motors[0].throttle(motorSpeed[0])" However, it does like "motors[0].throttle=motorSpeed[0]" So not a call to a method of the class motor, but an assignment of a value to an attribute "throttle"!!!