ev3dev / ev3dev-lang-python

Pure python bindings for ev3dev
MIT License
425 stars 144 forks source link

tank.turn_degrees throwing an error #717

Closed kpu979 closed 4 years ago

kpu979 commented 4 years ago

mtank.turn_degrees(20,90) File "/home/robot/ev3dev-lang-python/ev3dev2/motor.py", line 2267, in turn_degrees speed_native_units = speed.to_native_units(self.left_motor) AttributeError: 'int' object has no attribute 'to_native_units'

WasabiFan commented 4 years ago

@dwalton76 this looks like a bug in the gyro drive methods; they assume a speed unit class rather than defaulting to percent if a number is given.

Side-note: I think this comment line has a typo: https://github.com/ev3dev/ev3dev-lang-python/blob/ev3dev-stretch/ev3dev2/motor.py#L2279

@kpu979 Sorry! As a workaround, you should use a "speed unit" class (https://ev3dev-lang.readthedocs.io/projects/python-ev3dev/en/ev3dev-stretch/motors.html#units). In your case, this would look like:

mtank.turn_degrees(SpeedPercent(20),90)

I should also warn you -- since you cloned the repository and are using your local copy from our development branch, there are changes in your version which aren't in past or future releases. Just a heads-up.

WasabiFan commented 4 years ago

Looks like you already know: https://github.com/ev3dev/ev3dev-lang-python/issues/715#issuecomment-575369184

kpu979 commented 4 years ago

Hi, Here's another related bug:

When I do this:

    mtank.follow_gyro_angle(
        kp=11.3, ki=0.05, kd=3.2,
        speed=SpeedPercent(30),
        target_angle=0,
        follow_for=follow_for_ms,
        ms=4500)

I get this:

  File "/home/robot/ev3dev-lang-python/ev3dev2/motor.py", line 2179, in follow_gyro_angle
    assert speed_native_units <= MAX_SPEED, "Speed exceeds the max speed of the motors"
  File "/home/robot/ev3dev-lang-python/ev3dev2/motor.py", line 101, in __ge__
    return self.to_native_units() >= other.to_native_units()
AttributeError: 'float' object has no attribute 'to_native_units'
WasabiFan commented 4 years ago

@dwalton76 Did you get a chance to look at these issues? Are they solved by #724?

I can try to get these things resolved today or otherwise soon before I publish a release.

WasabiFan commented 4 years ago

I believe this is fixed in the 2.1.0 release. @kpu979 would you be able to confirm this is fixed?

dwalton76 commented 4 years ago

sorry just saw this...it should be fixed via #724

kpu979 commented 4 years ago

@WasabiFan -- I'd be happy to validate this issue.

to ensure I have the correct versions on my mac and EV3: IN VS Code on my Mac (Im running in a virtual environment) -- console: $ pip install python-ev3dev2 (do I use the --upgrade tag?)

Is there a better way to load EV3dev on the EV3 without refreshing the card?

dlech commented 4 years ago

Is there a better way to load EV3dev on the EV3 without refreshing the card?

  1. make sure the EV3 is connected to the internet with USB or Wi-Fi
  2. open an SSH terminal to the EV3
  3. run sudo apt update && sudo apt upgrade
kpu979 commented 4 years ago

Sorry it took this long to get back to you. I've never been busier for my work.

I finally got everything updated and tweaked, and this works!!