Control Chinese drones with Node.js.
I tested this on a "Propel Ultra-X + WiFi", but it should work on any similar model.
- Move your drone (throttle, direction, turning)
- Auto take-off
- Calibrate gyro
- Unlock motor
First, make sure you are connected to your drone's AP.
const { Drone } = require('dronelib')
const drone = new Drone()
// Enabling will start sending commands to your drone
// and the lights on it should stop blinking
drone.enable()
// Take flight!
drone.takeOff()
This is the current throttle of the drone. It ranges from 0-254. Equivalent to pushing the left stick up or down.
Set it below 128 to make it go down, set it above 128 to make it go up.
// FULL THROTTLE!
drone.throttle = 254
The current turn value of the drone. It ranges from 0-254. Equivalent to pushing the left stick left or right.
Set it below 128 to make it turn left, set it above 128 to make it turn right.
// Spin left!
drone.turn = 0
The current forward/backward direction value of the drone. It ranges from 0-254. Equivalent to pushing the right stick up or down.
Set it below 128 to make it go forward, set it above 128 to make it go backward.
// I hope it doesn't run into any trees
drone.forwardBackward = 254
The current left/right direction value of the drone. It ranges from 0-254. Equivalent to pushing the right stick left or right.
Set it below 128 to make it go left, set it above 128 to make it go right.
// Moves the drone slightly left
drone.leftRight = 100
The command that is currently being sent to the drone. You probably shouldn't touch this directly, and instead use one of the provided command methods.
Use this method to start sending commands to the drone. While enabled, this library will send a message to the drone every 100ms. This is how the drone knows it hasn't disconnected from the client.
Use this method to stop sending commands to the drone.
Take flight! This is equivalent to pressing the "Auto Take-Off/Land" button.
Fall with style! This is equivalent to pressing the "Auto Take-Off/Land" button.
Calibrate the drone's gyro. The user should put the drone on a flat surface before this is called.
Toggle the drone's motor lock. This enables/disables the altitude lock. There's no way to programmatically determine whether it is enabled or disabled.
This project is licensed under the GNU GPL v3.