artificial-intelligence-class / spherov2.py

Unofficial Python API for all Sphero toys
MIT License
64 stars 24 forks source link

get_location() returning rounded floating point #39

Open mattkiim opened 1 year ago

mattkiim commented 1 year ago

Hi, the get_location() api seems to return a value that is either a rounded floating point, or an integer value that was transformed into a floating value. I'm suspecting it's the latter because of the binary locator flags in [1] and the StreamingService classes in spherov2.py/spherov2/controls/v2.py.

[1]:

class LocatorFlags(IntFlag):
    AUTO_CALIBRATE = 0x1  # 0b1

To reproduce this:

from spherov2 import scanner
from spherov2.adapter.tcp_adapter import get_tcp_adapter
from spherov2.sphero_edu import SpheroEduAPI

toy = scanner.find_toy()
with SpheroEduAPI(toy) as api:
    print(api.get_location())

I am working with Python 3.11.3 64-bit, spherov2 version 0.12, and a Sphero SPRK+.

Other than this issue, this has been a great and simple package to work with, thank you!

superfashi commented 1 year ago

Hi, what do you get as the return value?

mattkiim commented 1 year ago

{'x': 0, 'y': -1} (had to tell the Sphero to spin first, otherwise None is returned)