Last active
January 30, 2019 18:36
-
-
Save miya0001/b28f39e71e6dc0ca1a6b72cf6e2628ed to your computer and use it in GitHub Desktop.
Tello + Node.js example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
'use strict' | |
const PORT = 8889; | |
const HOST = '192.168.10.1'; | |
const dgram = require('dgram'); | |
const client = dgram.createSocket('udp4'); | |
const sendCommand = (command) => { | |
const message = Buffer.from(command); | |
client.send(message, 0, message.length, PORT, HOST, (err, bytes) => { | |
if (err) throw err; | |
}); | |
} | |
// See official documentation. | |
// https://dl-cdn.ryzerobotics.com/downloads/tello/20180910/Tello%20SDK%20Documentation%20EN_1.3.pdf | |
sendCommand('command') | |
// 離陸 | |
sendCommand('takeoff') | |
// 5秒後に時計回りで180度 | |
setTimeout(() => { | |
sendCommand('cw 180') | |
}, 5000) | |
// 10秒後に着陸 | |
setTimeout(() => { | |
sendCommand('land') | |
}, 10000) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
試し方
path/to/tello.js
の部分はファイル名。たとえばデスクトップに保存した場合は~/Desktop/tello.js
になります。