Is there a SITL battery monitor?

Trying to hack some code to estimate motor power in SITL at the moment and would like to pull X-Plane’s battery voltage to test the idea out. Is there an easy SITL interface like there is for RPM or do I need to get my C++ hands really dirty?

Hey Andrew,

I don’t know the answer to your question, but I do have a remedy for something that surely ails you. Don’t you just hate that SITL currently will only uses the most recent dev firmware version of your vehicle. What if you want stable 4.09 or stable 4.05? Can’t have it unless you learn git and jump through 20 hoops which are a pain to learn for a non coder.

So consider commenting in my petition that you want a touch of a button feature in mission planner to choose which SITL firmware version that you want to use!

Wait actually I’ve got something to add, if you use the simulator RealFlight 9.5, it will actually estimate battery drain based on power while you fly your plane. If you’d like more details, I can provide more Tuesday.

Thanks @Shef. I’m already compiling my own code for use with SITL and X-Plane. While it’s a bit daunting to do, it’s actually reasonably well documented in various places to get it together for yourself and once you’re compiling your own code you really don’t have to bother with version updates. Actually, if you hack the code enough, the version update can be a bit of a pain, but hey, that’s life.

I’m needing to see voltage in my work because I’m coding a motor shaft power estimator to help drive a variable pitch propeller control algorithm I’ve knocked together in MS Excel. I want to see if I can make it run in X-Plane and thence into the real world. It’s forcing me to learn more C code than I thought I’d need to know, which makes for slow progress but is perhaps beneficial, hopefully!

Ah, boy that’s an endeavor. Good luck!

you need to look at the indexed list of variables pulled from Xplane’s standard and indexed list of datarefs (the list of items that you check to display on Xplane’s screen and to set by UDP). One or two of them is voltage and current. Check their indices and add them in Sim_Xplane.h file where there is an enumerated list of variables. In Sim_Xplane.cpp, just see how the xplane datarefs are read and processed to repeat it for voltage and current.

There is a new SITL battery monitor on a Pull request by Peter Barker. Take a look at that, might be a good starting point.

1 Like

@amilcarlucas would you mind giving me a linky hint here? I’ve had a trawl through Github but don’t see anything specific. Maybe I’m being dumb - not an unlikely scenario!

I think this is the PR you want,

Specifically the commit labeled “SITL: add accessor for battery voltage”

1 Like