A tidy way to talk to a Drone through PyMavLink
Project description
This project will contain an opinionated but tidy way to talk to a Drone through PyMavLink using the PyFlightCoach Libraries
Setup the connection:
from droneinterface import Vehicle
vehicle = Vehicle.connect('tcp:127.0.0.1:5762')
Get a single mavlink message wrapped in a pyflightcoach wrapper:
>>> vehicle.get_GlobalPositionInt()
GlobalPositionInt(
position=GPS(lat_=51.42 long_=-2.67 alt_=117.33, len=1),
agl=0.055,
velocity=Point(x_=-0.02 y_=-0.01 z_=0.0, len=1),
heading=13.95565269894666,
time_boot_ms=1840783
)
wait up to 1 second for a message:
>>> vehicle.next_heartbeat(1).type
MAV_TYPE(1=['mav_type_generic', 'mav_type_fixed_wing'])
Don't wait long enough:
>>> vehicle.next_heartbeat(1e-6)
droneinterface.scheduling.exceptions.Timeout: timeout after 1e-06 seconds waiting for message 0
Getting a pyflightcoach state object (combines 3 mavlink messages):
>>> vehicle.get_state().data
x y z rw rx ry rz t dt ... p q r du dv dw dp dq dr
0.0 -0.006941 -0.022264 0.01 -0.012416 0.989064 0.080289 0.123095 1.709667e+09 0.033333 ... -0.006507 -0.022492 0.00954 -0.567203 -1.919822 997.321415 0.0 0.0 0.0
[1 rows x 21 columns]
>>>
subscribing to a higher messaging rate:
with vehicle.subscribe(vehicle.state.ids, 10):
print(vehicle.next_state().data)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
droneinterface-0.0.4.tar.gz
(14.3 kB
view hashes)
Built Distribution
Close
Hashes for droneinterface-0.0.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1f72a484d9287654c1de4c629307c9bacaba931d3637197b661be8feb10a4f79 |
|
MD5 | 725b83359b6a4247af41feeca14b2b67 |
|
BLAKE2b-256 | a6b1d674445d17879ab9c220a4f56d6b19302eef7ace6f5e85388684e5f41136 |