diff --git a/libraries/AP_Scripting/applets/ahrs-source-extnav-optflow.lua b/libraries/AP_Scripting/applets/ahrs-source-extnav-optflow.lua index 7b980ce88fa318..7f4fac241e567d 100644 --- a/libraries/AP_Scripting/applets/ahrs-source-extnav-optflow.lua +++ b/libraries/AP_Scripting/applets/ahrs-source-extnav-optflow.lua @@ -184,7 +184,7 @@ function update() -- get rangefinder distance local rngfnd_distance_m = 0 if rangefinder:has_data_orient(rangefinder_rotation) then - rngfnd_distance_m = rangefinder:distance_cm_orient(rangefinder_rotation) * 0.01 + rngfnd_distance_m = rangefinder:distance_orient(rangefinder_rotation) end local rngfnd_over_threshold = (rngfnd_distance_m == 0) or (rngfnd_distance_m > ESRC_RNGFND_MAX:get()) diff --git a/libraries/AP_Scripting/applets/plane_package_place.lua b/libraries/AP_Scripting/applets/plane_package_place.lua index 360d958a1b0ca0..7985d107c16bf3 100644 --- a/libraries/AP_Scripting/applets/plane_package_place.lua +++ b/libraries/AP_Scripting/applets/plane_package_place.lua @@ -108,7 +108,7 @@ function update() -- check the distance, if less than RNG_ORIENT_DOWN then release local dist_m if not landed then - dist_m = rangefinder:distance_cm_orient(RNG_ORIENT_DOWN) * 0.01 + dist_m = rangefinder:distance_orient(RNG_ORIENT_DOWN) else dist_m = 0.0 end diff --git a/libraries/AP_Scripting/applets/plane_precland.lua b/libraries/AP_Scripting/applets/plane_precland.lua index 1d5dc96cd8f00a..74833af8b46105 100644 --- a/libraries/AP_Scripting/applets/plane_precland.lua +++ b/libraries/AP_Scripting/applets/plane_precland.lua @@ -166,7 +166,7 @@ local function update() --[[ get rangefinder distance, and if PLND_ALT_CUTOFF is set then stop precland operation if below the cutoff --]] - local rngfnd_distance_m = rangefinder:distance_cm_orient(rangefinder_orient) * 0.01 + local rngfnd_distance_m = rangefinder:distance_orient(rangefinder_orient) if PLND_ALT_CUTOFF:get() > 0 and rngfnd_distance_m < PLND_ALT_CUTOFF:get() then return end diff --git a/libraries/AP_Scripting/examples/ahrs-source-gps-optflow.lua b/libraries/AP_Scripting/examples/ahrs-source-gps-optflow.lua index 87d9bf3a232fca..4d1634fd3f4ff7 100644 --- a/libraries/AP_Scripting/examples/ahrs-source-gps-optflow.lua +++ b/libraries/AP_Scripting/examples/ahrs-source-gps-optflow.lua @@ -121,7 +121,7 @@ function update() -- get rangefinder distance local rngfnd_distance_m = 0 if rangefinder:has_data_orient(rangefinder_rotation) then - rngfnd_distance_m = rangefinder:distance_cm_orient(rangefinder_rotation) * 0.01 + rngfnd_distance_m = rangefinder:distance_orient(rangefinder_rotation) end local rngfnd_over_threshold = (rngfnd_distance_m == 0) or (rngfnd_distance_m > rangefinder_thresh_dist) diff --git a/libraries/AP_Scripting/examples/ahrs-source.lua b/libraries/AP_Scripting/examples/ahrs-source.lua index d65104dfea40cf..9eb050e48fc8ef 100644 --- a/libraries/AP_Scripting/examples/ahrs-source.lua +++ b/libraries/AP_Scripting/examples/ahrs-source.lua @@ -85,7 +85,7 @@ function update() -- get rangefinder distance local rngfnd_distance_m = 0 if rangefinder:has_data_orient(rangefinder_rotation) then - rngfnd_distance_m = rangefinder:distance_cm_orient(rangefinder_rotation) * 0.01 + rngfnd_distance_m = rangefinder:distance_orient(rangefinder_rotation) end local rngfnd_over_threshold = (rngfnd_distance_m == 0) or (rngfnd_distance_m > rangefinder_thresh_dist) diff --git a/libraries/AP_Scripting/examples/copter-wall-climber.lua b/libraries/AP_Scripting/examples/copter-wall-climber.lua index 0028776c304424..714c9344896ba0 100644 --- a/libraries/AP_Scripting/examples/copter-wall-climber.lua +++ b/libraries/AP_Scripting/examples/copter-wall-climber.lua @@ -140,7 +140,7 @@ function update() if (climb_mode == 1) then -- convert rangefinder distance to pitch speed if rangefinder:has_data_orient(0) then - local distance_m = rangefinder:distance_cm_orient(0) * 0.01 + local distance_m = rangefinder:distance_orient(0) wall_pitch_speed = (distance_m - wall_dist_target) * wall_dist_to_speed_P wall_pitch_speed = math.min(wall_pitch_speed, wall_pitch_speed_max) wall_pitch_speed = math.max(wall_pitch_speed, -wall_pitch_speed_max) diff --git a/libraries/AP_Scripting/examples/jump_tags_calibrate_agl.lua b/libraries/AP_Scripting/examples/jump_tags_calibrate_agl.lua index 582e0ce08967b2..9d6b53a2716747 100644 --- a/libraries/AP_Scripting/examples/jump_tags_calibrate_agl.lua +++ b/libraries/AP_Scripting/examples/jump_tags_calibrate_agl.lua @@ -61,7 +61,7 @@ function sample_rangefinder_to_get_AGL() end -- we're actively sampling rangefinder distance to ground - local distance_raw_m = rangefinder:distance_cm_orient(ROTATION_PITCH_270) * 0.01 + local distance_raw_m = rangefinder:distance_orient(ROTATION_PITCH_270) -- correct the range for attitude (multiply by DCM.c.z, which is cos(roll)*cos(pitch)) local ahrs_get_rotation_body_to_ned_c_z = math.cos(ahrs:get_roll())*math.cos(ahrs:get_pitch()) diff --git a/libraries/AP_Scripting/examples/land_hagl.lua b/libraries/AP_Scripting/examples/land_hagl.lua index 3bdbc36329aea6..d630633cff4f52 100644 --- a/libraries/AP_Scripting/examples/land_hagl.lua +++ b/libraries/AP_Scripting/examples/land_hagl.lua @@ -33,7 +33,7 @@ local function send_HAGL() last_active = false return end - local rangefinder_dist = rangefinder:distance_cm_orient(RANGEFINDER_ORIENT)*0.01 + local rangefinder_dist = rangefinder:distance_orient(RANGEFINDER_ORIENT) local correction = math.cos(ahrs:get_roll())*math.cos(ahrs:get_pitch()) local rangefinder_corrected = rangefinder_dist * correction if RANGEFINDER_ORIENT == ROTATION_PITCH_90 then diff --git a/libraries/AP_Scripting/examples/rangefinder_quality_test.lua b/libraries/AP_Scripting/examples/rangefinder_quality_test.lua index 1767b6bb8540d7..4c93bf4ac289df 100644 --- a/libraries/AP_Scripting/examples/rangefinder_quality_test.lua +++ b/libraries/AP_Scripting/examples/rangefinder_quality_test.lua @@ -88,12 +88,12 @@ local function get_and_eval(test_idx, dist_m_in, signal_quality_pct_in, status_e -- L U A I N T E R F A C E T E S T -- Check that the distance and signal_quality from the frontend are as expected - local distance1_cm_out = rangefinder:distance_cm_orient(RNGFND_ORIENTATION_DOWN) + local distance1_cm_out = rangefinder:distance_orient(RNGFND_ORIENTATION_DOWN) * 100 local signal_quality1_pct_out = rangefinder:signal_quality_pct_orient(RNGFND_ORIENTATION_DOWN) -- Make sure data was returned if not distance1_cm_out or not signal_quality1_pct_out then - return "No data returned from rangefinder:distance_cm_orient()" + return "No data returned from rangefinder:distance_orient()" end send(string.format("Frontend test %i dist in_m: %.2f out_cm: %.2f, signal_quality_pct in: %.1f out: %.1f",