forked from ArduPilot/ardupilot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
232 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
|
||
Set SCR_ENABLE 1 | ||
use RC 8 to set/unset standby | ||
use RC_override in broadcast to send to both FCUs. | ||
|
||
Tools/autotest/sim_vehicle.py -v ArduCopter -f + --slave 1 -I0 --sysid 1 --use-dir=FCU1 --add-param-file=$(pwd)/2rm.parm -A "--serial1=tcp:5761 " --console --map --no-rcin | ||
|
||
Tools/autotest/sim_vehicle.py -v ArduCopter --model json:0.0.0.0 --slave 0 -I1 --sysid 2 --use-dir=FCU2 --add-param-file=$(pwd)/2rm.parm -A "--serial1=tcpclient:127.0.0.1:5761 " --debug --no-rebuild -m "--console --source-system 252" --no-rcin | ||
|
||
|
||
Tools/autotest/sim_vehicle.py -v ArduCopter -f + -I0 --sysid 1 --use-dir=FCU1 --add-param-file=$(pwd)/2rm.parm -A "--serial1=tcp:5761 " --add-param-file=$(pwd)/2rm.parm --console --map --no-rcin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
SCR_ENABLE 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
-- This script is a test of param set and get | ||
|
||
local count = 0 | ||
local last_value = 0 | ||
local last_rc8_input = 0 | ||
|
||
local switch_high = 2 | ||
local switch_low = 0 | ||
local standby_function = 76 | ||
|
||
local scripting_rc_1 = rc:find_channel_for_option(300) | ||
|
||
|
||
-- for fast param acess it is better to get a param object, | ||
-- this saves the code searching for the param by name every time | ||
local JSON_MASTER = Parameter() | ||
if not JSON_MASTER:init('SIM_JSON_MASTER') then | ||
gcs:send_text(6, 'get JSON_MASTER failed') | ||
end | ||
|
||
local SYSID_THISMAV = Parameter() | ||
if not SYSID_THISMAV:init('SYSID_THISMAV') then | ||
gcs:send_text(6, 'get SYSID_THISMAV failed') | ||
end | ||
|
||
|
||
local sysid = SYSID_THISMAV:get() | ||
|
||
-- this allows this example to catch the otherwise fatal error | ||
-- not recommend if error is possible/expected, use separate construction and init | ||
|
||
-- local user_param = Parameter('SCR_USER1') | ||
-- is equivalent to: | ||
-- local user_param = Parameter() | ||
-- assert(user_param:init('SCR_USER1'), 'No parameter: SCR_USER1') | ||
gcs:send_text(6, 'LUA: hello') | ||
|
||
function update() -- this is the loop which periodically runs | ||
|
||
-- get and print all the scripting parameters | ||
local value = JSON_MASTER:get() | ||
if value then | ||
if value ~= last_value then | ||
gcs:send_text(6, string.format('LUA: SIM_JSON_MASTER: %i',value)) | ||
last_value = value | ||
end | ||
else | ||
gcs:send_text(6, 'LUA: get SIM_JSON_MASTER failed') | ||
end | ||
|
||
rc8_input = rc:get_pwm(8) | ||
-- standby switch enable == high | ||
|
||
if rc8_input ~= last_rc8_input then | ||
if sysid == 2 then | ||
if rc8_input > 1500 then | ||
if not JSON_MASTER:set(0) then | ||
gcs:send_text(6, string.format('LUA: failed to set JSON_MASTER')) | ||
else | ||
rc:run_aux_function(standby_function, switch_high) | ||
gcs:send_text(6, string.format('LUA: set JSON_MASTER to 0')) | ||
end | ||
else | ||
if not JSON_MASTER:set(1) then | ||
gcs:send_text(6, string.format('LUA: failed to set JSON_MASTER')) | ||
else | ||
rc:run_aux_function(standby_function, switch_low) | ||
gcs:send_text(6, string.format('LUA: set JSON_MASTER to 1')) | ||
end | ||
end | ||
end | ||
if sysid == 1 then | ||
if rc8_input > 1500 then | ||
if not JSON_MASTER:set(0) then | ||
gcs:send_text(6, string.format('LUA: failed to set JSON_MASTER')) | ||
else | ||
rc:run_aux_function(standby_function, switch_low) | ||
gcs:send_text(6, string.format('LUA: set JSON_MASTER to 0')) | ||
end | ||
else | ||
if not JSON_MASTER:set(1) then | ||
gcs:send_text(6, string.format('LUA: failed to set JSON_MASTER')) | ||
else | ||
rc:run_aux_function(standby_function, switch_high) | ||
gcs:send_text(6, string.format('LUA: set JSON_MASTER to 1')) | ||
end | ||
end | ||
end | ||
last_rc8_input = rc8_input | ||
end | ||
|
||
return update, 1000 -- reschedules the loop | ||
end | ||
|
||
return update() -- run immediately before starting to reschedule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
-- This script is a test of param set and get | ||
|
||
local count = 0 | ||
local last_value = 0 | ||
local last_rc8_input = 0 | ||
|
||
local switch_high = 2 | ||
local switch_low = 0 | ||
local standby_function = 76 | ||
|
||
local scripting_rc_1 = rc:find_channel_for_option(300) | ||
|
||
|
||
-- for fast param acess it is better to get a param object, | ||
-- this saves the code searching for the param by name every time | ||
local JSON_MASTER = Parameter() | ||
if not JSON_MASTER:init('SIM_JSON_MASTER') then | ||
gcs:send_text(6, 'get JSON_MASTER failed') | ||
end | ||
|
||
local SYSID_THISMAV = Parameter() | ||
if not SYSID_THISMAV:init('SYSID_THISMAV') then | ||
gcs:send_text(6, 'get SYSID_THISMAV failed') | ||
end | ||
|
||
|
||
local sysid = SYSID_THISMAV:get() | ||
|
||
-- this allows this example to catch the otherwise fatal error | ||
-- not recommend if error is possible/expected, use separate construction and init | ||
|
||
-- local user_param = Parameter('SCR_USER1') | ||
-- is equivalent to: | ||
-- local user_param = Parameter() | ||
-- assert(user_param:init('SCR_USER1'), 'No parameter: SCR_USER1') | ||
gcs:send_text(6, 'LUA: hello') | ||
|
||
function update() -- this is the loop which periodically runs | ||
|
||
-- get and print all the scripting parameters | ||
local value = JSON_MASTER:get() | ||
if value then | ||
if value ~= last_value then | ||
gcs:send_text(6, string.format('LUA: SIM_JSON_MASTER: %i',value)) | ||
last_value = value | ||
end | ||
else | ||
gcs:send_text(6, 'LUA: get SIM_JSON_MASTER failed') | ||
end | ||
|
||
rc8_input = rc:get_pwm(8) | ||
-- standby switch enable == high | ||
|
||
if rc8_input ~= last_rc8_input then | ||
if sysid == 2 then | ||
if rc8_input > 1500 then | ||
if not JSON_MASTER:set(0) then | ||
gcs:send_text(6, string.format('LUA: failed to set JSON_MASTER')) | ||
else | ||
rc:run_aux_function(standby_function, switch_high) | ||
gcs:send_text(6, string.format('LUA: set JSON_MASTER to 0')) | ||
end | ||
else | ||
if not JSON_MASTER:set(1) then | ||
gcs:send_text(6, string.format('LUA: failed to set JSON_MASTER')) | ||
else | ||
rc:run_aux_function(standby_function, switch_low) | ||
gcs:send_text(6, string.format('LUA: set JSON_MASTER to 1')) | ||
end | ||
end | ||
end | ||
if sysid == 1 then | ||
if rc8_input > 1500 then | ||
if not JSON_MASTER:set(0) then | ||
gcs:send_text(6, string.format('LUA: failed to set JSON_MASTER')) | ||
else | ||
rc:run_aux_function(standby_function, switch_low) | ||
gcs:send_text(6, string.format('LUA: set JSON_MASTER to 0')) | ||
end | ||
else | ||
if not JSON_MASTER:set(1) then | ||
gcs:send_text(6, string.format('LUA: failed to set JSON_MASTER')) | ||
else | ||
rc:run_aux_function(standby_function, switch_high) | ||
gcs:send_text(6, string.format('LUA: set JSON_MASTER to 1')) | ||
end | ||
end | ||
end | ||
last_rc8_input = rc8_input | ||
end | ||
|
||
return update, 1000 -- reschedules the loop | ||
end | ||
|
||
return update() -- run immediately before starting to reschedule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters