Change sensor value via Lua script

Hi. I need to change any sensor value when some event happens in lua script.
I need to make sound notification on me FS-i6 Remote control when I save waypoint. The only way to make the sound is set alarm on some sensor value changes. Due to I build a boat, I dont use most of sensors, but can set alarm on it. I need to change sensor value or send it via mavlink when wp saved. Is it possible to do? Thank you.

Please do not post the same question more than once ( How to check if WP saved via LUA script - ArduPilot Lua Scripting - ArduPilot Discourse).

I think you should monitor mission:num_commands(). Send that value back as a gcs:send_named_float(), and it will be available on the Quick tab of Mission Planner. Each time a WP is saved, the value will increase by one.

I am not familiar with your transmitter’s capabilities, so I’m not sure how to monitor that value on the transmitter and set an alarm accordingly.

Thanx for your reply. Since nobody answered the other topic, I have tried myself and figure out how to check if way point saved. So no more questions about saving waypoints I tried to delete that topic but I have no permission.
In this topic I asked another question.
The only way to make my transmitter play sound is to alarm when any of input telemetry data has changed. The idea is to change some value I don’t use in my project (temperature, pressure, altitude) using script. But I dont know how to do it.
I read this in the documantation

  • alt( [new_alt] ) - If called with no arguments, returns the current altitude in cm as an integer. If called with one argument, it will assign the value to the altitude.

Hoped that this is the answer. But no success.

I don’t think that arbitrarily changing an AHRS position value is advisable.

If you are only using one battery monitor, perhaps you could apply a known voltage to the second battery sense pin (usually no more than 3v3), and then change BATT2_VOLT_MULT by some meaningful value that’s detectable by your transmitter.

Make sure that you don’t have any failsafes tied to BATT2 if you try this method.

Thank you. I will try your advice with battery.
I think for the boat altitude is not important. Anyway, is it possible to change altitude value using lua script?

I’ve never tried. I agree it doesn’t seem important, but all position estimates are stored in a vector format, and I suspect that changing the vector length by a large amount could cause some other unwanted behavior.

Additionally, it would probably just be overwritten by GPS data almost immediately, anyway.

Altitude is still calculated and updated for rover its just not used for navigation, batt2 is your best option just disable the failsafes on if first.