Im a student learning how to work and publish packages on NPM. This is a simple package that allows you to communicate with a DJI Tello drone in a much easier way. Any feedback / help / improvement is appreaciated and i will hopefully be able to look into fixing bugs and such when i can.
This project is currently a work in progress, but as of 1.0.1 it can communicate with a tello drone with the sample code bellow.
- Package is now only async.
- Removed offsetBuffer and async option from config.
- Removed DELAYS attribute from the tello-data.json and the tello package.
- Replaced large sections of the code that could be replaced with native node modules, such as events and assert.
- Added testing and linting
The goal of this package is to provide an independent (no dependecies), simple and easy-to-use interface between nodejs and a tello drone. You can communicate with the drone asynchronously. When you connect to the drone it automatically sends the 'command' command, so that is not nececary.
The drone gives no feedback on errors. Command verification is already built in, it will throw an error if a command is invalid. If you recieve back an error and the drone does not execute the command, the most common reason in my experience is low battery. Charging the battery and trying again solves that error issue.
const tello = require("tello-drone");
// All option parameters are optional, default values shown
const drone = tello.connect(
{
host: "192.168.10.1", // manually set the host.
port: "8889", // manually set the port.
statePort: "8890", // manually set the state port.
skipOK: false, // dont send the OK message.
}
);
// Sends a command to the drone
drone.send("battery?")
// Sends a command to the drone without verifying the command
drone.forceSend("battery?")
// Attaches a callback to a specific event
drone.on(event, callback)
/** All events of the on method
* connection - Fired when connected to the drone. callback()
* state - Fired when the drone sends its state message. callback(stateObject, udpConnection)
* send - Fired when a command is sent. callback(error, messageLength)
* message - Fired when the drone sends a status message. callback(message, udpConnection)
*/
const tello = require("tello-drone");
const drone = tello.connect();
drone.on("connection", () => {
console.log("Connected to drone");
});
drone.on("state", state => {
console.log("Recieved State > ", state);
});
drone.on("send", (err, length) => {
if (err) console.log(err);
console.log(`Sent command is ${length} long`);
});
drone.on("message", message => {
console.log("Recieved Message > ", message);
});
drone.on("connection", async () => {
try {
await drone.send("takeoff");
await drone.send("flip", { value: "f" });
await drone.send("land");
} catch (error) {
console.log(error)
drone.send("land")
//A short delay so that the land command can be sent before exiting
setTimeout(process.exit)
}
});
Tellos official SDK documentation with all commands:
1.0: https://dl-cdn.ryzerobotics.com/downloads/tello/0228/Tello+SDK+Readme.pdf
1.3: https://dl-cdn.ryzerobotics.com/downloads/tello/20180910/Tello%20SDK%20Documentation%20EN_1.3.pdf
2.0: https://dl-cdn.ryzerobotics.com/downloads/Tello/Tello%20SDK%202.0%20User%20Guide.pdf
Here are the most used ones: command, takeoff, land, up, down, left, right, forward, back, flip, speed, speed?, battery?