ev3dev / ev3dev-lang-python

Pure python bindings for ev3dev
MIT License
428 stars 145 forks source link

AttributeError with MoveDifferential - possibly version related #679

Closed dkantereivin closed 4 years ago

dkantereivin commented 4 years ago

Hi All, I'm running into issues using ev3dev2 (Python) when it comes to the MoveDifferential class, and of course I'm also worried that my team will get coding and then will encounter other, more serious issues. In this case, using MoveDifferential consistently errors at mdiff.odometry_start() saying AttributeError: 'MoveDifferential' object has no attribute 'turn_to_angle'.

Initially I used my own code but it does not work using the code in the documentation either. When I remove odometer, the same error is presented for on_for_distance.

Here is the full code I copied:

#!/usr/bin/python3.5
from ev3dev2.motor import OUTPUT_C, OUTPUT_B, MoveDifferential, SpeedRPM
from ev3dev2.wheel import EV3Tire
STUD_MM = 8
# test with a robot that:
# - uses the standard wheels known as EV3Tire
# - wheels are 16 studs apart
mdiff = MoveDifferential(OUTPUT_B, OUTPUT_C, EV3Tire, 16 * STUD_MM)
# Rotate 90 degrees clockwise
mdiff.turn_right(SpeedRPM(40), 90)
# Drive forward 500 mm
mdiff.on_for_distance(SpeedRPM(40), 500)
# Drive in arc to the right along an imaginary circle of radius 150 mm.
# Drive for 700 mm around this imaginary circle.
mdiff.on_arc_right(SpeedRPM(80), 150, 700)
# Enable odometry
mdiff.odometry_start()
# Use odometry to drive to specific coordinates
mdiff.on_to_coordinates(SpeedRPM(40), 300, 300)
# Use odometry to go back to where we started
mdiff.on_to_coordinates(SpeedRPM(40), 0, 0)
# Use odometry to rotate in place to 90 degrees
mdiff.turn_to_angle(SpeedRPM(40), 90)
# Disable odometry
mdiff.odometry_stop()

I suspect that this is because the version in the docs and around is a newer beta version. This is the version of ev3dev I got from the main site - will updating to a newer version solve my problem, and where is it available? I figured other people might be liable to have a similar issue, so hopefully this will help anyone else in my place. I take it there is a way to update the python without completely updating the kernel?

Thanks for your help!

WasabiFan commented 4 years ago

Hmmm... I am not aware of this being encountered or fixed in the past. I don't expect it to fix the problem, but it's worth trying to upgrade; we have instructions here: https://python-ev3dev.readthedocs.io/en/ev3dev-stretch/faq.html

If that doesn't resolve it I'll try to look into it more thoroughly.

dkantereivin commented 4 years ago

Hmmm... I am not aware of this being encountered or fixed in the past. I don't expect it to fix the problem, but it's worth trying to upgrade; we have instructions here: https://python-ev3dev.readthedocs.io/en/ev3dev-stretch/faq.html

If that doesn't resolve it I'll try to look into it more thoroughly.

Holy crap I'm like Christopher Columbus!! In all seriousness, I'll get the update done and test it out within the next hour and a half and update you (just need to enable WiFi sharing through USB on school network). Thanks for your quick reply.

dkantereivin commented 4 years ago

Newest version fixed it, as expected! Thank you for your help.