Currently developping on a Pepper robot (Android dev), I'm trying to use some "basic" animations (from QiSQK lib). For instance, when calling a WS, I'm starting a "think" animation using animation/animate. Then, when the WS call ends, I try to use another animation ("showing the tablet").
I saw that Pepper can't animate twice if the previous animation isn't finished/cancelled.
So, I used requestCancellation()
, but it didn't stop the animation.
I also used cancel(mayInterruptIfRunning)
, didn't stop either.
So, I can't chain 2 animations without waiting the previous animation to stop (my WS call = 3-4s max).
Any idea ?
Example :
private var animate: Future<Animate>? = null
fun animate(animRes: Int) {
animate?.requestCancellation()
AnimationBuilder
.with(qiContext)
.withResources(animRes)
.buildAsync()
.thenConsume { futureAnimation ->
animate = AnimateBuilder
.with(qiContext)
.withAnimation(futureAnimation?.value)
.buildAsync()
animate?.andThenConsume {
it.async().run()
}
}
}
Thx, Bastien.
Finally found out my issue.
Actually, I was storing the animate
reference when creating the object like this :
animate = AnimateBuilder
.with(qiContext)
.withAnimation(futureAnimation?.value)
.buildAsync()
So, I printed my objects (like every Future
's used in my callbacks), then I found that after using it.async().run()
from my animate andThenConsume
callback, which returns the running animation reference, is different from the one I created before (was thinking reusing same old ref).
So, instead, here my new (working) code :
fun animate(animRes: Int) {
//Cancelling possible running animation to display a new one
animate?.requestCancellation()
AnimationBuilder
.with(qiContext)
.withResources(animRes)
.buildAsync()
.thenConsume { futureAnimation ->
AnimateBuilder
.with(qiContext)
.withAnimation(futureAnimation?.value)
.buildAsync()
.andThenConsume {
animate = it.async().run() as Future<Animate>
}
}
}