sphero-inc / sphero.js

🚫 DEPRECATED: The Sphero JavaScript SDK to control Sphero robots.

Home Page:http://sdk.sphero.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Any way to reset BB8?

debu66er opened this issue · comments

Hi, playing around with BB8 and this SDK after sometime, it seems BB8 gets hanged. Usually it is a matter of time, or sometimes if I start the official mobile app it starts working again.

Is there any function in the SDK to reset, initialize or anything similar to try to fix BB8 from my code? I took a look but I didn't find any obvious function name.

This info: https://sphero.zendesk.com/hc/en-us/articles/205382404-Q-How-do-I-reset-BB-8- doesn't help. Investigating now if it is a matter of low battery... it seems it works again when I put BB8 on the platform and it stops moving. What doesn't make sense is that official mobile app still working.

The behavior is I don't get reaction to any command sent and I receive this exception:

Unhandled rejection Error: Command sync response was lost.
at Sphero.handler (/Users/sp11382/IoT2BB8/node_modules/sphero/lib/sphero.js:252:21)
at Timer.listOnTimeout (timers.js:92:15)

Thanks!

Thanks in advance!

At the end, I am not able to explain when this issue happens. It seems some how random and related with battery. But I was able to find a not scientific procedure to recover it which is connect() and disconnect() several times from my app previous reset once on the platform.

What I see is that when connecting, BB8 executes the commands that failed before. It is like it has memory and as it didn't answered before it is trying to answer now. So after I connect and disconnect several times it seems I clean its queue or whatever it has and it starts working again.

Any function to clean, reset or whatever it needs to start from scratch?

Finally, a ping() call after connect() function avoided any more hanged.

commented

Hi, could you explain what you mean with ping() call after connect() ? thx.

I can't explain why this fixed my problem.... but this is the code:

bb8.connect(function()
{
console.log("##### Connected to BB8");
bb8.ping(); // Workaround for BB8 hangs?
});

@jmvandamme were you able to resolve the issue with a ping() call?

Hi, it looks like I have very common issue. Did you manage to fix that?

I am trying to use this https://github.com/charliegerard/leap_sphero.git

I tested on different versions of MacOS, but I still have the same issue.

Fixes tried
1/ I found that the issue could be caused by noble version 1.8.0. I downgraded noble to 1.7.0, but I still have the issue.

2/ Call ping() after connect() #37

Current Config
Mac OSX 10.12.6
Sphero model: S003, SPRK (not plus)
"express": "^4.16.2",
"leapjs": "^0.6.4",
"noble": "^1.7.0",
"serialport": "^3.1.2",
"sphero": "^0.9.2"

Issue
I only send roll commands to sphero, and I limit them to one command every 200ms.

Fist few commands execute instantly, but then after 10-20 seconds (about 30-50 commands), they suddenly they start lagging up to few seconds long lags and I was getting following message

Unhandled rejection Error: Command sync response was lost.
at Sphero.handler (/Users/martin/Workspace/LEAP Sphero MJ/node_modules/sphero/lib/sphero.js:252:21)
at ontimeout (timers.js:475:11)
at tryOnTimeout (timers.js:310:5)
at Timer.listOnTimeout (timers.js:270:5)

I tried sending commands more often and less often, it made no difference.

And I also tried waiting (for example 60 seconds) and then started sending commands. It looks like Sphero starts to lag 10-20 seconds after I start to send commands no matter how many commands I send and how much I waited before.

The error line is in this funcion:

/**

  • Adds a promise to the queue, to be executed when a response
  • gets back from the sphero.
  • @Private
  • @param {Array} cmdPacket the bytes array to be send through the wire
  • @param {Function} resolve function to be triggered on success
  • @param {Function} reject function to be triggered on failure
  • @example
  • sphero._execCommand(packet, resolve, reject);
  • @return {void}
    */
    Sphero.prototype._queuePromise = function(cmdPacket, resolve, reject) {
    var seq = cmdPacket[4];
    var handler = function(err, packet) {
    clearTimeout(this.responseQueue[seq].timeoutId);
    this.responseQueue[seq] = null;
    this.busy = false;
    if (typeof resolve === "function") {
    if (!err && !!packet) {
    resolve(packet);
    } else {
    var error = new Error("Command sync response was lost.");
    reject(error);
    }
    }
    this._execCommand();
    };