AP_Scripting: add set_origin and initialised bindings

added bindings and example scripts
This commit is contained in:
CallanDaniel 2021-07-02 17:00:07 +02:00 committed by Randy Mackay
parent 0217d1c3dc
commit c34322f6ce
2 changed files with 25 additions and 0 deletions

View File

@ -0,0 +1,23 @@
-- example script for using "set_origin()"" and "initialised()"
-- sets the ekf origin if not already set
function update ()
if not ahrs:initialised() then
return update, 5000
end
origin = assert(not ahrs:get_origin(),"Refused to set EKF origin - already set")
location = Location() location:lat(-353632640) location:lng(1491652352) location:alt(58409)
if ahrs:set_origin(location) then
gcs:send_text(0, string.format("Origin Set - Lat:%.7f Long:%.7f Alt:%.1f", location:lat()/10000000, location:lng()/10000000, location:alt()/100))
else
gcs:send_text(0, "Refused to set EKF origin")
end
return
end
return update()

View File

@ -46,6 +46,8 @@ singleton AP_AHRS method set_posvelyaw_source_set void uint8_t 0 2
singleton AP_AHRS method get_vel_innovations_and_variances_for_source boolean uint8_t 3 6 Vector3f'Null Vector3f'Null
singleton AP_AHRS method set_home boolean Location
singleton AP_AHRS method get_origin boolean Location'Null
singleton AP_AHRS method set_origin boolean Location
singleton AP_AHRS method initialised boolean
include AP_Arming/AP_Arming.h