2014-12-14 08:19:25 +08:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
var Cylon = require("../..");
|
2013-11-26 08:06:55 +08:00
|
|
|
|
2015-01-13 00:58:41 +08:00
|
|
|
// ensure you install the API plugin first:
|
|
|
|
// $ npm install cylon-api-http
|
2014-11-26 01:45:20 +08:00
|
|
|
Cylon.api({
|
2014-12-14 08:19:25 +08:00
|
|
|
host: "0.0.0.0",
|
|
|
|
port: "8080"
|
2014-09-20 02:59:11 +08:00
|
|
|
});
|
|
|
|
|
2014-09-30 06:15:42 +08:00
|
|
|
var bots = {
|
2015-04-15 12:49:12 +08:00
|
|
|
Thelma: "/dev/rfcomm0",
|
|
|
|
Louise: "/dev/rfcomm1"
|
2013-11-26 08:06:55 +08:00
|
|
|
};
|
|
|
|
|
2014-09-30 06:15:42 +08:00
|
|
|
Object.keys(bots).forEach(function(name) {
|
|
|
|
var port = bots[name];
|
2013-11-26 08:06:55 +08:00
|
|
|
|
2014-09-30 06:15:42 +08:00
|
|
|
Cylon.robot({
|
|
|
|
name: name,
|
2013-11-26 08:06:55 +08:00
|
|
|
|
2014-11-26 08:01:31 +08:00
|
|
|
connections: {
|
2014-12-14 08:19:25 +08:00
|
|
|
sphero: { adaptor: "sphero", port: port }
|
2014-11-26 08:01:31 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
devices: {
|
2014-12-14 08:19:25 +08:00
|
|
|
sphero: { driver: "sphero" }
|
2014-11-26 08:01:31 +08:00
|
|
|
},
|
2014-09-30 06:15:42 +08:00
|
|
|
|
|
|
|
work: function(my) {
|
|
|
|
every((1).seconds(), function() {
|
|
|
|
console.log(my.name);
|
|
|
|
my.sphero.setRandomColor();
|
|
|
|
my.sphero.roll(60, Math.floor(Math.random() * 360));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
2013-11-26 08:06:55 +08:00
|
|
|
|
|
|
|
Cylon.start();
|