How to send battary voltage in SITL using JSON interface?

Hi,
I am using JSON interface (-> ardupilot/libraries/SITL/examples/JSON/readme.md at master · ArduPilot/ardupilot · GitHub ) for my physical backend in a SITL simulation.

Now I like to change the battary value as well over JSON, so I thought I have to add something like a “battary”-node with a voltage value.

Is this possible and if so how to setup this? (Sorry, I didn’t find a more detailed information about the JSON interface)
In the case this is not the right approach, how can I achive this?

Many thanks for your help

You may start from neglecting the following values in SITL/SIM_Aircraft.cpp

    fdm.battery_voltage = battery_voltage;
    fdm.battery_current = battery_current;

after that voltage output should be considered in SIM_JSON.cpp, in the following function:

void JSON::recv_fdm(const struct sitl_input &input)

So by tracking the fdm.battery_voltage = battery_voltage; in sitl to replace its value with the values that received from JSON connection will do what you want

Thank you for your response.

I took a look at the code and I understand (or misunderstand) that I have to change the code and build it on my own to achive the goal setting battary values via JSON.

Is that correct?

Thx

hello,

Yes, we didn’t implement battery stats into JSON backend, so you will have to do it. Maybe an opportunity for a first contribution ? :grinning_face:

Yes, that’s correct. All sections related to these variables should be reviewed and updated accordingly.

:smiley: Yes of course! I will do my very best.
Thank you for your reply

Thank you very much for your answer. I still need to warm up to the ArduPilot coding world.
I’m sure I’ll have more questions :smiley: