SITL Support for Buttons

Hello,

I have implemented Button capabilities into lua scripting. All works as expected when I set the following on a physical drone:

BTN_ENABLE           1
BTN_PIN1            54
SERVO13_FUNCTION    -1 (GPIO)

However I’d like to be able to do preliminary testing of the lua scripting with the Simulation Copter.

If I set Button and Servo parameters as shown above on the Simulation Copter, the following PreArm error is reported in the Messages Tab of Mission Planner.

PreArm: BTN_PIN1=54 invalid

I dug into the Ardupilot code and know that the error is reported from the AP_Button::arming_checks function. However, I quickly get lost attempting to follow the hal.gpio->valid_pin(pin[i]) implementation from the arming_checks function.

Should I expect the Buttons feature to work in the Simulation Copter?

Or

Are Buttons a feature that is just not available in the Simulation Copter?

You can run SITL on actual cube hardware, where you have all gpio-s available.
https://ardupilot.org/dev/docs/sim-on-hardware.html

Thank you Andi for the response…

I reviewed the info at the link that you provided. Although I understand the advantages of running SITL on the hardware, that approach seems a little heavy for what I’m attempting to do. But I’ll give it some additional thought and decide if that is a route I wish to take.

Still would be nice if there were button support in the Simulation Copter. Perhaps there are larger issues/reasons that I’m unaware of that would make button support in Simulation Copter difficult.