Using the low level protocoll require calculation of crc8 and crc16.
Which algorithm has to be used?
Thanks in advance
f41ardu
Which algorithm has to be used?
Thanks in advance
f41ardu
I know, but need the algorithm used to implemet them using Python. I already transfered parts of tellolib into Processing (java like). Ugly to be honest, so I'm looking for the algorithm to get this implemented in Python.check tellolib. It contains several bugs but should get you started.
Thanks,Check out this python implementation, it uses a table with the _calcCRC8 function
......
# Init pygame
pygame.init()
# Creat pygame window
pygame.display.set_caption("Video Feed")
screen = pygame.display.set_mode([960,720])
# create update timer
pygame.time.set_timer(USEREVENT + 1, 50)
###############################################################################
# main
###############################################################################
#print( 'Tello Controller '
#print( '+------------------------------------+'
#print( '| ESC(quit) 1(360) 2(bounce) |'
#print( '+------------------------------------+'
#print( '| |'
#print( '| w up |'
#print( '| a d left right |'
#print( '| s down |'
#print( '| |'
#print( '| space(takeoff/land) |'
#print( '| |'
#print( '+------------------------------------+'
mDrone = tello.Tello()
#keyboard.hook(handleKey)
while True:
for event in pygame.event.get():
if event.type == USEREVENT + 1:
update()
elif event.type == QUIT:
should_stop = True
elif event.type == KEYDOWN:
if event.key == K_ESCAPE:
should_stop = True
else:
keydown(event.key)
elif event.type == KEYUP:
keyup(event.key)
def update():
global mRCVal
global mDrone
""" Update routine. Send velocities to Tello."""
mDrone.setStickData(0, mRCVal[IDX_ROLL], mRCVal[IDX_PITCH], mRCVal[IDX_THR], mRCVal[IDX_YAW])
def keydown(key):
""" Update velocities based on key pressed
Arguments:
key: pygame key
"""
global pygame
global mRCVal
if key == pygame.K_UP: # set forward velocity
mRCVal[IDX_PITCH] = RC_VAL_MAX
elif key == pygame.K_DOWN: # set backward velocity
mRCVal[IDX_PITCH] = RC_VAL_MIN
elif key == pygame.K_LEFT: # set left velocity
mRCVal[IDX_ROLL] = RC_VAL_MIN
elif key == pygame.K_RIGHT: # set right velocity
mRCVal[IDX_ROLL] = RC_VAL_MAX
elif key == pygame.K_w: # set up velocity
mRCVal[IDX_THR] = RC_VAL_MAX
elif key == pygame.K_s: # set down velocity
mRCVal[IDX_THR] = RC_VAL_MIN
elif key == pygame.K_a: # set yaw clockwise velocity
mRCVal[IDX_YAW] = RC_VAL_MIN
elif key == pygame.K_d: # set yaw counter clockwise velocity
mRCVal[IDX_YAW] = RC_VAL_MAX
elif key == pygame.K_1: # set yaw counter clockwise velocity
mDrone.setSmartVideoShot(tello.Tello.TELLO_SMART_VIDEO_360, True)
print( 'SmartVideo 360 start')
def keyup(key):
""" Update velocities based on key released
Arguments:
key: pygame key
"""
global mDrone
if key == pygame.K_UP or key == pygame.K_DOWN: # set zero forward/backward velocity
mRCVal[IDX_PITCH] = RC_VAL_MID
elif key == pygame.K_LEFT or key == pygame.K_RIGHT: # set zero left/right velocity
mRCVal[IDX_ROLL] = RC_VAL_MID
elif key == pygame.K_w or key == pygame.K_s: # set zero up/down velocity
mRCVal[IDX_THR] = RC_VAL_MID
elif key == pygame.K_a or key == pygame.K_d: # set zero yaw velocity
mRCVal[IDX_YAW] = RC_VAL_MID
elif key == pygame.K_t: # takeoff
mDrone.takeOff()
print( 'take off')
elif key == pygame.K_l: # land
mDrone.land()
print( 'land')
We use essential cookies to make this site work, and optional cookies to enhance your experience.