Skip to content

Conversation

ashober
Copy link

@ashober ashober commented Aug 6, 2025

Added bindings for public methods of AC_Sprayer.

Expected behavior: Sprayer pump can be controlled from Lua like it can from RC channels.
Tested on CubeOrange+ with HobbyWing XRotor 5L pump
Pump responded to Lua code.

singleton AC_PosControl method get_vel_target boolean Vector3f'Null
singleton AC_PosControl method get_accel_target boolean Vector3f'Null

include AC_Sprayer/AC_Sprayer.h depends APM_BUILD_TYPE(APM_BUILD_ArduCopter) || APM_BUILD_TYPE(APM_BUILD_Rover)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think maybe this should be dependent upon HAL_SPRAYER_ENABLED rather than the vehicle?

@rmackay9
Copy link
Contributor

rmackay9 commented Aug 6, 2025

This generally looks OK to me.

It doesn't affect the code but just as a side note, we can see this is a very old library because the "run" method is used to enable/disable the sprayer. Our standard these days is to call the method, "enable". "run" is too close to "update" so it's confusing. Still, it's existing code so not an issue for this PR

@tpwrules
Copy link
Contributor

tpwrules commented Aug 7, 2025

Thanks for looking into this and proposing bindings.

Some concerns:

  • The update method is called by the scheduler, it shouldn't be accessible to Lua
  • Does this need to take some kind of mutex? I think the general scheduler one since that's where update is called. I think this is what a scheduler-semaphore line would be for.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants