BB9E - play_animation gives TimeoutError
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
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.
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.
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.
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.
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
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
Hi,
I have the same issue with R2-D2...
Regards,
Olivier
@opasco What is the problem?
when I call play_animation() nothing happens and I get a timeout error.
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?
yes, the sounds and lights commands I tried work and the animation commands work fine with Sphero EDU.
Ok, can you send the stack tract of the timeout error here?
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
thanks. can you post your entire code and uncomment this line? https://github.com/artificial-intelligence-class/spherov2.py/blob/2f11b4e68ab4829972ba4e84bf23844c141f2266/spherov2/toy/init.py#L76 and then post the entire output as well.
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
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 https://github.com/artificial-intelligence-class/spherov2.py/commit/b124fe02e97cbc41421800c73af9581eacd2a397 this version. (pip install spherov2=0.8.2) which I know is working.
I actually get the same error after installing version 0.8.2
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.
Any guidance on how I could debug it?
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.