ev3dev / ev3dev-lang-python

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

Wrong version on ev3? #715

Closed kpu979 closed 4 years ago

kpu979 commented 4 years ago

Hi.. Newbie here again...

There are a bunch of objects that don't exist on the version I am running. For instance, I get the following error: AttributeError: 'MoveTank' object has no attribute 'follow_gyro_angle'

All of the odometry objects also gives me the same errors.

How do I get the proper version on my EV3?

kpu979 commented 4 years ago

I finally got the correct version, thanks to another thread.

WasabiFan commented 4 years ago

Sorry I didn't look into this sooner! Could you post what version you upgraded to?

kpu979 commented 4 years ago

@WasabiFan -- I followed the instructions in issue 712, and downloaded the code in this git. Things seem to work ok, but there are still variances between the code in VS Code and the EV3.

kpu979 commented 4 years ago

When I run this: def mtank(): mtank = MoveTank(OUTPUT_C, OUTPUT_B) mtank.set_polarity('inversed') mtank.ramp_up_sp = 2000 mtank.ramp_down_sp = 2000

mtank.gyro = GyroSensor()
Calibrate()

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/vscode-hello-python-master/hello.py", line 168, in mtank mtank.follow_gyro_angle( AttributeError: 'MoveTank' object has no attribute 'follow_gyro_angle'

kpu979 commented 4 years ago

I am finding this implementation very difficult to use. there are lots of functions that simply won't work. See above. tank.turn_to_angle_gyro: AttributeError: 'MoveTank' object has no attribute 'turn_to_angle_gyro'

It appears neither MoveTank or movedifferential utilize polarity, ramp up or ramp down.

Our wheels are on backwards to save space. It is important that on_to_coordinate works moving backwards and forwards. (If you want, I'll elaborate further on the results of going backwards...its not good.)

I must be doing something wrong and Im at the limit of my knowledge and frustrations. Again, I am new to Python, but not programming (its what I do for a living). I am new to Python on an EV3, and relatively new to Linux administration ( but I do know unix coding). and yeah, im new to git as well.

I am quite certain that once I understand the implementation and maintenance of ev3de2 on the EV3, I could be a valuable resource to this effort. Im hoping to get assistance with this and a deeper understanding of ev3dev2. As of now , I'm almost ready to pull the plug (or the sim card) and start with just EV3dev.

dwalton76 commented 4 years ago

Are you running from VScode on your laptop or are you SSHing to the ev3 and running from there? Until you figure out what is going on I would remove VScode from the equation and just ssh to the ev3.

When you ssh to the ev3 remember to do

export PYTHONPATH=/home/robot/ev3dev-lang-python/

that tells python to use the copy of ev3dev-lang-python that you clone from the repository here. If you do not do this then the AttributeError: 'MoveTank' object has no attribute 'follow_gyro_angle' error is expected as that is a really new method for MoveTank that isn't in a release yet.

kpu979 commented 4 years ago

Do i need to do that export every time I turn on the ev3?

dwalton76 commented 4 years ago

You can put that export line in your /home/robot/.bashrc file on your ev3 and then you won't need to enter it everytime.

WasabiFan commented 4 years ago

It sounds like you are referencing the version of the documentation for our in-development unreleased code on GitHub rather than the version of the library you are using. Refer to the "stable" version instead. You can select it in the bottom-right of the documentation page, or directly here: https://python-ev3dev.readthedocs.io/en/stable/index.html.

WasabiFan commented 4 years ago

Our wheels are on backwards to save space. It is important that on_to_coordinate works moving backwards and forwards. (If you want, I'll elaborate further on the results of going backwards...its not good.)

Can you open a new issue for this and describe the problem in more detail there?

kpu979 commented 4 years ago

Thank you both for the quick feedback. Im ok with using the test versions as they have the potential for using the gyro sensor. (Granted, I could code all of that as well ;) )

Im also ok knowing that this is under testing conditions, and for what Im doing, I can help with the testing. For instance, I just downloaded the latest version if this code, implemented the export into the bashrc file, and the function now is recognized, but not working: 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'

dwalton76 commented 4 years ago

Can you open an issue for this error, this is a bug. You can get around it by doing

from ev3dev2.motor import SpeedPercent
mtank.turn_degrees(SpeedPercent(20), 90)
kpu979 commented 4 years ago

Thank you @dwalton76 , that worked, and I opened a new issue.