sphero-inc / sphero.js Goto Github PK
View Code? Open in Web Editor NEW๐ซ DEPRECATED: The Sphero JavaScript SDK to control Sphero robots.
Home Page: http://sdk.sphero.com
License: MIT License
๐ซ DEPRECATED: The Sphero JavaScript SDK to control Sphero robots.
Home Page: http://sdk.sphero.com
License: MIT License
Hi, I am trying to create a script which will connect to a Sphero robot, disconnect, and then reconnect. Is this possible?
Hi,
I'm trying to program BB-8 with the Javascript API. I'm on Windows 10 and have installed all the necessary dependencies, and I am using a bluetooth 4.0 USB. When I run a basic script, f.e. just change the color of BB-8, the robot does it successfully. But when trying to get a response back, I always get the error:
Unhandled rejection Error: Command sync response was lost.
at Sphero.handler (C:\Users\toonr\AppData\Roaming\npm\node_modules\sphero\lib\sphero.js:252:21)
at ontimeout (timers.js:380:14)
at tryOnTimeout (timers.js:244:5)
at Timer.listOnTimeout (timers.js:214:5)
Or, when using Cylon.js, a similar error:
Error: Command sync response was lost.
at Sphero.cb (C:\Users\toonr\AppData\Roaming\npm\node_modules\cylon-sphero-ble\node_modules\sphero\lib\sphero.js:243:21)
at ontimeout (timers.js:380:14)
at tryOnTimeout (timers.js:244:5)
at Timer.listOnTimeout (timers.js:214:5)
Noble also throws a warning before this error, saying an unknown handle is disconnected.
So executing a command (or multiple) is working perfectly, but I can't seem to get data back from the BB-8. Any ideas on what the cause could be? Thanks in advance!
Hey there !
I tried to use SpheroJS to command my BB-8 Sphero.
I successfully installed sphero and noble packages but when I start this script:
var sphero = require("sphero");
var orb = sphero("XX:XX:XX:XX:XX:XX");
orb.connect(function() {
console.log("BB-8 connected");
orb.color("blue");
orb.roll(360, 0)
});
it tell me this :
It looks like you want to connect to a Sphero BB-8 or Sphero Ollie,
but did not install the 'noble' module.
To install it run this command:
npm install noble
For more information go to https://github.com/sandeepmistry/noble
X:\Programmation\NodeJS\bb8\node_modules\sphero\lib\adaptors\ble.js:33
throw new Error("Missing noble dependency");
^
Error: Missing noble dependency
By the way, noble is installed !
So please, can you edit your README to give me the instructions that allow me to make things work.
Thanks !
Xavier
Greetings,
I'm trying to connect to my BB-8, but when I run advertisement-discovery.js
it just hangs and never prints anything.
I can connect with the iOS app. The first time it did a firmware update.
I make sure BB-8 is fully charged. Then I remove him from the charging station, and set him on the floor right next to my MacBook Pro. BB-8 doesn't activate or light up when I do this. The I run advertisement-discovery.js
, but nothing prints. I tried moving BB-8 all around in close proximity to the laptop.
I tried resetting BB-8, which wakes him up, and then repeating the above procedure with him active, but no change.
package.json:
[...]
"dependencies": {
"noble": "^1.8.1",
"sphero": "^0.9.2"
}
}
noble and sphero install:
$ npm install
> [email protected] install /Users/ibrandt/Development/BrandtAcademy/git/bb8/node_modules/xpc-connection
> node-gyp rebuild
CXX(target) Release/obj.target/binding/src/XpcConnection.o
../src/XpcConnection.cpp:143:44: warning: 'GetRealNamedProperty' is deprecated [-Wdeprecated-declarations]
Local<Value> propertyValue = object->GetRealNamedProperty(propertyName->ToString());
^
/Users/ibrandt/.node-gyp/6.10.3/include/node/v8.h:2923:30: note: 'GetRealNamedProperty' has been explicitly marked
deprecated here
Local<Value> GetRealNamedProperty(Local<String> key));
^
1 warning generated.
SOLINK_MODULE(target) Release/binding.node
clang: warning: libstdc++ is deprecated; move to libc++ with a minimum deployment target of OS X 10.9 [-Wdeprecated]
> [email protected] install /Users/ibrandt/Development/BrandtAcademy/git/bb8/node_modules/usb
> node-pre-gyp install --fallback-to-build
node-pre-gyp info it worked if it ends with ok
node-pre-gyp verb cli [ '/usr/local/Cellar/node@6/6.10.3_1/bin/node',
node-pre-gyp verb cli '/Users/ibrandt/Development/BrandtAcademy/git/bb8/node_modules/usb/node_modules/.bin/node-pre-gyp',
node-pre-gyp verb cli 'install',
node-pre-gyp verb cli '--fallback-to-build' ]
node-pre-gyp info using [email protected]
node-pre-gyp info using [email protected] | darwin | x64
node-pre-gyp verb command install []
node-pre-gyp info check checked for "/Users/ibrandt/Development/BrandtAcademy/git/bb8/node_modules/usb/src/binding/usb_bindings.node" (not found)
node-pre-gyp http GET https://github.com/tessel/node-usb/releases/download/1.2.0/usb_bindings-v1.2.0-node-v48-darwin-x64.tar.gz
node-pre-gyp http 200 https://github.com/tessel/node-usb/releases/download/1.2.0/usb_bindings-v1.2.0-node-v48-darwin-x64.tar.gz
node-pre-gyp info install unpacking usb_bindings.node
node-pre-gyp info tarball done parsing tarball
node-pre-gyp info validate Running test command: '/usr/local/Cellar/node@6/6.10.3_1/bin/node --eval 'require(\'/Users/ibrandt/Development/BrandtAcademy/git/bb8/node_modules/usb/src/binding/usb_bindings.node\')''
[usb] Success: "/Users/ibrandt/Development/BrandtAcademy/git/bb8/node_modules/usb/src/binding/usb_bindings.node" is installed via remote
node-pre-gyp info ok
> [email protected] install /Users/ibrandt/Development/BrandtAcademy/git/bb8/node_modules/bluetooth-hci-socket
> node-gyp rebuild
SOLINK_MODULE(target) Release/binding.node
clang: warning: libstdc++ is deprecated; move to libc++ with a minimum deployment target of OS X 10.9 [-Wdeprecated]
added 295 packages in 12.177s
advertisement-discovery.js
with debug, hangs indefinitely at "noble scanStart":
$ DEBUG=* node ./node_modules/noble/examples/advertisement-discovery.js
noble addressChange 6c:40:08:ba:98:f1 +0ms
yosemite-bindings sendCBMsg: 1, {
"kCBMsgArgName": "node-1497250667277",
"kCBMsgArgOptions": {
"kCBInitOptionShowPowerAlert": 0
},
"kCBMsgArgType": 0
} +3ms
yosemite-bindings xpcEvent: {
"kCBMsgId": 6,
"kCBMsgArgs": {
"kCBMsgArgState": 5
}
} +2ms
yosemite-bindings state change poweredOn +0ms
noble stateChange poweredOn +0ms
yosemite-bindings sendCBMsg: 29, {
"kCBMsgArgOptions": {},
"kCBMsgArgUUIDs": []
} +1ms
noble scanStart +0ms
^C
MacBook Pro (Retina, 15-inch, Mid 2014):
Apple Bluetooth Software Version: 5.0.4f18
Hardware, Features, and Settings:
Name: Ian's MacBook Pro
Address: 6c-40-08-ba-98-f1
Bluetooth Low Energy Supported: Yes
Handoff Supported: Yes
Instant Hot Spot Supported: Yes
Manufacturer: Broadcom
Transport: USB
Chipset: 20702B0
Firmware Version: v137 c9260
Bluetooth Power: On
Discoverable: Off
Connectable: Yes
Auto Seek Pointing: On
Remote wake: On
Vendor ID: 0x05AC
Product ID: 0x8289
HCI Version: 4.0 (0x6)
HCI Revision: 0x242C
LMP Version: 4.0 (0x6)
LMP Subversion: 0x4189
Device Type (Major): Computer
Device Type (Complete): Mac Portable
Composite Class Of Device: 0x38010C
Device Class (Major): 0x01
Device Class (Minor): 0x03
Service Class: 0x1C0
Auto Seek Keyboard: On
OS X Version 10.12.5 (16F73)
Xcode Version 8.3.3 (8E3004b)
Node.js v6.10.3
Hey,
I'm trying to pair my BB-8 with my Macbook and I can't seem to find how to.
I've followed every step, installed noble, installed sphero SDK, got my BB-8 UUID, no problem there.
Then I tried to pair it and this is where I'm stuck. First of, it seems my Macbook doesn't not support BLE connection since it was never able to detect the BB-8. I downloaded LightBlue on the AppStore and I was able to see the BB-8 and connect it.
However, I can seem to find the tty.Sphero thingy.
When I type this command ls -a /dev | grep tty.Sphero
, it returns nothing.
Any ideas?
Trying to say YES or NO for example.
Haven't found any function at https://github.com/orbotix/sphero.js/blob/master/lib/commands/sphero.js although the official mobile app supports it.
Thanks!
Upon calling getBluetoothInof() or getPowerStateInfo() or any other methods that contain data in buffer format, the methods return buffer data instead of human readable data.
For instance:
{ sop1: 255,
sop2: 255,
mrsp: 0,
seq: 0,
dlen: 33,
data: <Buffer 53 70 68 65 72 6f 2d 47 52 50 00 00 00 00 00 00 36 38 38 36 65 37 30 34 64 63 37 65 00 47 52 50>,
checksum: 47 }
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:
/**
So I realize that I need the additional npm dependency noble
, which I've installed locally (do I need it globally installed)? I am trying to run a simple script from the examples, as follows:
// test.js
var sphero = require("sphero"),
bb8 = sphero("D6:35:5E:95:BA:A2"); // change BLE address accordingly
bb8.connect(function() {
// roll BB-8 in a random direction, changing direction every second
setInterval(function() {
var direction = Math.floor(Math.random() * 360);
bb8.roll(150, direction);
}, 1000);
});
Despite the fact that I have noble
installed and in node_modules
, I'm getting the following:
โ sphero git:(master) โ node test.js
It looks like you want to connect to a Sphero BB-8 or Sphero Ollie,
but did not install the 'noble' module.
To install it run this command:
npm install noble
For more information go to https://github.com/sandeepmistry/noble
/Users/brianfeister/dev/node_modules/sphero/lib/adaptors/ble.js:32
throw new Error("Missing noble dependency");
^
Error: Missing noble dependency
at initBLE (/Users/brianfeister/dev/node_modules/sphero/lib/adaptors/ble.js:32:11)
at new Adaptor (/Users/brianfeister/dev/node_modules/sphero/lib/adaptors/ble.js:51:5)
at Object.load (/Users/brianfeister/dev/node_modules/sphero/lib/loader.js:29:10)
at new Sphero (/Users/brianfeister/dev/node_modules/sphero/lib/sphero.js:52:44)
at sphero (/Users/brianfeister/dev/node_modules/sphero/index.js:21:10)
at Object.<anonymous> (/Users/brianfeister/dev/sphero/test.js:2:11)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
โ sphero git:(master) โ npm install noble
npm WARN optional dep failed, continuing [email protected]
> [email protected] install /Users/brianfeister/dev/sphero/node_modules/noble/node_modules/xpc-connection
> node-gyp rebuild
CXX(target) Release/obj.target/binding/src/XpcConnection.o
SOLINK_MODULE(target) Release/binding.node
[email protected] node_modules/noble
โโโ [email protected]
โโโ [email protected] ([email protected])
โโโ [email protected] ([email protected])
โ sphero git:(master) โ node test.js
It looks like you want to connect to a Sphero BB-8 or Sphero Ollie,
but did not install the 'noble' module.
To install it run this command:
npm install noble
For more information go to https://github.com/sandeepmistry/noble
/Users/brianfeister/dev/node_modules/sphero/lib/adaptors/ble.js:32
throw new Error("Missing noble dependency");
^
Error: Missing noble dependency
at initBLE (/Users/brianfeister/dev/node_modules/sphero/lib/adaptors/ble.js:32:11)
at new Adaptor (/Users/brianfeister/dev/node_modules/sphero/lib/adaptors/ble.js:51:5)
at Object.load (/Users/brianfeister/dev/node_modules/sphero/lib/loader.js:29:10)
at new Sphero (/Users/brianfeister/dev/node_modules/sphero/lib/sphero.js:52:44)
at sphero (/Users/brianfeister/dev/node_modules/sphero/index.js:21:10)
at Object.<anonymous> (/Users/brianfeister/dev/sphero/test.js:2:11)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
โ sphero git:(master) โ
When I close my app, I disconnect before from BB8 with disconnect() function and then BB8 turns on an "orange" light and reminds like that until I connect to it again.
That is a problem with the battery life. Is it a bug? (BTW, it seems it turns off after 5-6 minutes).
Using Sphero v0.9.2
With my Ollie, I am able connect and send/get data to/from Ollie but I have a problem. After noble loses connection with Ollie for a moment, commandQueue
property of Sphero
constructor fills up quickly and it gets stuck and new commands don't execute on time, (they execute after 1 or 2 min). And the queue is processed when a new command is sent (line 177), so it becomes a vicious circle with no end. One solution I found was to reduce the 256
limit to 1, but it defeats the purpose of the queue.
package.json reference the exact version [email protected] which DOES NOT COMPILE on Raspberry Pi, and breaks the whole Sphero package.
However if you npm install the latest version of serialport (2.0.5), it works well.
Referencing exact versions is BAD PRACTICE.
Please correct your dependencies to allow updated versions!
R2D2 is showing up as a BLE device using LightBlue for Mac.
I'm able to use this to obtain the UUID for the sphero sdk connection.
` var sphero = require('sphero');
var r2 = sphero('73ECD53D-B7FE-47E1-B86E-9AF39A880ABE');
r2.connect(function() {
console.log("Now connected to R2");
//The Ping command verifies that R2 is awake and receiving commands.
r2.ping(function(err, data) {
console.log(err || data);
});`
When running, the output is simply:
noble addressChange 28:f0:76:12:44:91 +0ms yosemite-bindings sendCBMsg: 1, { "kCBMsgArgName": "node-1513679700187", "kCBMsgArgOptions": { "kCBInitOptionShowPowerAlert": 0 }, "kCBMsgArgType": 0 } +3ms yosemite-bindings xpcEvent: { "kCBMsgId": 4, "kCBMsgArgs": { "kCBMsgArgState": 5 } } +2ms
Hi,
I'm an Ubuntu newbie and I'm struggling to use the sphero package.
Using your main example I am just getting the following error;
Cannot open /dev/rfcomm0
I have connected the sphero using bluetooth manager and it says the device is connected.
I have also added the following to a new file called - /etc/udev/rules.d/55-rfcomm.rules;
KERNEL=="rfcomm[0-9]*", NAME="%k", GROUP="dialout"
Any help would be great.
Thanks
Hi,
I'm using this Javascript SDK to control my BB-8 but I can barely not connect my pc to my BB-8.
var sphero = require("sphero");
var bb8 = sphero("e0e55aa81faf");
console.log('Application started');
bb8.connect(function() {
console.log("Connect");
}
This piece of code will most of the time prompt : Application started
only.
Perhaps, 1 in 10 time, there is the Connect
message.
Am I missing somethings ?
Should I press the dock side button ? (BTW what does this button ?)
Is there a precise time when I should start my app ?
The advertisement-discovery.js and peripheral-explorer.js works (most of the time).
The official App works too (most of the time).
(Windows 10, Node v6.10.2, Sphero 0.9.2)
This is for the /examples
.profile
, the likelyhood to collide with other variables is too highJust suggesting. Btw if you ok the change, i can do the pull-request
Since last commit dff80df "Minor formatting changes" the function color() is not working.
Probably due to the changes on function hexToRgb().
Hey dev team,
I started to develop a functionality to move sphero to a defined waypoint. You can integrate this feature in your sdk.
There are two open tasks:
Function:
function goToPosition(pos, x, y, speed) {
last_angle = 0;
var locationInterval = setInterval(function() {
orb.readLocator(function(err, data) {
if (err) {
console.log("error: ", err);
} else {
var xcomp = (x - data.xpos == 0) ? 1 : (x - data.xpos);
var ycomp = (y - data.ypos == 0) ? 1 : (y - data.ypos);
var angle = Math.atan(ycomp / xcomp);
angle = angle * 180 / Math.PI;
if(angle < 90) {
angle = 90 - angle;
}
if((x - data.xpos) < 0) {
angle = angle + 180;
}
console.log(" --" + pos + "--");
console.log(" xpos:", data.xpos);
console.log(" ypos:", data.ypos);
console.log(" xerror:", x - data.xpos);
console.log(" yerror:", y - data.ypos);
console.log(" angle:", angle );
orb.roll(speed, angle);
// positon arrived
if(((angle < 0) || (Math.abs(angle - last_angle) > 50)) && (last_angle != 0)) {
clearInterval(locationInterval);
orb.stop();
console.log("Position arrived!");
}
last_angle = angle;
}
});
}, 500);
}
An example use case:
var sphero = require("sphero"),
orb = sphero("EE:75:8E:48:D5:6D"); // change BLE address accordingly
var last_angle = 0;
/* place function goToPostion() {...} here */
orb.connect(function() {
var opts = {
flags: 0x01,
x: 0x0000,
y: 0x0000,
yawTare: 0x0
};
console.log("::START CALIBRATION::");
orb.startCalibration();
setTimeout(function() {
console.log("::FINISH CALIBRATION::");
orb.finishCalibration();
orb.setBackLed(255);
orb.configureLocator(opts);
orb.color({ red: 255, green: 0, blue: 0 });
goToPosition("toPos1", 0, 350, 50);
setTimeout(function() {
goToPosition("toPos2", 200, 350, 50);
setTimeout(function() {
goToPosition("toPos3", 200, 100, 50);
setTimeout(function() {
goToPosition("toPos4", 5, 5, 50);
}, 10000);
}, 10000);
}, 10000);
}, 5000);
});
I'm happy about feedback the the current code and help for the open tasks. Next step will be to enable communication between to spheros for simulation swarm intelligence. Feel free to contact me if you want to support.
Bye,
Niklas
I've got the following code which works for the most part, except that the callback is never called from
ollie.connect()
const bleAddress = "e7:40:98:2a:20:8d";
noble = Npm.require('noble');
sphero = Npm.require('sphero');
// Cylon = Npm.require('cylon');
// Npm.require('cylon-ble');
noble.on('stateChange', function(state) {
if (state === 'poweredOn') {
console.log("Scanning for ollie's in the area...");
noble.startScanning();
} else {
noble.stopScanning();
}
});
noble.on('discover', function(peripheral) {
if(peripheral.address === bleAddress) {
console.log('Found your ollie!');
if(peripheral.connectable) {
console.log('I can connect to it');
console.log('Attempting to connect now');
noble.stopScanning();
console.dir('device uuid is: ' + peripheral.uuid);
ollie = sphero(peripheral.uuid);
ollie.connect(function() {
console.log('connected!');
});
ollie.on('error', function() {
console.log('error');
})
}else {
console.log('Womp womp, I cant connect to it right now');
}
}
});
Hi, I'm one of the MSPs working on the Sphero pilot program. I've been doing a lot of research trying to figure out how to calibrate the Sphero without physically picking it up.
I found that on other platforms the way of doing this is to start calibration and then set heading (I believe). How might I do this with node.
I already have a custom element slider that generates a number between 0 and 360 that the user can use to calibrate the Sphero.
Thanks so much!
Does this package support ollie? Otherwise, are you working on making ollie a similar package?
Hi,
Is it possible to have access to the heading value of bb8 ? I search for this functionality but I find nothing to get it and it could be useful to have it.
Thanks
Related to #42.
Could the project require both dependencies and use config options to determine which device is being used?
This would probably simplify the installation process and make the examples clearer?
e.g
device = sphero('########', { device: 'ollie' });
device = sphero('########', { device: 'bb8' });
device = sphero('########'); // falls back to original setup
I am working to get the Ollie up and running on a windows 10 machine. I have installed node, node-gyp, noble, sphero noble, and their dependencies. I can successfully find Bluetooth connections via ./advertisement-discovery.js, and can connect to peripherals using ./peripheral-explorer.js, however when I run the basic connection example with the Ollie's address, I get the following output:
C:\Users\IronLab\Desktop\test\node_modules\sphero\lib\adaptors\ble.js:404
return this._connectedService(serviceId).characteristics;
^
TypeError: Cannot read property 'characteristics' of null
at Adaptor._connectedCharacteristics (C:\Users\IronLab\Desktop\test\node_modules\sphero\lib\adaptors\ble.js:404:43)
at Adaptor._connectCharacteristic (C:\Users\IronLab\Desktop\test\node_modules\sphero\lib\adaptors\ble.js:357:12)
at C:\Users\IronLab\Desktop\test\node_modules\sphero\lib\adaptors\ble.js:302:12
at Adaptor._connectService (C:\Users\IronLab\Desktop\test\node_modules\sphero\lib\adaptors\ble.js:338:5)
at C:\Users\IronLab\Desktop\test\node_modules\sphero\lib\adaptors\ble.js:300:10
at Adaptor._connectBLE (C:\Users\IronLab\Desktop\test\node_modules\sphero\lib\adaptors\ble.js:324:5)
at Adaptor.getCharacteristic (C:\Users\IronLab\Desktop\test\node_modules\sphero\lib\adaptors\ble.js:299:8)
at Adaptor.writeServiceCharacteristic (C:\Users\IronLab\Desktop\test\node_modules\sphero\lib\adaptors\ble.js:274:8)
at Adaptor.setTXPower (C:\Users\IronLab\Desktop\test\node_modules\sphero\lib\adaptors\ble.js:203:8)
at C:\Users\IronLab\Desktop\test\node_modules\sphero\lib\adaptors\ble.js:156:10
Am I missing an extra dependency?
Hello, I am trying to get BB8 saying YES with the head, but I am not able. Any help?
I know I should get it doing moving the body (as the head is not independent) but no luck with my quick forward and backward roll tries.
Thanks!
With products that aren't orbs (like the Ollie) would it be better to have examples that have a more neutral name than orb
?
Could do device
? Not sure about it, sounds a bit crap. Thoughts?
Hi,
I was just testing with collision detection and I am not getting asynchronous messages when BB-8 has a collision. Has anyone tested if it works? I added a line to tell it to roll in the examples/collision-detection.js:
var sphero = require("../");
var orb = sphero(process.env.PORT);
orb.connect(function() {
orb.detectCollisions();
orb.color("green");
orb.on("collision", function(data) {
console.log("collision detected");
console.log(" data:", data);
orb.color("red");
setTimeout(function() {
orb.color("green");
}, 1000);
});
orb.roll(200, 0);
});
No colour change, no console log output.
I am running on Ubuntu 14.04, nodejs = 0.10.25 and BB-8's firmware = 4.63.
Is it possible to send raw motor commands using the sphero.js API?
I was able to connect and control bb8 using standard commands, but am I correct in assuming that controlling the head is not supported? I'd be happy to investigate how to add it if someone could point me in the right direction. Is there a way to interface the motors directly?
> [email protected] install /home/kran/Code/orbotix/sphero.js/node_modules/serialport
> node-pre-gyp install --fallback-to-build
make: Entering directory `/home/kran/Code/orbotix/sphero.js/node_modules/serialport/build'
CXX(target) Release/obj.target/serialport/src/serialport.o
In file included from ../src/serialport.h:5:0,
from ../src/serialport.cpp:3:
../node_modules/nan/nan.h:261:25: error: redefinition of โtemplate<class T> v8::Local<T> _NanEnsureLocal(v8::Local<T>)โ
NAN_INLINE v8::Local<T> _NanEnsureLocal(v8::Local<T> val) {
^
../node_modules/nan/nan.h:256:25: error: โtemplate<class T> v8::Local<T> _NanEnsureLocal(v8::Handle<T>)โ previously declared here
NAN_INLINE v8::Local<T> _NanEnsureLocal(v8::Handle<T> val) {
^
../node_modules/nan/nan.h:661:13: error: โnode::smallocโ has not been declared
, node::smalloc::FreeCallback callback
^
../node_modules/nan/nan.h:661:35: error: expected โ,โ or โ...โ before โcallbackโ
, node::smalloc::FreeCallback callback
^
../node_modules/nan/nan.h: In function โv8::Local<v8::Object> NanNewBufferHandle(char*, size_t, int)โ:
../node_modules/nan/nan.h:665:50: error: โcallbackโ was not declared in this scope
v8::Isolate::GetCurrent(), data, length, callback, hint);
^
../node_modules/nan/nan.h:665:60: error: โhintโ was not declared in this scope
v8::Isolate::GetCurrent(), data, length, callback, hint);
^
../node_modules/nan/nan.h: In function โv8::Local<v8::Object> NanNewBufferHandle(const char*, uint32_t)โ:
../node_modules/nan/nan.h:672:67: error: call of overloaded โNew(v8::Isolate*, const char*&, uint32_t&)โ is ambiguous
return node::Buffer::New(v8::Isolate::GetCurrent(), data, size);
^
../node_modules/nan/nan.h:672:67: note: candidates are:
In file included from ../node_modules/nan/nan.h:25:0,
from ../src/serialport.h:5,
from ../src/serialport.cpp:3:
/home/kran/.node-gyp/4.2.1/include/node/node_buffer.h:31:40: note: v8::MaybeLocal<v8::Object> node::Buffer::New(v8::Isolate*, v8::Local<v8::String>, node::encoding) <near match>
NODE_EXTERN v8::MaybeLocal<v8::Object> New(v8::Isolate* isolate,
^
/home/kran/.node-gyp/4.2.1/include/node/node_buffer.h:31:40: note: no known conversion for argument 3 from โuint32_t {aka unsigned int}โ to โnode::encodingโ
/home/kran/.node-gyp/4.2.1/include/node/node_buffer.h:43:40: note: v8::MaybeLocal<v8::Object> node::Buffer::New(v8::Isolate*, char*, size_t) <near match>
NODE_EXTERN v8::MaybeLocal<v8::Object> New(v8::Isolate* isolate,
^
/home/kran/.node-gyp/4.2.1/include/node/node_buffer.h:43:40: note: no known conversion for argument 2 from โconst char*โ to โchar*โ
In file included from ../src/serialport.h:5:0,
from ../src/serialport.cpp:3:
../node_modules/nan/nan.h: In function โv8::Local<v8::Object> NanNewBufferHandle(uint32_t)โ:
../node_modules/nan/nan.h:676:61: error: could not convert โnode::Buffer::New(v8::Isolate::GetCurrent(), ((size_t)size))โ from โv8::MaybeLocal<v8::Object>โ to โv8::Local<v8::Object>โ
return node::Buffer::New(v8::Isolate::GetCurrent(), size);
^
../node_modules/nan/nan.h: In function โv8::Local<v8::Object> NanBufferUse(char*, uint32_t)โ:
../node_modules/nan/nan.h:683:12: error: โUseโ is not a member of โnode::Bufferโ
return node::Buffer::Use(v8::Isolate::GetCurrent(), data, size);
^
make: *** [Release/obj.target/serialport/src/serialport.o] Error 1
make: Leaving directory `/home/kran/Code/orbotix/sphero.js/node_modules/serialport/build'
I think that there is probably something that I'm missing in my environment, but I can't find anything.
bb8.color("red",-0.5); shows light red color but bb8.color("red",0); and bb8.color("red",0.5); show exactly the same red color.
0.5 is not brighter than 0 as I understood it should be from the examples. I tested to change between them several times and there is no change. I just see change with -0.5
Hi,
I have a stupid question but really I don't understand what's going on. By running an example from the official documentation (http://sdk.sphero.com/community-apis/javascript-sdk/), I wanted to let my bb8 to blink according the following script:
bb8.connect(function() {
var i = 0;
do {
setTimeout(function() {bb8.color("red");} , 1000);
setTimeout(function() {bb8.color("green");} , 1000);
i++
} while (i<6);
});
....but bb8 blinks too fast and does not wait a second before to change the color.
This is probably not an issue with this sdk, but I already used setTimeout on other scripts but without this unexpected behavior...
Thanks in advance for any help you could provide.
Hi,
I would like to expose most of the commands (color, roll, etc, ....) as web services in order to control my device across various channels (ifttt, cortana, node-red, etc...)
Therefore, I have installed "restify" but bb8.connect is not fired when the command is embedded into a function. Below a simplified version of the source code to keep the most important elements:
var sphero = require("sphero");
var bb8 = sphero("xxxx");
var restify = require("restify");
var server = restify.createServer({
name: "bb8-rest-api",
version: "1.0.0"
});
function bb8_SetColor(req, res, next) {
bb8.connect(function() {
console.log("connected");
bb8.color(req.params.color);
}
res.send(200);
return next();
});
server.get("/color/:color", bb8_SetColor);
server.listen("8081", function() {});
I have of course added several console.log and up to bb8.connect, the code is well executed and then nothing else happen after while the same code outside the function works fine.
Any ideas why the command is not recognised?
Thanks for any help you will provide
when use color("black"), the terminal show "invalid color provided black".
it seems that the sphero.js can't accpet this color.
if i change the code to color(0x0), the sphero turns to white color.
so how to ture off the RGB led of sphero?
Hello! I get unhandled error
very often when trying to connect to the Sphero 2.0. It succeeds in connecting to the Sphero approximately (or rather almost exactly) every third time. The times it fails I get the following output:
events.js:160
throw er; // Unhandled 'error' event
^
Error: Opening COM79: Unknown error code 121
at Error (native)
Somebody having the same issue? Any ideas?
Hi, I've encountered a difficulty connecting through serial-port library (refer to hybridgroup/cylon#310). I've added a new adaptor to handle bluetooth connection via MACAddress and modified the loader.js to automatically handle port input with bluetooth MACAddress. You can check out the codes at my fork (vincent-leonardo@f2658f6). If you don't mind, I could create a pull request for it.
Installation log:
E:\dev\projects\sphero>npm install sphero
> [email protected] install E:\dev\projects\sphero\node_modules\sphero\node_modules\serialport
> node-pre-gyp install --fallback-to-build
E:\dev\projects\sphero\node_modules\sphero\node_modules\serialport>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" clean ) else (node clean )
E:\dev\projects\sphero\node_modules\sphero\node_modules\serialport>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" configure --fallback-to-build --module=E:\dev\projects\sphero\node_modules\sphero\node_modules\serialport\build\serialport\v1.7.1\Release\node-v46-win32-x64\serialport.node --module_name=serialport --module_path=E:\dev\projects\sphero\node_modules\sphero\node_modules\serialport\build\serialport\v1.7.1\Release\node-v46-win32-x64 ) else (node configure --fallback-to-build --module=E:\dev\projects\sphero\node_modules\sphero\node_modules\serialport\build\serialport\v1.7.1\Release\node-v46-win32-x64\serialport.node --module_name=serialport --module_path=E:\dev\projects\sphero\node_modules\sphero\node_modules\serialport\build\serialport\v1.7.1\Release\node-v46-win32-x64 )
E:\dev\projects\sphero\node_modules\sphero\node_modules\serialport>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" build --fallback-to-build --module=E:\dev\projects\sphero\node_modules\sphero\node_modules\serialport\build\serialport\v1.7.1\Release\node-v46-win32-x64\serialport.node --module_name=serialport --module_path=E:\dev\projects\sphero\node_modules\sphero\node_modules\serialport\build\serialport\v1.7.1\Release\node-v46-win32-x64 ) else (node build --fallback-to-build --module=E:\dev\projects\sphero\node_modules\sphero\node_modules\serialport\build\serialport\v1.7.1\Release\node-v46-win32-x64\serialport.node --module_name=serialport --module_path=E:\dev\projects\sphero\node_modules\sphero\node_modules\serialport\build\serialport\v1.7.1\Release\node-v46-win32-x64 )
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
serialport.cpp
serialport_win.cpp
enumser.cpp
E:\dev\projects\sphero\node_modules\sphero\node_modules\serialport\node_modules\nan\nan.h(263): error C2995: 'v8::Local
<T> _NanEnsureLocal(v8::Local<T>)': function template has already been defined (compiling source file ..\src\serialport
.cpp) [E:\dev\projects\sphero\node_modules\sphero\node_modules\serialport\build\serialport.vcxproj]
E:\dev\projects\sphero\node_modules\sphero\node_modules\serialport\node_modules\nan\nan.h(263): error C2995: 'v8::Local
<T> _NanEnsureLocal(v8::Local<T>)': function template has already been defined (compiling source file ..\src\serialport
_win.cpp)E:\dev\projects\sphero\node_modules\sphero\node_modules\serialport\node_modules\nan\nan.h(256): note: see decl
aration of '_NanEnsureLocal' (compiling source file ..\src\serialport.cpp) [E:\dev\projects\sphero\node_modules\sphero\
node_modules\serialport\build\serialport.vcxproj]
E:\dev\projects\sphero\node_modules\sphero\node_modules\serialport\node_modules\nan\nan.h(256): note: see declaration
of '_NanEnsureLocal' (compiling source file ..\src\serialport_win.cpp)
E:\dev\projects\sphero\node_modules\sphero\node_modules\serialport\node_modules\nan\nan.h(661): error C3083: 'smalloc':
the symbol to the left of a '::' must be a type (compiling source file ..\src\serialport.cpp) [E:\dev\projects\sphero\
node_modules\sphero\node_modules\serialport\build\serialport.vcxproj]
E:\dev\projects\sphero\node_modules\sphero\node_modules\serialport\node_modules\nan\nan.h(661): error C2039: 'FreeCallb
ack': is not a member of 'node' (compiling source file ..\src\serialport.cpp)E:\dev\projects\sphero\node_modules\sphero
\node_modules\serialport\node_modules\nan\nan.h(661): error C3083: 'smalloc': the symbol to the left of a '::' must be
a type (compiling source file ..\src\serialport_win.cpp) [E:\dev\projects\sphero\node_modules\sphero\node_modules\seria
lport\build\serialport.vcxproj]
E:\dev\projects\sphero\node_modules\sphero\node_modules\serialport\node_modules\nan\nan.h(661): error C2039: 'FreeCallb
ack': is not a member of 'node' (compiling source file ..\src\serialport_win.cpp) [E:\dev\projects\sphero\node_modules\
sphero\node_modules\serialport\build\serialport.vcxproj]
C:\Users\student\.node-gyp\4.1.1\include\node\node_object_wrap.h(8): note: see declaration of 'node' (compiling sourc
e file ..\src\serialport.cpp)
C:\Users\student\.node-gyp\4.1.1\include\node\node_object_wrap.h(8): note: see declaration of 'node' (compiling sourc
e file ..\src\serialport_win.cpp)
E:\dev\projects\sphero\node_modules\sphero\node_modules\serialport\node_modules\nan\nan.h(661): error C2061: syntax err
or: identifier 'FreeCallback' (compiling source file ..\src\serialport.cpp) [E:\dev\projects\sphero\node_modules\sphero
\node_modules\serialport\build\serialport.vcxproj]
E:\dev\projects\sphero\node_modules\sphero\node_modules\serialport\node_modules\nan\nan.h(661): error C2061: syntax err
or: identifier 'FreeCallback' (compiling source file ..\src\serialport_win.cpp) [E:\dev\projects\sphero\node_modules\sp
hero\node_modules\serialport\build\serialport.vcxproj]
E:\dev\projects\sphero\node_modules\sphero\node_modules\serialport\node_modules\nan\nan.h(665): error C2065: 'callback'
: undeclared identifier (compiling source file ..\src\serialport.cpp) [E:\dev\projects\sphero\node_modules\sphero\node_
modules\serialport\build\serialport.vcxproj]
E:\dev\projects\sphero\node_modules\sphero\node_modules\serialport\node_modules\nan\nan.h(665): error C2065: 'callback'
: undeclared identifier (compiling source file ..\src\serialport_win.cpp) [E:\dev\projects\sphero\node_modules\sphero\n
ode_modules\serialport\build\serialport.vcxproj]
E:\dev\projects\sphero\node_modules\sphero\node_modules\serialport\node_modules\nan\nan.h(665): error C2065: 'hint': un
declared identifier (compiling source file ..\src\serialport.cpp) [E:\dev\projects\sphero\node_modules\sphero\node_modu
les\serialport\build\serialport.vcxproj]
E:\dev\projects\sphero\node_modules\sphero\node_modules\serialport\node_modules\nan\nan.h(665): error C2065: 'hint': un
declared identifier (compiling source file ..\src\serialport_win.cpp) [E:\dev\projects\sphero\node_modules\sphero\node_
modules\serialport\build\serialport.vcxproj]
E:\dev\projects\sphero\node_modules\sphero\node_modules\serialport\node_modules\nan\nan.h(672): error C2665: 'node::Buf
fer::New': none of the 4 overloads could convert all the argument types (compiling source file ..\src\serialport.cpp) [
E:\dev\projects\sphero\node_modules\sphero\node_modules\serialport\build\serialport.vcxproj]
C:\Users\student\.node-gyp\4.1.1\include\node\node_buffer.h(43): note: could be 'v8::MaybeLocal<v8::Object> node::Buf
fer::New(v8::Isolate *,char *,size_t)' (compiling source file ..\src\serialport.cpp)
E:\dev\projects\sphero\node_modules\sphero\node_modules\serialport\node_modules\nan\nan.h(672): error C2665: 'node::Buf
fer::New': none of the 4 overloads could convert all the argument types (compiling source file ..\src\serialport_win.cp
p) [E:\dev\projects\sphero\node_modules\sphero\node_modules\serialport\build\serialport.vcxproj]
C:\Users\student\.node-gyp\4.1.1\include\node\node_buffer.h(43): note: could be 'v8::MaybeLocal<v8::Object> node::Buf
fer::New(v8::Isolate *,char *,size_t)' (compiling source file ..\src\serialport_win.cpp)
C:\Users\student\.node-gyp\4.1.1\include\node\node_buffer.h(31): note: or 'v8::MaybeLocal<v8::Object> node::Buf
fer::New(v8::Isolate *,v8::Local<v8::String>,node::encoding)' (compiling source file ..\src\serialport.cpp)
C:\Users\student\.node-gyp\4.1.1\include\node\node_buffer.h(31): note: or 'v8::MaybeLocal<v8::Object> node::Buf
fer::New(v8::Isolate *,v8::Local<v8::String>,node::encoding)' (compiling source file ..\src\serialport_win.cpp)E:\dev
\projects\sphero\node_modules\sphero\node_modules\serialport\node_modules\nan\nan.h(672): note: while trying to match
the argument list '(v8::Isolate *, const char *, uint32_t)' (compiling source file ..\src\serialport.cpp)
E:\dev\projects\sphero\node_modules\sphero\node_modules\serialport\node_modules\nan\nan.h(672): note: while trying to
match the argument list '(v8::Isolate *, const char *, uint32_t)' (compiling source file ..\src\serialport_win.cpp)
E:\dev\projects\sphero\node_modules\sphero\node_modules\serialport\node_modules\nan\nan.h(676): error C2440: 'return':
cannot convert from 'v8::MaybeLocal<v8::Object>' to 'v8::Local<v8::Object>' (compiling source file ..\src\serialport.cp
p) [E:\dev\projects\sphero\node_modules\sphero\node_modules\serialport\build\serialport.vcxproj]
E:\dev\projects\sphero\node_modules\sphero\node_modules\serialport\node_modules\nan\nan.h(676): note: No constructor
could take the source type, or constructor overload resolution was ambiguous (compiling source file ..\src\serialport
.cpp)
E:\dev\projects\sphero\node_modules\sphero\node_modules\serialport\node_modules\nan\nan.h(676): error C2440: 'return':
cannot convert from 'v8::MaybeLocal<v8::Object>' to 'v8::Local<v8::Object>' (compiling source file ..\src\serialport_wi
n.cpp) [E:\dev\projects\sphero\node_modules\sphero\node_modules\serialport\build\serialport.vcxproj]
E:\dev\projects\sphero\node_modules\sphero\node_modules\serialport\node_modules\nan\nan.h(676): note: No constructor
could take the source type, or constructor overload resolution was ambiguous (compiling source file ..\src\serialport
_win.cpp)
E:\dev\projects\sphero\node_modules\sphero\node_modules\serialport\node_modules\nan\nan.h(683): error C2039: 'Use': is
not a member of 'node::Buffer' (compiling source file ..\src\serialport_win.cpp)E:\dev\projects\sphero\node_modules\sph
ero\node_modules\serialport\node_modules\nan\nan.h(683): error C2039: 'Use': is not a member of 'node::Buffer' (compili
ng source file ..\src\serialport.cpp) [E:\dev\projects\sphero\node_modules\sphero\node_modules\serialport\build\serialp
ort.vcxproj]
C:\Users\student\.node-gyp\4.1.1\include\node\node_buffer.h(8): note: see declaration of 'node::Buffer' (compiling so
urce file ..\src\serialport_win.cpp)
C:\Users\student\.node-gyp\4.1.1\include\node\node_buffer.h(8): note: see declaration of 'node::Buffer' (compiling so
urce file ..\src\serialport.cpp)
E:\dev\projects\sphero\node_modules\sphero\node_modules\serialport\node_modules\nan\nan.h(683): error C3861: 'Use': ide
ntifier not found (compiling source file ..\src\serialport.cpp) [E:\dev\projects\sphero\node_modules\sphero\node_module
s\serialport\build\serialport.vcxproj]
E:\dev\projects\sphero\node_modules\sphero\node_modules\serialport\node_modules\nan\nan.h(683): error C3861: 'Use': ide
ntifier not found (compiling source file ..\src\serialport_win.cpp) [E:\dev\projects\sphero\node_modules\sphero\node_mo
dules\serialport\build\serialport.vcxproj]
..\src\serialport_win.cpp(152): warning C4311: 'type cast': pointer truncation from 'HANDLE' to 'int' [E:\dev\projects\
sphero\node_modules\sphero\node_modules\serialport\build\serialport.vcxproj]
..\src\serialport_win.cpp(152): warning C4302: 'type cast': truncation from 'HANDLE' to 'int' [E:\dev\projects\sphero\n
ode_modules\sphero\node_modules\serialport\build\serialport.vcxproj]
..\src\serialport_win.cpp(177): warning C4312: 'type cast': conversion from 'int' to 'HANDLE' of greater size [E:\dev\p
rojects\sphero\node_modules\sphero\node_modules\serialport\build\serialport.vcxproj]
..\src\win\enumser.cpp(443): warning C4996: 'GetVersionExA': was declared deprecated [E:\dev\projects\sphero\node_modul
es\sphero\node_modules\serialport\build\serialport.vcxproj]
C:\Program Files (x86)\Windows Kits\8.1\Include\um\sysinfoapi.h(433): note: see declaration of 'GetVersionExA'
..\src\serialport_win.cpp(179): warning C4312: 'type cast': conversion from 'int' to 'HANDLE' of greater size [E:\dev\p
rojects\sphero\node_modules\sphero\node_modules\serialport\build\serialport.vcxproj]
..\src\serialport_win.cpp(183): warning C4312: 'type cast': conversion from 'int' to 'HANDLE' of greater size [E:\dev\p
rojects\sphero\node_modules\sphero\node_modules\serialport\build\serialport.vcxproj]
..\src\serialport_win.cpp(185): warning C4312: 'type cast': conversion from 'int' to 'HANDLE' of greater size [E:\dev\p
rojects\sphero\node_modules\sphero\node_modules\serialport\build\serialport.vcxproj]
..\src\serialport_win.cpp(189): warning C4312: 'type cast': conversion from 'int' to 'HANDLE' of greater size [E:\dev\p
rojects\sphero\node_modules\sphero\node_modules\serialport\build\serialport.vcxproj]
..\src\serialport_win.cpp(191): warning C4312: 'type cast': conversion from 'int' to 'HANDLE' of greater size [E:\dev\p
rojects\sphero\node_modules\sphero\node_modules\serialport\build\serialport.vcxproj]
..\src\serialport_win.cpp(196): warning C4312: 'type cast': conversion from 'int' to 'HANDLE' of greater size [E:\dev\p
rojects\sphero\node_modules\sphero\node_modules\serialport\build\serialport.vcxproj]
..\src\serialport_win.cpp(208): warning C4312: 'type cast': conversion from 'int' to 'HANDLE' of greater size [E:\dev\p
rojects\sphero\node_modules\sphero\node_modules\serialport\build\serialport.vcxproj]
..\src\serialport_win.cpp(308): warning C4311: 'type cast': pointer truncation from 'HANDLE' to 'int' [E:\dev\projects\
sphero\node_modules\sphero\node_modules\serialport\build\serialport.vcxproj]
..\src\serialport_win.cpp(308): warning C4302: 'type cast': truncation from 'HANDLE' to 'int' [E:\dev\projects\sphero\n
ode_modules\sphero\node_modules\serialport\build\serialport.vcxproj]
..\src\serialport_win.cpp(318): warning C4311: 'type cast': pointer truncation from 'HANDLE' to 'int' [E:\dev\projects\
sphero\node_modules\sphero\node_modules\serialport\build\serialport.vcxproj]
..\src\serialport_win.cpp(318): warning C4302: 'type cast': truncation from 'HANDLE' to 'int' [E:\dev\projects\sphero\n
ode_modules\sphero\node_modules\serialport\build\serialport.vcxproj]
..\src\serialport_win.cpp(328): warning C4312: 'type cast': conversion from 'int' to 'HANDLE' of greater size [E:\dev\p
rojects\sphero\node_modules\sphero\node_modules\serialport\build\serialport.vcxproj]
..\src\serialport_win.cpp(353): warning C4312: 'type cast': conversion from 'int' to 'HANDLE' of greater size [E:\dev\p
rojects\sphero\node_modules\sphero\node_modules\serialport\build\serialport.vcxproj]
..\src\serialport_win.cpp(366): warning C4312: 'type cast': conversion from 'int' to 'HANDLE' of greater size [E:\dev\p
rojects\sphero\node_modules\sphero\node_modules\serialport\build\serialport.vcxproj]
..\src\serialport_win.cpp(401): warning C4312: 'type cast': conversion from 'int' to 'HANDLE' of greater size [E:\dev\p
rojects\sphero\node_modules\sphero\node_modules\serialport\build\serialport.vcxproj]
..\src\serialport_win.cpp(403): warning C4312: 'type cast': conversion from 'int' to 'HANDLE' of greater size [E:\dev\p
rojects\sphero\node_modules\sphero\node_modules\serialport\build\serialport.vcxproj]
..\src\serialport_win.cpp(502): warning C4312: 'type cast': conversion from 'int' to 'HANDLE' of greater size [E:\dev\p
rojects\sphero\node_modules\sphero\node_modules\serialport\build\serialport.vcxproj]
..\src\serialport_win.cpp(511): warning C4312: 'type cast': conversion from 'int' to 'HANDLE' of greater size [E:\dev\p
rojects\sphero\node_modules\sphero\node_modules\serialport\build\serialport.vcxproj]
e:\dev\projects\sphero\node_modules\sphero\node_modules\serialport\src\win\stdstring.h(2123): warning C4311: 'reinterpr
et_cast': pointer truncation from 'const void *' to 'unsigned long' (compiling source file ..\src\win\enumser.cpp) [E:\
dev\projects\sphero\node_modules\sphero\node_modules\serialport\build\serialport.vcxproj]
e:\dev\projects\sphero\node_modules\sphero\node_modules\serialport\src\win\stdstring.h(2117): note: while compiling c
lass template member function 'bool CStdStr<wchar_t>::TryLoad(const void *)' (compiling source file ..\src\win\enumse
r.cpp)
e:\dev\projects\sphero\node_modules\sphero\node_modules\serialport\src\win\stdstring.h(2171): note: see reference to
function template instantiation 'bool CStdStr<wchar_t>::TryLoad(const void *)' being compiled (compiling source file
..\src\win\enumser.cpp)
e:\dev\projects\sphero\node_modules\sphero\node_modules\serialport\src\win\stdstring.h(3982): note: see reference to
class template instantiation 'CStdStr<wchar_t>' being compiled (compiling source file ..\src\win\enumser.cpp)
e:\dev\projects\sphero\node_modules\sphero\node_modules\serialport\src\win\stdstring.h(2123): warning C4302: 'reinterpr
et_cast': truncation from 'const void *' to 'unsigned long' (compiling source file ..\src\win\enumser.cpp) [E:\dev\proj
ects\sphero\node_modules\sphero\node_modules\serialport\build\serialport.vcxproj]
e:\dev\projects\sphero\node_modules\sphero\node_modules\serialport\src\win\stdstring.h(2126): warning C4311: 'reinterpr
et_cast': pointer truncation from 'const void *' to 'unsigned long' (compiling source file ..\src\win\enumser.cpp) [E:\
dev\projects\sphero\node_modules\sphero\node_modules\serialport\build\serialport.vcxproj]
e:\dev\projects\sphero\node_modules\sphero\node_modules\serialport\src\win\stdstring.h(2126): warning C4302: 'reinterpr
et_cast': truncation from 'const void *' to 'unsigned long' (compiling source file ..\src\win\enumser.cpp) [E:\dev\proj
ects\sphero\node_modules\sphero\node_modules\serialport\build\serialport.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe` failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:270:23)
gyp ERR! stack at emitTwo (events.js:87:13)
gyp ERR! stack at ChildProcess.emit (events.js:172:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Windows_NT 10.0.10240
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "build" "--fallback-to-build" "--module=E:\\dev\\projects\\sphero\\node_modules\\sphero\\node_modules\\serialport\\build\\serialport\\v1.7.1\\Release\\node-v46-win32-x64\\serialport.node" "--module_name=serialport" "--module_path=E:\\dev\\projects\\sphero\\node_modules\\sphero\\node_modules\\serialport\\build\\serialport\\v1.7.1\\Release\\node-v46-win32-x64"
gyp ERR! cwd E:\dev\projects\sphero\node_modules\sphero\node_modules\serialport
gyp ERR! node -v v4.1.1
gyp ERR! node-gyp -v v3.0.3
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute 'node-gyp.cmd build --fallback-to-build --module=E:\dev\projects\sphero\node_modules\sphero\node_modules\serialport\build\serialport\v1.7.1\Release\node-v46-win32-x64\serialport.node --module_name=serialport --module_path=E:\dev\projects\sphero\node_modules\sphero\node_modules\serialport\build\serialport\v1.7.1\Release\node-v46-win32-x64' (1)
node-pre-gyp ERR! stack at ChildProcess.<anonymous> (E:\dev\projects\sphero\node_modules\sphero\node_modules\serialport\node_modules\node-pre-gyp\lib\util\compile.js:83:29)
node-pre-gyp ERR! stack at emitTwo (events.js:87:13)
node-pre-gyp ERR! stack at ChildProcess.emit (events.js:172:7)
node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:817:16)
node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
node-pre-gyp ERR! System Windows_NT 10.0.10240
node-pre-gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "E:\\dev\\projects\\sphero\\node_modules\\sphero\\node_modules\\serialport\\node_modules\\node-pre-gyp\\bin\\node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd E:\dev\projects\sphero\node_modules\sphero\node_modules\serialport
node-pre-gyp ERR! node -v v4.1.1
node-pre-gyp ERR! node-pre-gyp -v v0.6.7
node-pre-gyp ERR! not ok
Failed to execute 'node-gyp.cmd build --fallback-to-build --module=E:\dev\projects\sphero\node_modules\sphero\node_modules\serialport\build\serialport\v1.7.1\Release\node-v46-win32-x64\serialport.node --module_name=serialport --module_path=E:\dev\projects\sphero\node_modules\sphero\node_modules\serialport\build\serialport\v1.7.1\Release\node-v46-win32-x64' (1)
npm ERR! Windows_NT 10.0.10240
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "sphero"
npm ERR! node v4.1.1
npm ERR! npm v2.14.4
npm ERR! code ELIFECYCLE
npm ERR! [email protected] install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script 'node-pre-gyp install --fallback-to-build'.
npm ERR! This is most likely a problem with the serialport package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-pre-gyp install --fallback-to-build
npm ERR! You can get their info via:
npm ERR! npm owner ls serialport
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! E:\dev\projects\sphero\npm-debug.log
When running npm install sphere noble
I was getting the following error on OSX Yosemite with Xcode 6:
> [email protected] install /Users/brianfeister/dev/sphero/node_modules/noble/node_modules/xpc-connection
> node-gyp rebuild
CXX(target) Release/obj.target/binding/src/XpcConnection.o
SOLINK_MODULE(target) Release/binding.node
ld: library not found for -lgcc_s.10.5
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [Release/binding.node] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:269:23)
gyp ERR! stack at ChildProcess.emit (events.js:110:17)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:1067:12)
gyp ERR! System Darwin 14.5.0
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/brianfeister/dev/sphero/node_modules/noble/node_modules/xpc-connection
gyp ERR! node -v v0.12.0
gyp ERR! node-gyp -v v2.0.2
gyp ERR! not ok
npm WARN optional dep failed, continuing [email protected]
[email protected] node_modules/noble
โโโ [email protected]
โโโ [email protected] ([email protected])
Here's how I fixed it:
Can you please issue a new release so that we can include the rejected promise suppression in sphero@latest?
Thanks!
I am on a Macbook Pro.
Used $ node ./node_modules/noble/examples/advertisement-discovery.js
to find Ollie's UUID and then ran ran the below code with my UUID.
var sphero = require("sphero"),
bb8 = sphero("F3:F2:6D:55:71:09"); // change BLE address accordingly
bb8.connect(function() {
// roll BB-8 in a random direction, changing direction every second
setInterval(function() {
var direction = Math.floor(Math.random() * 360);
bb8.roll(150, direction);
}, 1000);
});
Ollie connected quickly and started rolling around. Then I killed the script that I was running from the command line using CTRL + C.
After this I have not been able to connect to Ollie again, even the app has stopped working with it.
I have tried charging Ollie to full, waking up Ollie by inserting and removing the USB cable..
Any ideas?
Disclaimer: I have no idea what caused this and it may in fact not be related to the sphero.js project at all. I have also opened a support ticket with Sphero.
My build environment is a raspberry pi 3 with the "stretch" as the OS. I can successfully connect and control the sprk+ but I receive the following error when trying to connect to the mini.
/var/public/node_modules/sphero/lib/adaptors/ble.js:405
return this._connectedService(serviceId).characteristics;
^
TypeError: Cannot read property 'characteristics' of null
at Adaptor._connectedCharacteristics (/var/public/node_modules/sphero/lib/adaptors/ble.js:405:43)
at Adaptor._connectCharacteristic (/var/public/node_modules/sphero/lib/adaptors/ble.js:358:12)
at /var/public/node_modules/sphero/lib/adaptors/ble.js:303:12
at /var/public/node_modules/sphero/lib/adaptors/ble.js:346:9
at Peripheral. (/var/public/node_modules/noble/lib/peripheral.js:73:7)
at Object.onceWrapper (events.js:254:19)
at Peripheral.emit (events.js:159:13)
at Noble.onServicesDiscover (/var/public/node_modules/noble/lib/noble.js:208:16)
at NobleBindings.emit (events.js:159:13)
at NobleBindings.onServicesDiscovered (/var/public/node_modules/noble/lib/hci-socket/bindings.js:291:8)
at Gatt.emit (events.js:159:13)
at Gatt. (/var/public/node_modules/noble/lib/hci-socket/gatt.js:361:12)
at Gatt.onAclStreamData (/var/public/node_modules/noble/lib/hci-socket/gatt.js:132:26)
at AclStream.emit (events.js:164:20)
at AclStream.push (/var/public/node_modules/noble/lib/hci-socket/acl-stream.js:35:10)
at NobleBindings.onAclDataPkt (/var/public/node_modules/noble/lib/hci-socket/bindings.js:272:15)
Hi!
I've got some troubles with the readLocator response data.
Let's say I set the configuration as:
var opts = {
flags: 0x00,
x: 0x00FF, // x = 255 cm
y: 0x0000,
yawTare: 0x0
};
orb.configureLocator(opts);
I will get a 2
as xpos
value the when I do:
orb.readLocator(function(err, data) {
if (err) {
console.log("error: ", err);
} else {
console.log("readLocator:");
console.log(" xpos:", data.xpos); // xpos is 2
console.log(" ypos:", data.ypos);
console.log(" xvel:", data.xvel);
console.log(" yvel:", data.yvel);
console.log(" sog:", data.sog);
}
});
I've looked at the response from ollie on the readLocator and the response itself looks wrong. It has the xpos set to 2 and xvel is to 25 (0x19
):
<Buffer ff ff 00 01 0b 00 02 00 00 00 19 00 00 00 00 d8>
In parallel though, if I read the async packets, I can get the real value:
orb.on("async", function(response){
var xField = {from: 0, to: 2, type: 'signed'};
var yField = {from: 2, to: 4, type: 'signed'};
var x = Packet.prototype._parseField(xField, response.data); // x is 255
var y = Packet.prototype._parseField(yField, response.data);
console.log('pos:', x, y);
});
Not sure whether it matters but I am using a Ollie.
Does anyone know what might be going on, why am I getting the wrong data in the readLocator but correct position in the streaming/async packets?
cd sphero.js/examples
node location.js
...
xpos: undefined
ypos: undefined
xvel: undefined
yvel: undefined
sog: undefined
I printed out the object that does come back and it looks unrelated:
{ sop1: 255,
sop2: 255,
mrsp: 4,
seq: 100,
dlen: 1,
data: ,
checksum: 150 }
I double-checked the command id and it really is going across as 0x15 now. This all lines up with the sphero docs I saw in http://docs-beta.gosphero.com/reference/
Hi!
I'm running Ubuntu 16.04 lts and my bluetooth adapter is BCM20702A0 Bluetooth 4.0.
It 100% physically could work with few devices because I could control 2 Ollies at the same time (first from official SDK and the second one by unofficial python SDK). But I couldn't control both of them at the same time from the official SDK.
My code:
#Test.js
var sphero = require("sphero");
ollie1 = sphero('XX:XX:XX:XX:XX:XX', {timeout: 1000});
ollie2 = sphero('YY:YY:YY:YY:YY:YY', {timeout: 1000});
ollie1.connect(function() {
console.log("Ollie1 connected");
setInterval(function() {
ollie1.randomColor(function(err, data) {
console.log("Ollie1 set random color");
});
}, 1000);
});
ollie2.connect(function() {
console.log("Ollie2 connected");
setInterval(function() {
ollie2.randomColor(function(err, data) {
console.log("Ollie2 set random color");
});
}, 1000);
});
When I execute it only first Ollie changing color.
I divided code into two different files and locate them in the different directories:
#Test1.js
var sphero = require("sphero");
ollie1 = sphero('XX:XX:XX:XX:XX:XX', {timeout: 1000});
ollie1.connect(function() {
console.log("Ollie1 connected");
setInterval(function() {
ollie1.randomColor(function(err, data) {
console.log("Ollie1 set random color");
});
}, 1000);
});
#Test2.js
var sphero = require("sphero");
ollie2 = sphero('YY:YY:YY:YY:YY:YY', {timeout: 1000});
ollie2.connect(function() {
console.log("Ollie2 connected");
setInterval(function() {
ollie2.randomColor(function(err, data) {
console.log("Ollie2 set random color");
});
}, 1000);
});
When I execute second one It trough exceptions:
/home/myPath2/node_modules/sphero/lib/adaptors/ble.js:405
return this._connectedService(serviceId).characteristics;
^
TypeError: Cannot read property 'characteristics' of null
at Adaptor._connectedCharacteristics (/home/myPath2/node_modules/sphero/lib/adaptors/ble.js:405:43)
at Adaptor._connectCharacteristic (/home/myPath2/node_modules/sphero/lib/adaptors/ble.js:358:12)
at /home/myPath2/node_modules/sphero/lib/adaptors/ble.js:303:12
at Adaptor._connectService (/home/myPath2/node_modules/sphero/lib/adaptors/ble.js:339:5)
at /home/myPath2/node_modules/sphero/lib/adaptors/ble.js:301:10
at Adaptor._connectBLE (/home/myPath2/node_modules/sphero/lib/adaptors/ble.js:325:5)
at Adaptor.getCharacteristic (/home/myPath2/node_modules/sphero/lib/adaptors/ble.js:300:8)
at Adaptor.writeServiceCharacteristic (/home/myPath2/node_modules/sphero/lib/adaptors/ble.js:275:8)
at Adaptor.setTXPower (/home/myPath2/node_modules/sphero/lib/adaptors/ble.js:204:8)
at /home/myPath2/node_modules/sphero/lib/adaptors/ble.js:157:10
at /home/myPath2/node_modules/sphero/lib/adaptors/ble.js:276:25
at /home/myPath2/node_modules/sphero/lib/adaptors/ble.js:302:20
at /home/myPath2/node_modules/sphero/lib/adaptors/ble.js:348:9
at Peripheral.<anonymous> (/home/myPath2/node_modules/noble/lib/peripheral.js:73:7)
at Peripheral.g (events.js:260:16)
at emitOne (events.js:77:13)
Thanks in advance!
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!
I am trying to integrate this into my cross-platform mobile development (via JS). I am getting errors lacking arm64 support. Any plans to upgrade this for x64 support?
Hello,
Just got a new BB8 and am a node.js developer. Noticed there are resources and info about programming Ollie + Sphero but nothing on BB8.
Thanks!
This happens when sending roll() commands repeatedly.
Full error stack -
ERROR: Error: Incorrect checksum, packet discarded!
at Packet._verifyChecksum (/home/root/.node_app_slot/node_modules/sphero/lib/packet.js:152:24)
at Packet._parse (/home/root/.node_app_slot/node_modules/sphero/lib/packet.js:124:15)
at Packet.parse (/home/root/.node_app_slot/node_modules/sphero/lib/packet.js:85:21)
at Adaptor. (/home/root/.node_app_slot/node_modules/sphero/lib/sphero.js:98:34)
at Adaptor.emit (events.js:117:20)
at SerialPort.emit (events.js:95:17)
at Object.module.exports.raw as parser
at Object.SerialPort.opts.dataCallback (/home/root/.node_app_slot/node_modules/sphero/node_modules/serialport/serialport.js:181:12)
at SerialPortFactory.SerialPort._emitData (/home/root/.node_app_slot/node_modules/sphero/node_modules/serialport/serialport.js:396:20)
at afterRead (/home/root/.node_app_slot/node_modules/sphero/node_modules/serialport/serialport.js:372:20)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.