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

BB9E - play_animation gives TimeoutError #5

Open
mjuchno opened this issue Feb 2, 2021 · 20 comments
Open

BB9E - play_animation gives TimeoutError #5

mjuchno opened this issue Feb 2, 2021 · 20 comments

Comments

@mjuchno
Copy link

mjuchno commented Feb 2, 2021

I played around with basic movement and LEDs and all work great.

However, I wanted to test build-in animations and play_animation() gives me TimeoutError().
I don't see play_animation() in the documentation so I'm not sure if this is really implemented and if it works how I understand it.

Any help would be greatly appreciated.

droid.play_animation(toy.Animations.WWM_SCARED) File "C:\ProgramData\Anaconda3\lib\site-packages\spherov2\sphero_edu.py", line 285, in play_animation ToyUtil.play_animation(self.__toy, animation, True) File "C:\ProgramData\Anaconda3\lib\site-packages\spherov2\utils.py", line 93, in play_animation toy.play_animation(animation, wait) File "C:\ProgramData\Anaconda3\lib\site-packages\spherov2\commands\animatronic.py", line 28, in play_animation toy._execute(Animatronic._encode(toy, 5, proc, to_bytes(animation, 2))) File "C:\ProgramData\Anaconda3\lib\site-packages\spherov2\toy\__init__.py", line 85, in _execute return self._wait_packet(packet.id) File "C:\ProgramData\Anaconda3\lib\site-packages\spherov2\toy\__init__.py", line 90, in _wait_packet packet = future.result(timeout) File "C:\ProgramData\Anaconda3\lib\concurrent\futures\_base.py", line 441, in result raise TimeoutError() concurrent.futures._base.TimeoutError

@superfashi
Copy link
Member

Was the animation being played? If no, then I think BB-9E does not support that animation (or any animation at all).

When I code this, I remember that animations on some droids are actually just a bunch of coordinated movements. Only R2-D2 and -Q5 are for sure equipped with a dedicated animation command, but I forgot whether BB-9E supports that dedicated animation command or just the former case.

When I have time I will look into the code again.

@mjuchno
Copy link
Author

mjuchno commented Feb 2, 2021

Thanks!

The animation was not played but it also did not return "Animation cannot be play by this toy" like it did when I was using IntEnum the wrong way.

The list of Animations(IntEnum) in toy/bb9e.py resembles expressions that are available in the official Droid app so I though that the sequence sits in the firmware and it is trigger by an app.

If this is not the case I will try to reproduce these with raw_motor() sequence but it doesn't seem so responsive as expressions in the Droid app.

@Cole1220
Copy link
Contributor

This is frustrating when it comes to the BB8 model. It doesnt seem to run off the same code as the BB9E and enums for animation dont seem to be relevant although on the app they work just fine.

@superfashi
Copy link
Member

I remember BB8's animation is just a bunch of movements hard-coded on the app side. Check the js file, inside it should have a mapping of an animation to a list of movements.

@Cole1220
Copy link
Contributor

Cole1220 commented Sep 2, 2021

Given BB8 and BB9E are so different, I wont be able to further test BB9E until I can get my hands on one. Updates have been made to the class if that helps. BB8 changes are in pull request

@Cole1220
Copy link
Contributor

Cole1220 commented Sep 3, 2021

I remember BB8's animation is just a bunch of movements hard-coded on the app side. Check the js file, inside it should have a mapping of an animation to a list of movements.

I found this (I think) and this is going to be a while... but it WILL happen

@opasco
Copy link

opasco commented Jun 29, 2022

Hi,

I have the same issue with R2-D2...

Regards,

Olivier

@superfashi
Copy link
Member

@opasco What is the problem?

@opasco
Copy link

opasco commented Jun 30, 2022

when I call play_animation() nothing happens and I get a timeout error.

@superfashi
Copy link
Member

when I call play_animation() nothing happens and I get a timeout error.

does any other command works? Can you try with sphero EDU app and see if it works?

@opasco
Copy link

opasco commented Jun 30, 2022

yes, the sounds and lights commands I tried work and the animation commands work fine with Sphero EDU.

@superfashi
Copy link
Member

Ok, can you send the stack tract of the timeout error here?

@opasco
Copy link

opasco commented Jul 1, 2022

Sure:

Traceback (most recent call last):
  File "/Users/olivierpasco/Library/Mobile Documents/com~apple~CloudDocs/Documents/Apps/Python/Sphero/R2D2Test.py", line 110, in <module>
    droid.play_animation(R2D2.Animations.WWM_YOOHOO)
  File "/Users/olivierpasco/opt/miniconda3/lib/python3.9/site-packages/spherov2/sphero_edu.py", line 289, in play_animation
    ToyUtil.play_animation(self.__toy, animation, True)
  File "/Users/olivierpasco/opt/miniconda3/lib/python3.9/site-packages/spherov2/utils.py", line 93, in play_animation
    toy.play_animation(animation, wait)
  File "/Users/olivierpasco/opt/miniconda3/lib/python3.9/site-packages/spherov2/commands/animatronic.py", line 33, in play_animation
    toy._execute(Animatronic._encode(toy, 5, proc, to_bytes(animation, 2)))
  File "/Users/olivierpasco/opt/miniconda3/lib/python3.9/site-packages/spherov2/toy/__init__.py", line 86, in _execute
    return self._wait_packet(packet.id)
  File "/Users/olivierpasco/opt/miniconda3/lib/python3.9/site-packages/spherov2/toy/__init__.py", line 91, in _wait_packet
    packet = future.result(timeout)
  File "/Users/olivierpasco/opt/miniconda3/lib/python3.9/concurrent/futures/_base.py", line 447, in result
    raise TimeoutError()
concurrent.futures._base.TimeoutError

@superfashi
Copy link
Member

thanks. can you post your entire code and uncomment this line?

# print('request ' + ' '.join([hex(c) for c in payload]))
and then post the entire output as well.

@opasco
Copy link

opasco commented Jul 5, 2022

Here is my code:

import time

from spherov2 import scanner
from spherov2.sphero_edu import SpheroEduAPI
from spherov2.sphero_edu import Stance
from spherov2.types import Color
from spherov2.toy.r2d2 import R2D2

sleep_timer = 5
r2_stance = Stance.Bipod

print("Connecting to Droid...")
toy = scanner.find_toy()
if toy is not None:
    print("Connected to " + toy.toy_type.display_name)
    with SpheroEduAPI(toy) as droid:
        droid.play_animation(R2D2.Animations.WWM_YOOHOO)

        print("Disconnected from " + toy.toy_type.display_name)

And here is the output after uncommenting the line:

Connecting to Droid...
Connected to R2-D2
request 0x8d 0xa 0x13 0xd 0x0 0xd5 0xd8
request 0x8d 0xa 0x17 0xf 0x1 0x0 0x0 0x0 0x0 0xce 0xd8
request 0x8d 0xa 0x17 0xd 0x2 0x1 0xce 0xd8
request 0x8d 0xa 0x18 0x17 0x3 0x0 0xc3 0xd8
request 0x8d 0xa 0x18 0x11 0x4 0x1 0x5a 0x82 0x5a 0x82 0x1 0xe 0xd8
request 0x8d 0xa 0x13 0x5 0x5 0x1 0xd7 0xd8
request 0x8d 0xa 0x18 0xf 0x6 0x1 0xc7 0xd8
request 0x8d 0xa 0x18 0x0 0x7 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0xd6 0xd8
request 0x8d 0xa 0x18 0xc 0x8 0x0 0x0 0x0 0x0 0xc9 0xd8
request 0x8d 0xa 0x18 0x0 0x9 0x0 0x96 0x0 0x0 0x0 0x0 0x0 0x3e 0xd8
request 0x8d 0xa 0x1a 0xe 0xa 0x0 0xff 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0xc4 0xd8
request 0x8d 0xa 0x18 0x13 0xb 0xbf 0xd8
request 0x8d 0xa 0x18 0x0 0xc 0x0 0x0 0x0 0x0 0x7 0xe0 0x78 0x72 0xd8
request 0x8d 0xa 0x18 0xc 0xd 0x3 0x80 0x0 0x0 0x41 0xd8
request 0x8d 0xa 0x18 0x0 0xe 0x0 0x96 0x0 0x0 0x7 0xe0 0x78 0xda 0xd8
request 0x8d 0x3a 0x11 0x1 0x17 0x5 0xf 0x0 0x36 0x52 0xd8
request 0x8d 0xa 0x13 0x1 0x10 0xd1 0xd8
Traceback (most recent call last):
  File "/Users/olivierpasco/Library/Mobile Documents/com~apple~CloudDocs/Documents/Apps/Python/Sphero/R2D2Test.py", line 20, in <module>
    droid.play_animation(R2D2.Animations.WWM_YOOHOO)
  File "/Users/olivierpasco/opt/miniconda3/lib/python3.9/site-packages/spherov2/sphero_edu.py", line 289, in play_animation
    ToyUtil.play_animation(self.__toy, animation, True)
  File "/Users/olivierpasco/opt/miniconda3/lib/python3.9/site-packages/spherov2/utils.py", line 93, in play_animation
    toy.play_animation(animation, wait)
  File "/Users/olivierpasco/opt/miniconda3/lib/python3.9/site-packages/spherov2/commands/animatronic.py", line 33, in play_animation
    toy._execute(Animatronic._encode(toy, 5, proc, to_bytes(animation, 2)))
  File "/Users/olivierpasco/opt/miniconda3/lib/python3.9/site-packages/spherov2/toy/__init__.py", line 86, in _execute
    return self._wait_packet(packet.id)
  File "/Users/olivierpasco/opt/miniconda3/lib/python3.9/site-packages/spherov2/toy/__init__.py", line 91, in _wait_packet
    packet = future.result(timeout)
  File "/Users/olivierpasco/opt/miniconda3/lib/python3.9/concurrent/futures/_base.py", line 447, in result
    raise TimeoutError()
concurrent.futures._base.TimeoutError

@superfashi
Copy link
Member

Ok I don't see anything particularly wrong... I don't have an R2D2 with me so I can't test. One thing you can try is to use b124fe0 this version. (pip install spherov2=0.8.2) which I know is working.

@opasco
Copy link

opasco commented Jul 5, 2022

I actually get the same error after installing version 0.8.2

@superfashi
Copy link
Member

Okay, then I suspect it's model issue, because I knew 0.8.2 was working. You said it works with the Edu App, which is very peculiar. I don't know if you can debug it by yourself, but it looks like your R2-D2 just straight up not accepting the command.

@opasco
Copy link

opasco commented Jul 5, 2022

Any guidance on how I could debug it?

@superfashi
Copy link
Member

one thing you could try doing is to have a BLE packet debugger/interceptor on a Android device, and compare it to the packets sent by python.

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