At the moment the queue is working but things like
August 2019: Added support for front camera on drone
You must have FFMPEG installed on your computer and added it your path test your installation with this command in the terminal: "ffmpeg -version"
images are saved as jpg-files in a folder named grabbedImages
**September 2019: minor changes Queue is working
A brief example of how to program a Tello drone with Java. Tello drones accept commands through UDP and responds with a short text message
You can find further information about the drone here: [https://www.ryzerobotics.com/tello/downloads] including the full SDK describing all commands accepted by the drone
This example makes it very easy to commmunicate with the drone - see the code below:
// Create Drone instance
TelloDrone drone = new TelloDrone();
// write commands to console
drone.setLogToConsole(true);
// Sending commands to drone
drone.connect();
drone.streamOn();
drone.takeoff();
drone.rotateClockwise(360);
drone.land();
Look in the documentation for more commands
You can add a queue of commands you want executed in a separate thread. This might be handy if you need to fly the drone to a specific place while you do something else in your program
// create a queue of commands and execute them
drone.addToCommandQueue("sdk?");
drone.addToCommandQueue("sn?");
drone.addToCommandQueue("takeoff");
drone.addToCommandQueue("ccw 180");
drone.addToCommandQueue("cw 180");
drone.addToCommandQueue("land");
//disable logging drone and use the eventlistener below instead
drone.setLogToConsole(false);
// add eventlistener to the "drone command queue"
drone.addCommandQueueEventListener(new TelloDrone.DroneCommandEventListener() {
@Override
public void commandExecuted(TelloDrone.Command command)
{
System.out.println("Command Executed:");
System.out.println(command);
}
@Override
public void commandFinished(TelloDrone.Command command)
{
System.out.println("Command Finished:");
System.out.println(command);
}
@Override
public void commandAdded(TelloDrone.Command command)
{
System.out.println(command.getCommand() + " added to queue");
}
@Override
public void commandQueueFinished() {
System.out.println("Done. No more commands in queue");
}
});
drone.startCommandQueue();
This project has no other requirements than an actual Tello Drone. Just folow these steps and you should be up and running in a matter of minutes
- Download this project and open it in intelliJ or another java IDE
- Turn on the Tello drone
- Connect your computer to the Tello Wifi
- Run the code....
You can grab the stream if you have ffmpeg installed and has send the 'streamon' command to the drone
ffplay -probesize 32 -i udp://@:11111 -framerate 30
-
Author: Ebbe Vang
-
Version: 0.1
This class connects to a Tello drone using a UDP connection and sends commands to the drone
Supports all commands in sdk1.
connects to the drone using the 'command' comamnd and allows you to send further commands
- Returns: whether the drone is connected or not
Send any command to the drone - see the sdk for more details about the commands you can send to the drone
- Parameters:
command
— the command you want to send to the drone - Returns: whether the command is accepted or not
The drone takes off - The drone will rise about 1 meter
- Returns: whether the command is accepted or not
The drone lands
- Returns: whether the command is accepted or not
move drone down
- Parameters:
cm
— distance in cm - Returns: whether the command is accepted or not
move drone up
- Parameters:
cm
— distance in cm - Returns: whether the command is accepted or not
move drone left
- Parameters:
cm
— distance in cm - Returns: whether the command is accepted or not
move drone right
- Parameters:
cm
— distance in cm - Returns: whether the command is accepted or not
move drone forward
- Parameters:
cm
— distance in cm - Returns: whether the command is accepted or not
move drone backwards
- Parameters:
cm
— distance in cm - Returns: whether the command is accepted or not
start video stream from front camera
- Returns: whether the command is accepted or not
Stop streaming from front camera
- Returns:
The Drone will turn clockwise
- Parameters:
degrees
— you want the drone to turn - must be between 0 and 360 - Returns: whether the command is accepted or not
The Drone will turn counter clockwise
- Parameters:
degrees
— you want the drone to turn - must be between 0 and 360 - Returns: whether the command is accepted or not
Log status.
- Returns: If the drone is writing to the console or not
Stops motors immediately!*
- Returns:
activate or deactivate log to console
- Parameters:
logToConsole
— Log to console
grab image from front camera. image will be saved in grabbedImages folder
- Returns: image number - which is used as a filename
get URL for latest image taken by grabbedImage method
- Returns: image url as string
Set drone speed
- Parameters:
speed
— in cm/s (1-100) - Returns: whether the speed is set or not
g get the speed of the drone i cm/s
- Returns: speed in cm/s (1-100)
get the battery charge level in percentage
- Returns: battery charge in percentage (1-100)
get time droen has been in the air
- Returns: time flying
Add to queue of commands
- Parameters:
command
—
start executing commands from command queue in separate thread
suspend command queue
resume command queue
add eventlistener to command queue
- Parameters:
listener
—
remove eventlistener from command queue
- Parameters:
listener
—
remove all commands from queue