First Commit for AR Drone Browser controller
Esse commit está contido em:
@@ -0,0 +1,9 @@
|
||||
/**
|
||||
* Created with JetBrains WebStorm.
|
||||
* User: rohitghatol
|
||||
* Date: 6/29/13
|
||||
* Time: 6:36 PM
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
|
||||
require("dronestream").listen(3001);
|
||||
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* Created with JetBrains WebStorm.
|
||||
* User: rohitghatol
|
||||
* Date: 6/29/13
|
||||
* Time: 6:32 PM
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
|
||||
var io = require('socket.io').listen(3002);
|
||||
io.set('log level', 1);
|
||||
|
||||
io.sockets.on('connection', function (socket) {
|
||||
var arDrone = require('ar-drone');
|
||||
var client = arDrone.createClient();
|
||||
|
||||
setInterval(function(){
|
||||
var batteryLevel = client.battery();
|
||||
socket.emit('event', { name: 'battery',value: batteryLevel});
|
||||
},1000);
|
||||
|
||||
socket.on('event', function (data) {
|
||||
if(data.name=="takeoff"){
|
||||
console.log("Browser asked Ar Drone to Take Off");
|
||||
client.takeoff();
|
||||
}
|
||||
if(data.name=="spin"){
|
||||
console.log("Browser asked Ar Drone to Start Spinning");
|
||||
client.clockwise(1);
|
||||
}
|
||||
if(data.name=="stop"){
|
||||
console.log("Browser asked Ar Drone to Stay and Hover");
|
||||
client.stop();
|
||||
}
|
||||
if(data.name=="land"){
|
||||
console.log("Browser asked Ar Drone to Land");
|
||||
client.land();
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
Referência em uma Nova Issue
Bloquear um usuário