Этот коммит содержится в:
Lukas Bachschwell 2018-05-21 13:00:25 +02:00
родитель 144349a24b
Коммит f5818f33dd
3 изменённых файлов: 101 добавлений и 0 удалений

68
index.js Обычный файл
Просмотреть файл

@ -0,0 +1,68 @@
var sumo = require('node-sumo');
var drone = sumo.createClient();
var stdin = process.stdin;
// without this, we would only get streams once enter is pressed
stdin.setRawMode(true);
stdin.resume();
stdin.setEncoding('utf8');
var isConnected = false;
var speed = 25;
stdin.on('data', function(key) {
if (!isConnected) {
console.log("Not Connected!");
}
// ctrl-c ( end of text )
if (key === '\u0003') {
process.exit();
}
// write the key to stdout all normal like
//process.stdout.write(key);
if (key === 'w') {
drone.forward(speed);
} else if (key === 's') {
drone.backward(speed);
} else if (key === 'a') {
drone.right(speed);
} else if (key === 'd') {
drone.left(speed);
} else if (key === ' ') {
drone.animationsHighJump();
}
});
drone.on("battery", function(battery) {
console.log("battery: " + battery);
});
drone.connect(function() {
//drone.postureJumper();
console.log("We are connected!")
isConnected = true;
});
// on any data into stdin
stdin.on('data', function(key) {
// ctrl-c ( end of text )
if (key === '\u0003') {
process.exit();
}
// write the key to stdout all normal like
process.stdout.write(key);
});
drone.on('postureUnknown', function() {
console.log('PUT ME DOWN BASTARD!!!!!!!!!!!!!!!!!!!!!');
});
function turnRight() {
drone.right(50);
setTimeout(function() {
drone.stop();
}, 230);
}

19
package-lock.json сгенерированный Обычный файл
Просмотреть файл

@ -0,0 +1,19 @@
{
"name": "sumocontroller",
"version": "1.0.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"node-sumo": {
"version": "git+https://github.com/alronz/node-sumo.git#c619bd6e9e523dfa93901fba20977b9cea374aa3",
"requires": {
"through": "2.3.8"
}
},
"through": {
"version": "2.3.8",
"resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz",
"integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU="
}
}
}

14
package.json Обычный файл
Просмотреть файл

@ -0,0 +1,14 @@
{
"name": "sumocontroller",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Lukas Bachschwell",
"license": "ISC",
"dependencies": {
"node-sumo": "git+https://github.com/alronz/node-sumo.git"
}
}