Skip to content
This repository was archived by the owner on Feb 16, 2018. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions libardrone/libardrone.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,17 @@

DEBUG = False

# 0: "Not defined"
# 131072: "Landed"
# 393216: "Taking-off-Floor"
# 393217: "Taking-off-Air"
# 262144: "Hovering"
# 524288: "Landing"
# 458752: "Stabilizing"
# 196608: "Moving"
# 262153 and 196613: "Undefined"
ctrl_state_dict={0:0, 131072:1, 393216:2, 393217:3, 262144:4, 524288:5, 458752:6, 196608:7, 262153:8, 196613:9}


class ARDrone(object):
"""ARDrone Class.
Expand Down Expand Up @@ -537,6 +548,7 @@ def decode_navdata(packet):
values = struct.unpack_from("IIfffifffI", "".join(values))
values = dict(zip(['ctrl_state', 'battery', 'theta', 'phi', 'psi', 'altitude', 'vx', 'vy', 'vz', 'num_frames'], values))
# convert the millidegrees into degrees and round to int, as they
values['ctrl_state'] = ctrl_state_dict[values['ctrl_state']]
# are not so precise anyways
for i in 'theta', 'phi', 'psi':
values[i] = int(values[i] / 1000)
Expand Down