Skip to content

Commit

Permalink
v2.4.2
Browse files Browse the repository at this point in the history
-Small bug fixes
-Style/optimization fixes
  • Loading branch information
ErnGusMik committed Apr 26, 2023
1 parent 8be827e commit eccc84f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 20 deletions.
7 changes: 3 additions & 4 deletions setup.py
Expand Up @@ -3,6 +3,7 @@


def readme():
"""Returns the README.md file as a string"""
with open("README.md") as f:
return f.read()

Expand All @@ -12,13 +13,11 @@ def readme():
packages=find_packages("tello_sdk"),
version="2.4.1",
license="MIT",
description=
"Python SDK fro the Tello EDU and RMTT drones, with all commands and more.",
description="Python SDK fro the Tello EDU and RMTT drones, with all commands and more.",
author="ErnGusMik",
author_email="ernests.mikuts@gmail.com",
url="https://github.com/ErnGusMik/python-tello",
download_url=
"https://github.com/ErnGusMik/python-tello/archive/refs/tags/v2.1.0-alpha.tar.gz",
download_url="https://github.com/ErnGusMik/python-tello/archive/refs/tags/v2.1.0-alpha.tar.gz",
keywords=[
"tello",
"drone",
Expand Down
29 changes: 13 additions & 16 deletions tello_sdk/tello.py
@@ -1,4 +1,3 @@
# !! tello.curveMpad() -- ERROR: RUN TIMEOUT ???
# Import all needed libraries
import logging
import socket
Expand All @@ -16,11 +15,9 @@

# ------------------ #
sentry_sdk.init(
dsn=
"https://f2fcaa10be4f41958ab756183583ba81@o1400261.ingest.sentry.io/6728983",
dsn="https://f2fcaa10be4f41958ab756183583ba81@o1400261.ingest.sentry.io/6728983",
traces_sample_rate=1.0,
)

# ------------------ #


Expand Down Expand Up @@ -78,7 +75,7 @@ def __init__(self, log_in_console: bool = True, tips: bool = True):
logging.info(" Drone Script ")
logging.info("--------------------------------------")

logging.debug(f"Current port for UDP connection: {str(port)}")
logging.debug(f"Current port for UDP connection: %s", str(port))

logging.info(" Checking network... \r\n")
time.sleep(0.5)
Expand Down Expand Up @@ -416,12 +413,12 @@ def rotate(self, direction: str, degrees: int):
"""Sends command to rotate clockwise or anti-clockwise for specified amount of degrees"""
logging.debug("Sending command: cw()")
if 1 <= degrees <= 360:
if direction is "cw":
if direction == "cw":
return self.run(
f"cw {str(degrees)}",
f"Rotating clockwise {str(degrees)} degrees \r\n",
)
if direction is "ccw":
if direction == "ccw":
return self.run(
f"ccw {str(degrees)}",
f"Rotating counter-clockwise {str(degrees)} degrees \r\n",
Expand All @@ -444,7 +441,7 @@ def flip(self, direction: str):
def set_speed(self, x: int):
"""Sends command to set speed to x cm/s"""
logging.debug("Sending command: set_speed()")
if x >= 1 and x <= 100:
if 1 <= x <= 100:
return self.run(f"speed {str(x)}",
f"Setting speed to {str(x)} cm/s \r\n")
logging.warning("tello.set_speed(): Invalid value.")
Expand Down Expand Up @@ -475,7 +472,7 @@ def set_mission_off(self):
def set_mission_direction(self, x: int):
"""Sends command to set mission pad detection direction"""
logging.debug("Sending command: set_mission_direction()")
if x >= 0 and x <= 3:
if 0 <= x <= 3:
return self.run(
f"mdirection {str(x)}",
f"Setting Mission Pad Detection to setting {str(x)}\r\n",
Expand Down Expand Up @@ -659,7 +656,7 @@ def set_light_flash(self, r1: int, g1: int, b1: int, r2: int, g2: int,
logging.debug("Sending command: set_light_flash()")
if (255 >= r1 >= 0 and 255 >= g1 >= 0 and 255 >= b1 >= 0
and 255 >= r2 >= 0 and 255 >= g2 >= 0 and 255 >= b2 >= 0
and 2.5 >= f >= 0.1):
and 10 >= f >= 0.1):
return self.run(
f"EXT led bl {str(f)} {str(r1)} {str(g1)} {str(b1)} {str(r2)} {str(g2)} {str(b2)}",
f"Setting RMTT light color to (r, g, b): {str(r1)}, {str(g1)}, {str(b1)} and {str(r2)}, {str(g2)}, {str(b2)} with flash of {str(f)} Hz\r\n",
Expand Down Expand Up @@ -689,7 +686,7 @@ def set_display_blank(self): # TO TEST
)

def set_display_string(self, direction: str, color: str, frame_rate: float
or int, string: str):
or int, text: str):
"""Sends command to show a string on the display"""
logging.debug("Sending command: set_display_string()")
for char in direction:
Expand All @@ -699,13 +696,13 @@ def set_display_string(self, direction: str, color: str, frame_rate: float
return "matrix error"
if color in ("r", "b", "p") and 10 >= frame_rate >= 0.1:
return self.run(
f"EXT mled {str(direction)} {str(color)} {str(frame_rate)} {str(string)}",
f"Showing the string: {str(string)} with color: {str(color)}, frame rate (Hz): {str(frame_rate)} and in the diretion: {str(direction)} on the RMTT display \r\n",
f"EXT mled {str(direction)} {str(color)} {str(frame_rate)} {str(text)}",
f"Showing the string: {str(text)} with color: {str(color)}, frame rate (Hz): {str(frame_rate)} and in the diretion: {str(direction)} on the RMTT display \r\n",
)
logging.warning("tello.set_display_string(): Invalid values.")
return "matrix error"

def set_display_moving_image(self, direction: str, color: str,
def set_display_moving_image(self, direction: str,
frame_rate: float or int, pattern: str):
"""Sends command to show a moving image on the display"""
logging.debug("Sending command: set_display_moving_image()")
Expand All @@ -719,10 +716,10 @@ def set_display_moving_image(self, direction: str, color: str,
logging.warning(
"tello.set_display_moving_image(): Invalid pattern.")
return "matrix error"
if color in ("r", "b", "p") and 10 >= frame_rate >= 0.1:
if 2.5 >= frame_rate >= 0.1:
return self.run(
f"EXT mled {str(direction)} g {str(frame_rate)} {str(pattern)}",
f"Showing a moving image on the RMTT display in the direction: {str(direction)} with color: {str(color)}, frame rate (Hz): {str(frame_rate)} and pattern: {str(pattern)} \r\n",
f"Showing a moving image on the RMTT display in the direction: {str(direction)} with frame rate (Hz): {str(frame_rate)} and pattern: {str(pattern)} \r\n",
)
logging.warning("tello.set_display_moving_image(): Invalid values.")
return "matrix error"
Expand Down

0 comments on commit eccc84f

Please sign in to comment.