get_angle_target() and get_rate_target() in AP_Mount_Backend and AP_Mount
are now declared and defined only when AP_SCRIPTING_ENABLED is set,
matching the existing treatment of get_location_target().
AP_Mount_Backend::write_log() read mnt_target directly when scripting is
not compiled in, avoiding the dependency on those methods.
AP_Mount_Scripting gains its own ScriptTargetType enum and
_angle_target/_rate_target members. send_target_angles() and
send_target_rates() now store the pushed target into those members.
get_angle_target() / get_rate_target() overrides return the stored values,
removing the previous hack of stamping mnt_target.target_type = ANGLE
inside send_target_angles(). _script_target_type is reset to NONE at the
top of each update() cycle so stale targets are never returned.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Scripting backends (e.g. mount-djirs2-driver.lua) poll get_angle_target()
and get_rate_target() rather than receiving pushed targets. Before this
fix, get_angle_target() returned false for RETRACT, NEUTRAL, and LOCATION
modes because it only checked target_type == ANGLE, even though
send_target_to_gimbal() had already written the converted angle into
mnt_target.angle_rad.
Fix by calling send_target_to_gimbal() from AP_Mount_Scripting::update()
(matching every other backend) and implementing send_target_angles() to
stamp mnt_target.target_type = ANGLE after send_target_to_gimbal() has
written the converted value into mnt_target.angle_rad. This makes
get_angle_target() return the converted value without any changes to the
base class.
Declare NATIVE_ANGLES_AND_RATES_ONLY so that RATE targets are not
converted to angles internally; the Lua script receives them via
get_rate_target() and performs its own integration. send_target_rates()
is a no-op because mnt_target.target_type stays RATE, which is all
get_rate_target() checks.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
If a backend gets the target mode converted to angle, get_angle_target
will return the converted angles. This fixes scripting backends that
relied on get_angle_target
Fix the broken get_location_target method and move it up to generic
backend so that can be used by all backends
Remove flag variables that were used to determine valid or invalid
Location variables and use the initialized() method instead.
Should fix#31535
Signed-off-by: neo-0007 <hrishikeshgohain123@gmail.com>