-
Notifications
You must be signed in to change notification settings - Fork 90
Sphero SPRK controlled via Mac fills up queue and lags with executing commands #93
Comments
I just noticed that after the queue is full and it starts to throw errors, it empties the queue approximately every half second (I attached the log below). Then after fully emptying the queue it starts to lag immediately. ` Commands sent: 177 = = = = = = Time Running: 39.431999921798706 = = = = = = = Queue length: 9 Unhandled rejection Error: Command sync response was lost. Commands sent: 177 = = = = = = Time Running: 39.918999910354614 = = = = = = = Queue length: 8 Unhandled rejection Error: Command sync response was lost. Commands sent: 177 = = = = = = Time Running: 40.43999981880188 = = = = = = = Queue length: 7 Unhandled rejection Error: Command sync response was lost. Commands sent: 177 = = = = = = Time Running: 40.92799997329712 = = = = = = = Queue length: 6 |
Could it be related to this bit of code in sphero/lib/sphero.js? /**
this.commandQueue.push({ packet: cmdPacket, resolver: resolve, rejecter: reject }); |
Hello there,
I have a following issue and I hope someone can help me :/
Quick Description of the issue
I am trying to use this https://github.com/charliegerard/leap_sphero.git with my Sphero SPRK. But after I start sending commands to Sphero, the queue fills up and Sphero starts to lag in the real world responses to the commands.
My Question
1/ Did anyone encounter common issue and managed to fix that?
2/ Any tips on what to study to find out how does the queue or how to debug this?
3/ I was thinking of simply dumping the Sphero queue if it is longer than a few commands, any tips how can I do it please?
Fixes tried
1/ I tested on different versions of MacOS (not win and linux however)
2/ I found that the issue could be caused by noble version 1.8.0. I downgraded noble to 1.7.0 as suggested here #85
3/ Call ping() after connect() as suggested here #37
4/ @olcar here #37 said it works for him with Node 5.2.0 so I tried also downgrading to this version
Current Config
Mac OSX 10.12.6
Sphero model: S003, SPRK (not plus)
node -v 9.2.0
"express": "^4.16.2",
"leapjs": "^0.6.4",
"noble": "^1.7.0",
"serialport": "^3.1.2",
"sphero": "^0.9.2"
Detailed Description of the 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 few seconds (or commands, either way it looks random), they suddenly start filling in the queue and execution starts 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 after random seconds (or commands) 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:
/**
*/
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();
};
The text was updated successfully, but these errors were encountered: