2013-11-26 08:06:55 +08:00
|
|
|
var Cylon = require('../..');
|
|
|
|
|
|
|
|
Cylon.api({ host: '0.0.0.0', port: '8080' });
|
|
|
|
|
|
|
|
var bots = [
|
|
|
|
{ port: '/dev/rfcomm0', name: 'Thelma' },
|
|
|
|
{ port: '/dev/rfcomm1', name: 'Louise' }
|
|
|
|
];
|
|
|
|
|
|
|
|
var SpheroRobot = {
|
|
|
|
connection: { name: 'Sphero', adaptor: 'sphero' },
|
|
|
|
|
|
|
|
device: { name: 'sphero', driver: 'sphero' },
|
|
|
|
|
2013-11-27 08:02:12 +08:00
|
|
|
work: function(my) {
|
2013-11-26 08:06:55 +08:00
|
|
|
every((1).seconds(), function() {
|
2014-01-04 09:18:09 +08:00
|
|
|
console.log(my.name);
|
2013-11-27 08:02:12 +08:00
|
|
|
my.sphero.setRandomColor();
|
|
|
|
my.sphero.roll(60, Math.floor(Math.random() * 360));
|
2013-11-26 08:06:55 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
for (var i = 0; i < bots.length; i++) {
|
|
|
|
var bot = bots[i];
|
|
|
|
var robot = Object.create(SpheroRobot);
|
|
|
|
|
|
|
|
robot.connection.port = bot.port;
|
|
|
|
robot.name = bot.name;
|
|
|
|
|
|
|
|
Cylon.robot(robot);
|
|
|
|
}
|
|
|
|
|
|
|
|
Cylon.start();
|