ev3dev / ev3dev-lang-python

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

AssertionError: odometry_start() must be called to track robot coordinates #722

Closed orioldelos closed 4 years ago

orioldelos commented 4 years ago

||/ Name Version Architecture Description ii micropython-ev 2.0.0 all Python language bindings for ev3d ii python3-ev3dev 1.2.0 all Python language bindings for ev3d ii python3-ev3dev 2.0.0 all Python language bindings for ev3d

I was testing the ev3dev2 libraries and playing with the MoveDifferential odometry. I have the following code:

#!/usr/bin/env micropython

from ev3dev2.motor import LargeMotor, Motor, OUTPUT_C, OUTPUT_D, SpeedPercent, MoveTank, MoveDifferential, SpeedRPM
from ev3dev2.wheel import EV3Tire
from ev3dev2.sensor import INPUT_1
from ev3dev2.sensor.lego import TouchSensor
import logging
logging.basicConfig( level=logging.DEBUG,
    format='%(message)s')
steering_drive = MoveDifferential(OUTPUT_D, OUTPUT_C, EV3Tire, 150,None, Motor)
steering_drive.odometry_start()
steering_drive.on_to_coordinates(SpeedRPM(40), 50, 50)
steering_drive.on_to_coordinates(SpeedRPM(40), 50, 70)
steering_drive.on_to_coordinates(SpeedRPM(40), 0, 0)

But when I run it I get the error:

Starting: brickrun --directory="/home/robot/sonar" "/home/robot/sonar/test.py"
Started.
----------
Traceback (most recent call last):
  File "/home/robot/sonar/test.py", line 24, in <module>
  File "ev3dev2/motor.py", line 2531, in on_to_coordinates
AssertionError: odometry_start() must be called to track robot coordinates
----------
Exited with error code 1.

Which is strange since I am calling the odometry_start method. Is this a bug or am I doing something wrong?

Thanks

ADITIONAL NOTE: I am using micropython and I am not sure to be using the lates version of the ev3dev2 modules. But Can not find how to ensure I have the latest released version installed in my Ev3. Any feedback on how to do it? I tried following the instructions on one of the issues and executed:

sudo apt-get update
sudo apt-get install --only-upgrade python3-ev3dev2 micropython-ev3dev2

But told me I already had the latest version installed.

dwalton76 commented 4 years ago

It is a bug specific to micropython :( I have a fix for it as part of https://github.com/ev3dev/ev3dev-lang-python/pull/718/files

WasabiFan commented 4 years ago

Once we merge that PR I'll try to get a release out sooner rather than later.

dwalton76 commented 4 years ago

FYI that one is merged

orioldelos commented 4 years ago

Does this mean the release with the fix is ready?

WasabiFan commented 4 years ago

I can try to do a release soon!

WasabiFan commented 4 years ago

This has been released in version 2.1.0. @orioldelos are you in a position to test this and confirm it's fixed?

Sorry for the delay!

orioldelos commented 4 years ago

I will test it as soon as possible and let you know. I was trying to update my ev3dev2 for micropython but i don't find how I installed it in the first place... what is the best way to install the latest relare of ev3dev2 for micropython?

orioldelos commented 4 years ago

I have upgraded to micropython-ev3dev2 2.1.0 and the error is fixed.