-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathread_parameters.py
More file actions
32 lines (26 loc) · 800 Bytes
/
Copy pathread_parameters.py
File metadata and controls
32 lines (26 loc) · 800 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
"""
Example of how to read all the parameters from the Autopilot with pymavlink
"""
# Disable "Broad exception" warning
# pylint: disable=W0703
import time
import sys
# Import mavutil
from pymavlink import mavutil
# Create the connection
master = mavutil.mavlink_connection('tcp:127.0.0.1:5762')
# Wait a heartbeat before sending commands
master.wait_heartbeat()
# Request all parameters
master.mav.param_request_list_send(
master.target_system, master.target_component
)
while True:
time.sleep(0.01)
try:
message = master.recv_match(type='PARAM_VALUE', blocking=True).to_dict()
print('name: %s\tvalue: %d' % (message['param_id'],
message['param_value']))
except Exception as error:
print(error)
sys.exit(0)