Udded actions
Esse commit está contido em:
gerado
+20
-7
@@ -2,14 +2,13 @@
|
||||
<project version="4">
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="eeacb93f-73aa-46ec-92c7-08d6fb5d2b5c" name="Default" comment="">
|
||||
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/nearest.js" />
|
||||
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/go.js" afterPath="$PROJECT_DIR$/go.js" />
|
||||
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
|
||||
</list>
|
||||
<ignored path="NodeCopterHack.iws" />
|
||||
<ignored path=".idea/workspace.xml" />
|
||||
<file path="/Dummy.txt" changelist="eeacb93f-73aa-46ec-92c7-08d6fb5d2b5c" time="1376143309879" ignored="false" />
|
||||
<file path="/go.js" changelist="eeacb93f-73aa-46ec-92c7-08d6fb5d2b5c" time="1376143525720" ignored="false" />
|
||||
<file path="/Dummy.txt" changelist="eeacb93f-73aa-46ec-92c7-08d6fb5d2b5c" time="1376145571388" ignored="false" />
|
||||
<file path="/go.js" changelist="eeacb93f-73aa-46ec-92c7-08d6fb5d2b5c" time="1376145788053" ignored="false" />
|
||||
<file path="/nearest.js" changelist="eeacb93f-73aa-46ec-92c7-08d6fb5d2b5c" time="1376142921730" ignored="false" />
|
||||
<option name="TRACKING_ENABLED" value="true" />
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
@@ -33,7 +32,7 @@
|
||||
<file leaf-file-name="go.js" pinned="false" current="true" current-in-tab="true">
|
||||
<entry file="file://$PROJECT_DIR$/go.js">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="104" column="2" selection-start="2594" selection-end="2594" vertical-scroll-proportion="0.34051725">
|
||||
<state line="96" column="22" selection-start="2682" selection-end="2682" vertical-scroll-proportion="0.41379312">
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
@@ -103,7 +102,6 @@
|
||||
<sortByType />
|
||||
</navigator>
|
||||
<panes>
|
||||
<pane id="Scope" />
|
||||
<pane id="ProjectPane">
|
||||
<subPane>
|
||||
<PATH>
|
||||
@@ -124,14 +122,15 @@
|
||||
</PATH>
|
||||
</subPane>
|
||||
</pane>
|
||||
<pane id="Scope" />
|
||||
</panes>
|
||||
</component>
|
||||
<component name="PropertiesComponent">
|
||||
<property name="options.splitter.main.proportions" value="0.3" />
|
||||
<property name="WebServerToolWindowFactoryState" value="false" />
|
||||
<property name="options.lastSelected" value="Template Data Languages" />
|
||||
<property name="options.searchVisible" value="true" />
|
||||
<property name="options.splitter.details.proportions" value="0.2" />
|
||||
<property name="options.searchVisible" value="true" />
|
||||
</component>
|
||||
<component name="RunManager">
|
||||
<configuration default="true" type="DartUnitRunConfigurationType" factoryName="DartUnit">
|
||||
@@ -236,6 +235,20 @@
|
||||
<breakpoint-manager />
|
||||
</component>
|
||||
<component name="editorHistoryManager">
|
||||
<entry file="file://$PROJECT_DIR$/go.js">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-proportion="0.0">
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/nearest.js">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="11" column="0" selection-start="0" selection-end="465" vertical-scroll-proportion="0.0">
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/go.js">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-proportion="0.0">
|
||||
@@ -266,7 +279,7 @@
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/go.js">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="104" column="2" selection-start="2594" selection-end="2594" vertical-scroll-proportion="0.34051725">
|
||||
<state line="96" column="22" selection-start="2682" selection-end="2682" vertical-scroll-proportion="0.41379312">
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
|
||||
+40
-6
@@ -76,24 +76,57 @@ app.listen(8076);
|
||||
var doAction = function (command) {
|
||||
findCommand(command, function (res) {
|
||||
if(res) {
|
||||
// console.log("COMMAND: " + res);
|
||||
// console.log("COMMAND: " + res);
|
||||
var commands = {
|
||||
'LAND': function () {
|
||||
client.land();
|
||||
},
|
||||
'TAKEOFF': function() { client.takeoff(); },
|
||||
'TAKE OFF': function() { client.takeoff(); },
|
||||
'TAKEOFF': function () {
|
||||
client.takeoff();
|
||||
},
|
||||
'TAKE OFF': function () {
|
||||
client.takeoff();
|
||||
},
|
||||
'PARTY': function () {
|
||||
client.animateLeds('redSnake', 5, 5);
|
||||
client.clockwise(5);
|
||||
client.animate('thetaDance', 5000);
|
||||
},
|
||||
'FLIP': function () {
|
||||
client.animate('flipBehind', 2000);
|
||||
},
|
||||
|
||||
'LEFT': function () {
|
||||
client.left(0.5).after(1000, function () {
|
||||
client.stop();
|
||||
});
|
||||
},
|
||||
|
||||
'UP': function () {
|
||||
client.up(0.5).after(1000, function () {
|
||||
client.stop();
|
||||
});
|
||||
},
|
||||
|
||||
'DOWN': function () {
|
||||
client.down(0.5).after(1000, function () {
|
||||
client.stop();
|
||||
});
|
||||
},
|
||||
|
||||
'RIGHT': function () {
|
||||
client.right(0.5).after(1000, function () {
|
||||
client.stop();
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var upper = command.toUpperCase();
|
||||
if(typeof commands[upper] == 'function') {
|
||||
commands[upper]();
|
||||
} else {
|
||||
// console.log("BAD Command: " + command);
|
||||
// console.log("BAD Command: " + command);
|
||||
}
|
||||
} else {
|
||||
//console.log("BAD Command: " + command);
|
||||
@@ -111,7 +144,8 @@ var findCommand = function (command, callback) {
|
||||
{ name: "DOWN"},
|
||||
{ name: "LEFT"},
|
||||
{ name: "RIGHT"},
|
||||
{ name: "PARTY"}
|
||||
{ name: "PARTY"},
|
||||
{ name: "FLIP"}
|
||||
];
|
||||
|
||||
var query = { name: command};
|
||||
@@ -123,7 +157,7 @@ var findCommand = function (command, callback) {
|
||||
nn.findMostSimilar(query, items, fields, function (nearestNeighbor, probability) {
|
||||
//console.log(query);
|
||||
//console.log(nearestNeighbor);
|
||||
//console.log(probability);
|
||||
//console.log(probability);
|
||||
if(probability > 0.4) {
|
||||
callback(nearestNeighbor.name);
|
||||
} else {
|
||||
|
||||
+157
@@ -0,0 +1,157 @@
|
||||
var express = require('express');
|
||||
var engines = require('consolidate');
|
||||
var nodecr = require('nodecr');
|
||||
var drone = require('dronestream');
|
||||
var fs = require('fs');
|
||||
var app = express();
|
||||
app.engine('html', engines.hogan);
|
||||
app.set('view engine', 'html');
|
||||
app.set('views', __dirname);
|
||||
|
||||
var lastPng;
|
||||
|
||||
app.get('/', function (req, res) {
|
||||
res.render('index');
|
||||
});
|
||||
|
||||
app.get('/image', function (req, res) {
|
||||
if(lastPng) {
|
||||
//console.log('has last png');
|
||||
res.writeHead(200, {'Content-Type:': 'image/png' });
|
||||
res.end(lastPng);
|
||||
}
|
||||
});
|
||||
|
||||
app.get('/land', function (req, res) {
|
||||
client.land();
|
||||
res.render('index');
|
||||
});
|
||||
|
||||
var arDrone = require('ar-drone');
|
||||
var client = arDrone.createClient();
|
||||
var pngStream;
|
||||
|
||||
//client.takeoff();
|
||||
client.after(2000, function () {
|
||||
pngStream = client.getPngStream();
|
||||
pngStream.on('error', console.log).on('data', function (lastPng = pngBuffer;
|
||||
var filename = new Date() * 1 + '.png';
|
||||
fs.open(filename, "wx", function (err, fd) {
|
||||
fs.write(fd, pngBuffer, 0, pngBuffer.length, null, function () {
|
||||
fs.close(fd, function () {
|
||||
scan(filename);
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
})
|
||||
;
|
||||
|
||||
var takeoff = function () {
|
||||
client.takeoff();
|
||||
};
|
||||
|
||||
var scanning = false;
|
||||
var scan = function (filename) {
|
||||
if(!scanning) {
|
||||
scanning = true;
|
||||
nodecr.process(__dirname + '/' + filename, function (err, text)
|
||||
//nodecr.process(lastPng, function(err, text)
|
||||
{
|
||||
if(err) {
|
||||
// console.error(err);
|
||||
} else {
|
||||
var tidiedUp = text.replace("0", "O").replace(/\W/g, "");
|
||||
// if(tidiedUp == "STOP")
|
||||
//{
|
||||
console.log(tidiedUp);
|
||||
doAction(tidiedUp);
|
||||
|
||||
// }
|
||||
}
|
||||
});
|
||||
scanning = false;
|
||||
}
|
||||
};
|
||||
|
||||
app.listen(8076);
|
||||
|
||||
var doAction = function (command) {
|
||||
<<<<<<< Updated upstream
|
||||
console.log("COMMAND: " + command);
|
||||
var commands = {
|
||||
'LAND': function () {
|
||||
client.land();
|
||||
},
|
||||
'TAKEOFF': function () {
|
||||
client.takeoff();
|
||||
},
|
||||
'DANCE': function()
|
||||
{
|
||||
client.animateLeds('redSnake', 5, 5);
|
||||
=======
|
||||
findCommand(command, function (res) {
|
||||
if(res){
|
||||
console.log("COMMAND: " + res);
|
||||
var commands = {
|
||||
'LAND': function () {
|
||||
client.land();
|
||||
},
|
||||
'TAKE OFF': function () {
|
||||
client.takeoff();
|
||||
}
|
||||
}
|
||||
var upper = command.toUpperCase();
|
||||
if(typeof commands[upper] == 'function') {
|
||||
commands[upper]();
|
||||
}else{
|
||||
console.log("BAD Command: " + command);
|
||||
}
|
||||
}else{
|
||||
console.log("BAD Command: " + command);
|
||||
}
|
||||
>>>>>>> Stashed changes
|
||||
}
|
||||
|
||||
);
|
||||
};
|
||||
var findCommand = function (command, callback) {
|
||||
nn = require('nearest-neighbor');
|
||||
var items = [
|
||||
{ name: "LAND"},
|
||||
{ name: "TAKE OFF"},
|
||||
{ name: "UP"},
|
||||
{ name: "DOWN"},
|
||||
{ name: "LEFT"},
|
||||
{ name: "RIGHT"},
|
||||
{ name: "DANCE"}
|
||||
];
|
||||
|
||||
var query = { name: command};
|
||||
|
||||
var fields = [
|
||||
{ name: "name", measure: nn.comparisonMethods.word },
|
||||
];
|
||||
|
||||
nn.findMostSimilar(query, items, fields, function (nearestNeighbor, probability) {
|
||||
console.log(query);
|
||||
console.log(nearestNeighbor);
|
||||
console.log(probability);
|
||||
if(probability > 0.6) {
|
||||
callback(nearestNeighbor.name);
|
||||
} else {
|
||||
callback('');
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
<<<<<<< Updated upstream
|
||||
}
|
||||
//takeoff();
|
||||
=======
|
||||
takeoff();
|
||||
>>>>>>> Stashed changes
|
||||
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário