Skip to content

Config: Full Parameter List: allow math expressions #2731

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 23, 2021

Conversation

IamPete1
Copy link
Member

This allows params to be entered as basic math expressions in the full list.

1+2, 5*10, 8/9 ect

Brackets work, but not constants, powers or trig.

We could do more complex expressions if we were to add a math parser sub-module, but this gets us 99% of what anyone will use, and sub-modules are above by C# skill level.

@AppVeyorBot
Copy link

@meee1
Copy link
Contributor

meee1 commented Nov 21, 2021

mission planner already includes
MathParser.org-mXparser

in the "extlibs/utilities" project. so you could check out this as it may have better overall support for the wierd stuff

@AppVeyorBot
Copy link

@IamPete1
Copy link
Member Author

@meee1 even better, I have switched to that, things like cos(pi) work, sqrt(25) ect. While playing about I discovered you could get a NaN so I have also added handling for that case.

@AppVeyorBot
Copy link

if (float.IsNaN(newvalue) || float.IsInfinity(newvalue))
{
Params.CellValueChanged -= Params_CellValueChanged;
Params[e.ColumnIndex, e.RowIndex].Value = newvalue;
Copy link
Contributor

Choose a reason for hiding this comment

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

question? is this meant to be new value? or a restore of the old value?

Copy link
Member Author

Choose a reason for hiding this comment

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

I put the new value, ie the NaN, so you can see your equation was wrong. Then again you could argue that it is better to leave it, the cell will go red thanks to the exception, and you can try and correct it. Maybe that would be nicer?

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah, i could go either way. changing it to NaN means you would have to reload the screen to see the old value.

Copy link
Member Author

Choose a reason for hiding this comment

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

@meee1 I have changed to not over write the value. So no you get left with what you typed in with the red background. This mean you can correct the error in the equation. This is also consistent with what happens in current version if you enter a none number.

@AppVeyorBot
Copy link

@meee1 meee1 merged commit e5248e2 into ArduPilot:master Nov 23, 2021
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