diff --git a/libraries/AP_Scripting/docs/docs.lua b/libraries/AP_Scripting/docs/docs.lua index bbce390216b..b140ac7870d 100644 --- a/libraries/AP_Scripting/docs/docs.lua +++ b/libraries/AP_Scripting/docs/docs.lua @@ -3851,6 +3851,9 @@ function ahrs:groundspeed_vector() end function ahrs:get_wind() end -- Returns a Vector3f containing the current wind estimate for the vehicle. +-- Deprecated, use get_wind; this gives no indication of whether the vehicle +-- actually has a valid wind estimate, so the returned vector may be zero or stale. +---@deprecated Use get_wind ---@return Vector3f_ud -- wind estiamte North, East, Down meters / second function ahrs:wind_estimate() end diff --git a/libraries/AP_Scripting/lua_bindings.cpp b/libraries/AP_Scripting/lua_bindings.cpp index a216243acbb..334fbbf0fc3 100644 --- a/libraries/AP_Scripting/lua_bindings.cpp +++ b/libraries/AP_Scripting/lua_bindings.cpp @@ -20,6 +20,7 @@ #include #include +#include #include #include "lua/src/lauxlib.h" @@ -1226,17 +1227,27 @@ int lua_gps_inject_data(lua_State *L) #if AP_AHRS_ENABLED /* - compatibility binding for the Vector3f-returning + deprecated compatibility binding for the Vector3f-returning AP_AHRS::wind_estimate() method which has been removed from the AHRS - interface. Scripting has no way of receiving both the vector and the - validity flag from AP_AHRS::get_wind(), so the validity is discarded - here and the vector returned regardless; it may be zero or stale. + interface. The validity of the estimate is discarded here and the + vector returned regardless; it may be zero or stale. Scripts should + use ahrs:get_wind() instead. + + the generator can not attach a deprecation warning to a manual + binding, so it is emitted here in the same manner as the generated + bindings do it. */ int lua_AP_AHRS_wind_estimate(lua_State *L) { binding_argcheck(L, 1); AP_AHRS *ahrs = check_AP_AHRS(L); + static bool warned; + if (!warned) { + lua_scripts::set_and_print_new_error_message(MAV_SEVERITY_WARNING, "ahrs:wind_estimate Use get_wind"); + warned = true; + } + Vector3f wind; { WITH_SEMAPHORE(ahrs->get_semaphore());