-
-
Notifications
You must be signed in to change notification settings - Fork 56
Expand file tree
/
Copy pathread_rc.lua
More file actions
31 lines (24 loc) · 705 Bytes
/
read_rc.lua
File metadata and controls
31 lines (24 loc) · 705 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
-- Description: This script reads RC inputs.
-- define global variables
local MAV_SEVERITY_DEBUG = 7
local LOOP_DELAY_IN_MS = 1000
-- read channel
function read_channel(channel)
local channel_value = rc:get_pwm(channel)
if not channel_value then
return 0
end
return channel_value
end
-- read RC input
function read_rc()
-- read RC inputs
local channel_6 = read_channel(6)
local channel_7 = read_channel(7)
-- log RC inputs
gcs:send_text(MAV_SEVERITY_DEBUG, "RC input: channel 6 = " .. channel_6 .. ", channel 7 = " .. channel_7)
-- schedule the next call to this function
return read_rc, LOOP_DELAY_IN_MS
end
-- start the script
return read_rc()