Initial Parameters Calculator Plugin

In the latest release (1.71) of Mission Planner, Michael added an ingenious new feature to the plugin system. It can compile (interpret) plugins written in c#.
Plugins written this way are distributed in source code form and interpreted during loading of Mission Planner.

To illustrate the benefits of this type of plugin I implemented the initial parameters calculation, based on Leonard Hall’s excellent Tuning Guide and it’s excel sheet implementation by Shawn aka xfacta on Ardupilot Discuss forum.

All you have to do is to extract this zip file to the Program Files(x86)/Mission Planner/Plugins directory (zip contains one c# source code file)

Then start Mission Planner and after connected to an Arducopter press ALT+A to start calculator

Feel free to explore the code and change it if you want.
InitialParamsCalculator.zip (2.8 KB)

12 Likes

It is a great feature!!! Ask me how i know :slight_smile:

Will test this new work from you asap :slight_smile:

Is this way of writing plugins less powerful that the old way compiling them or have access to same features?

Great tool, just tested with sim.

I would change airscrew with prop size.

On a new build you think i should load default param (wich ones for a 20 inch prop?) than copy your calculated values and do an autotune?

Thanks @Eosbandi and @Michael_Oborne that is extremely good work!

I copied the “InitialParamsCalculator.cs” file to C:\Program Files(x86)/Mission Planner/Plugins and restarted MissionPlanner - as per the instructions.
Pressing Alt-A brings up the dialog to enter basic info.
I especially like that you’ve put in the different voltages for a range of battery types - I did toy with this idea for my spreadsheet too and I was collecting the battery data.

(I chose some values to ensure all the params would show up for that screenshot)

The one thing I’d say is that writing INS_GYRO_FILTER with a value other than 20 should be optional and probably only for small frames/props. Is it possible to put some warning text at the bottom of the ParamCompare window or similar?
I’ll check the code myself, but no promises there, it’s above my pay grade.

EDIT: I just noticed the closing dialog still says it successfully updated the parameters even if you unselected all params - that’s not a big issue of course.

1 Like

Thanks for checking. I’ll update it with the warning. The success message box is a known bug, since I use the compare control from Mission planner and it does not differentiate a success or a canceled dialog :frowning:

Thanks, It is just a bit less powerful than a full blown compiled one, since runtime compiled plugins can be only single files, and use only libraries and packages that already come with Mission Planner. Single file restriction is only painful if you want a fancy form or gui.

Oh, and I’ve found some of those battery params dont exist until some form of voltage sensor is selected (even if it’s not calibrated) - hard to do anything about that but just putting it out there.

OK, Updated the file with some welcome message, prerequisites and a note about INS_GYRO_FILTER :slight_smile:

Looks good, thanks!

image

Just for info, if i wanted to do something like this:

would it be possible with a .cs script?

Any chance to get this integrated in the official MP release?

@Eosbandi, @xfacta, this is why AP is such a great project, the evolution of ideas and implementation of new ideas is amazing.
Bravo

1 Like

@xfacta once I sort out the process for doing the Loiter tuning and pilot speed up/down inclusive of fail safe descents maybe adding a table for that could be handy for the future. I know there is correlation between weight of the aircraft, prop size and air mass displacement which can cause unsteady decent. So if we go down that path to give basic loiter braking and acceleration rates and decent speeds may help with an initial setup. < will discuss later :slight_smile:

This is really great! After reading this post and looking at your example I am now also playing with making custom C# plugins. Sometimes I make stupid C# syntax errors which causes the plugin not to load/start. Is there a way that I can see more details about the reasons a plugin failed to load?

You can see compiler errors in the console (enable console window on the help screen) and they also logged to MissionPlanner.log which resides in c:\ProgramData\Mission Planner directory. (note that the ProgramData directory is hidden by default).
I recommend to delete MissionPlanner log, start MP then press CTRL+P to check if your plugin is loaded. If not, close MP and check log, you will find plugin loading at the bottom of the latest log.

But you can use visual studio (community edition is free) to develop your plugin, you can use MissionPlanner.stats plugin as a template project. Once it compiles and runs then you can take the .cs code and put in the plugin directory (so no need to compile and create a dll…)

4 Likes

Thanks for sharing this! Enabled the console and now it’s much easier to debug!
These plugins are really powerful stuff! Spent less than half a day (mostly reading the MP code) on it and so far I could add another tab page to the Data window where I can now add all my custom experimental features :slight_smile:

image

Now also getting curious to try out the dll plugins…

4 Likes

@Jan_Swanepoel I would love to see some of these plugins a main feature of MP. The amount of amazing stuff that can come out of a little bit of time and someone that knows what they are doing is invaluable to projects like these.

1 Like

If one (me), with moderate python knowledge would like to learn the basics of c# to start playing with .cs plugin, what would be your advice? Where should i start reading and learning?

The best book IMHO is : https://www.amazon.co.uk/C-7-0-Nutshell-Joseph-Albahari/dp/1491987650 There is a new book coming out soon for C# 8.0, but you can start with the 7.0 and once you grab the understanding of c# code, you have to browse the MP source code…

1 Like

I don’t understand the missionplanner.stat part, would you mind elaborate a bit?