Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Event with Bolt #26

Open
Dlawlet opened this issue Dec 1, 2022 · 7 comments
Open

Event with Bolt #26

Dlawlet opened this issue Dec 1, 2022 · 7 comments

Comments

@Dlawlet
Copy link

Dlawlet commented Dec 1, 2022

Hello,
I can't seem to use the events (collision, landing, etc.), even the examples given in the API documentation don't work for me. Can I have a full example if it's my code that is the problem.
I am using a win11 with python 3.8.5.
Here is my code:

import sys
from spherov2 import scanner
from spherov2.sphero_edu import SpheroEduAPI, EventType
from spherov2.types import Color


def on_collision(droid):
        droid.stop_roll()
        print('Collision')
        droid.set_heading(droid.get_heading() + 180)
        time.sleep(0.5)
        droid.set_main_led(Color(255, 22, 255))
        droid.set_speed(100)

toy = scanner.find_toy(toy_name=sys.argv[1])
with SpheroEduAPI(toy) as droid:
    for i in range(50):
        droid.register_event(EventType.on_collision, on_collision)
        droid.set_main_led(Color(255, 255, 255))
        droid.set_speed(100)
        time.sleep(.5)```
@superfashi
Copy link
Member

Hi, can you try if using the edu app works?

@Dlawlet
Copy link
Author

Dlawlet commented Dec 1, 2022

yes, with edu app it works

@Dlawlet
Copy link
Author

Dlawlet commented Dec 19, 2022

For the collision event, seem like the fonction _colision_detected_notify() is never called, so i made a fonction to call it manually.
IR event and other still not working for me.

@superfashi
Copy link
Member

#30 Maybe the same reason. Again, without a BOLT it's hard to know why unless you can provide me some debug information.

@poiuytrezaur
Copy link
Contributor

I'm working on various fixes for Bolt.
The handler for collision was not set correctly in bolt.py

I pushed my sandbox branch so you can see the fix here : poiuytrezaur@99c1e05?diff=unified#diff-2ca5105736d73cf3855940cf13b3cdb49c62bf0d65247fc5a49ae5913e79f7feR198

I'll submit a clean PR later next week with all the fixes I did

@poiuytrezaur
Copy link
Contributor

Here's a cleaned up PR for BOLT API : #31

However, the collision packet fails to decode (wrong packet size, expected 18 bytes but packet sent by bolt is 16 bytes). I don't have access to a decompiled version of the EDU API so I can't check how the event args are decoded.

My temporary workaround until the event args are properly decoded can be found here : poiuytrezaur@617d133

This enables to retrieve the event, without args (like EDU API)

@marlow-fawn
Copy link

Wanted to bump this - Also getting wrong packet size.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants