Drone

Main drone class reponsible for drone control. The class can initialize a drone connection with telnet on IP 192.168.1.1.

Drone class

class dronevis.drone_connect.drone.Drone(ip_address='192.168.1.1')

Drone implementation for connecting, controlling, retrieving video stream from the drone using sockets

__init__(ip_address='192.168.1.1')

Initialize ip and communication ports

Parameters:

ip_address (str, optional) – IP of the drone. Defaults to “192.168.1.1”.

connect_video(close_callback, operation_callback, model_name)

Initialize and start video thread

Parameters:
  • close_callback (Callable) – Callback to be invoked after closing the video thread

  • model_name (str) – Computer vision to run over the video stream

  • operation_callback (Callable) – Callback to be invoked after each operation

Raises:

TypeError – Provided callback should be callable

disconnect_video()

Disconnect video stream

connect()

Start communication thread to send control commands

Raises:
set_config(**kwargs)

Set a configuration onto the drone

See possibles arguments with `list_config`

Raises:

AttributeError – raised when there is an invalid config

Returns:

a flag that everything went fine

Return type:

bool

list_config()

List all possible configuration

Returns:

list of configurations

Return type:

list

takeoff()

Take Off

Returns:

a flag for valid execution

Return type:

bool

land()

Land

Returns:

a flag for valid execution

Return type:

bool

calibrate()

Calibrate sensors

Returns:

a flag for valid execution

Return type:

bool

forward(speed=0.2)

Make the drone go forward, speed is between 0 and 1

Parameters:

speed (float, optional) – speed of the forward move. Defaults to 0.2.

Returns:

a flag for valid execution

Return type:

bool

backward(speed=0.2)

Make the drone go backward, speed is between 0 and 1

Parameters:

speed (float, optional) – speed of back move. Defaults to 0.2.

Returns:

a flag for valid execution

Return type:

bool

left(speed=0.2)

Make the drone go left, speed is between 0 and 1

Parameters:

speed (float, optional) – speed of left move. Defaults to 0.2.

Returns:

a flag for valid execution

Return type:

bool

upward(speed=0.2)

Make the drone rise in the air, speed is between 0 and 1

Parameters:

speed (float, optional) – speed of right move. Defaults to 0.2.

Returns:

a flag for valid execution

Return type:

bool

downward(speed=0.2)

Make the drone descend, speed is between 0 and 1

Parameters:

speed (float, optional) – speed of down move. Defaults to 0.2.

Returns:

a flag for valid execution

Return type:

bool

rotate_left(speed=0.8)

Make the drone turn left, speed is between 0 and 1

Parameters:

speed (float, optional) – speed of rotation. Defaults to 0.8.

Returns:

a flag for valid execution

Return type:

bool

rotate_right(speed=0.8)

Make the drone turn right, speed is between 0 and 1

Parameters:

speed (float, optional) – speed of rotation. Defaults to 0.8.

Returns:

a flag for valid execution

Return type:

bool

right(speed=0.2)

Make the drone go right, speed is between 0 and 1

Parameters:

speed (float, optional) – speed of rotation. Defaults to 0.2.

Returns:

a flag for valid execution

Return type:

bool

navigate(left_right=0.0, front_back=0.0, up_down=0.0, angle_change=0.0)

Command the drone, all the arguments are between -1 and 1

Parameters:
  • left_right (int, optional) – how much horizontal move (y-axis). Defaults to 0.

  • front_back (int, optional) – how much horizontal move (x-axis). Defaults to 0.

  • up_down (int, optional) – how much vertical move (z-axis). Defaults to 0.

  • angle_change (int, optional) – how much to change the angle. Defaults to 0.

Returns:

a flag for valid execution

Return type:

bool

hover()

Make the drone stationary

Returns:

a flag for valid execution

Return type:

bool

emergency()

Enter in emergency mode

Returns:

a flag for valid execution

Return type:

str

stop()

Stop the drone

set_callback(callback=None)

Set the callback function

reset()

Reset the state of the drone

Returns:

a flag for valid execution

Return type:

bool