ArduPilot / ardupilot

ArduPlane, ArduCopter, ArduRover, ArduSub source
http://ardupilot.org/
GNU General Public License v3.0
11.02k stars 17.57k forks source link

Servo output based on arming state. (like servo 30 function) #26492

Open VinceHogg opened 8 months ago

VinceHogg commented 8 months ago

Servo function 30 is described as 'engine run enable' or 'motor enable' and is supposed to output 2 PWM values depending on arming state. It would also be useful for turning on or off equipment before flight. However in copter 4.4.4 it seems to do nothing. Perhaps it works when ICE_ENABLE=1 ? This parameter in not in copter. Could it be enabled for all vehicles as a general propose feature?

Thanks.

IamPete1 commented 8 months ago

Run enable is a helicopter feature.

It would be a quite simple lua script to do as you describe. Something like:

-- use scripting 1 servo output
local SRV_function = 94

-- set scaled range as 0 to 1
SRV_Channels:set_range(SRV_function, 1.0)

function update()
  if arming:is_armed() then
    SRV_Channels:set_output_scaled(SRV_function, 1.0)
  else
    SRV_Channels:set_output_scaled(SRV_function, 0.0)
  end

  return update, 100 -- run at 10 Hz
end

return update() 
VinceHogg commented 8 months ago

Thanks for that. It may be simple but its been 20 years since I did any programming. I should get my self more familiar with it. It may be a good idea to open that servo 30 feature for all vehicles and perhaps rename. It could still be used for the original purpose.

peterbarker commented 3 months ago

Thanks for that. It may be simple but its been 20 years since I did any programming. I should get my self more familiar with it. It may be a good idea to open that servo 30 feature for all vehicles and perhaps rename. It could still be used for the original purpose.

I don't think re-purposing 30 is a good idea; it might be that the user wants to remain armed while also killing the motor. For example, we have an option to turn on the safety switch when you disarm - a user might want their ailerons to continue to function even when they've chosen to kill the motor in-flight.

@VinceHogg is @IamPete1 's script enough to get you by?