Changing vehicle angle_max and rates mid-flight?

Hello,

I am wondering if there is a possible solution to this. My vehicle is required to inside of buildings in tight spaces where speed is not critical, but also sometimes fly outside where speed is critical. Short of creating a new flight mode, is it possible to change parameters such as angle_max from a Lua script?

Always learning. Thank you.

Sure, you can do that.

Is this as simple as ahrs:set_angle_max?

I am not at my computer to test this but am excited to give it a try.

param:set (‘ANGLE_MAX’, 3500)

3500 = 35 degrees

if rc:get_pwm(15)>1700 then param:set (‘ANGLE_MAX’, 3500) end

1 Like

This is going to be an amazing feature for my mission requirements. Thank you all for the help! Loving this community!

Here is the script I wrote thanks to input from @Michail_Belov :

local current_angle_max = 0
local desired_angle_max = 0

function update()
  current_angle_max = param:get("ANGLE_MAX")
  if rc:get_pwm(10) > 1500 then desired_angle_max = 4000
  else desired_angle_max = 1000
  end

  if current_angle_max ~= desired_angle_max then
	param:set("ANGLE_MAX", desired_angle_max)
	gcs:send_text(0, "Angle limit set to: " .. desired_angle_max)
  end
    
  return update, 100
end

return update()

I thought maybe posting this script can help someone in the future.

Never set local xxx_angle_max=0

This asignment will be reasigned, but if something goes wrong, you may end with 0 set, and uncontrollable copter, set it to a save value even if you assume it will never be used, something lilke 2000

1 Like

Great feedback, I never considered that as a possibility. Thank you!