Skip to content
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

Square Root math for Calculated Sensors #4491

Closed
walrath596 opened this issue Sep 7, 2024 · 21 comments
Closed

Square Root math for Calculated Sensors #4491

walrath596 opened this issue Sep 7, 2024 · 21 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@walrath596
Copy link

Would be great to have the option to make calculated sensors that can multiply by the square root of a value. This would allow us to correct stall speeds for any G forces.

@noamkrief
Copy link

I agree. Please add square root as an option.
It's good for stall warning detection because you multiply the level flight stall speed by the square root of the G force from the accelerometer.

@PeterGraz
Copy link

Meanwhile you could use the approximation:
sqrt(G) = 0.75 + G (0.3 - 0.006 G) with an max error of 8% over the range from 1 to 20 G

@PeterGraz
Copy link

... or
sqrt(G) = 0.58 + G (0.46 - 0.027 G) with an max error of 1.6% over the range from 1 to 5 G

@noamkrief
Copy link

@PeterGraz this is wild! I didn't know such formula existed! amazing!

@walrath596
Copy link
Author

walrath596 commented Sep 16, 2024 via email

@PeterGraz
Copy link

Unfortunately, you have interpreted my formula incorrectly (parenthesis rule!).

The calculation for the formula 0.75 + G (0.3 - 0.006 G) is as follows:

$ for G=1

multiply 0.006 by G: 0.006 G = 0.006
subtract this result form 0.3: 0.3 - 0.006 = 0.294
multiply this result by G: 0.294 G = 0.294
add this result to 0.75: 0.75 + 0.294 = 1.044
done

The result is too big by .044 or 4.4% off.

$ for G=10

multiply 0.006 by G: 0.006 G = 0.06
subtract this result form 0.3: 0.3 - 0.006 = 0.24
multiply this result by G: 0.24 G = 2.4
add this result to 0.75: 0.75 + 2.4 = 3,15
done

The result is too small by .0123 or 0.39% off.

… for the second formula 0.58 + G (0.46 - 0.027 G) it follows:

$ for G=1

multiply 0.027 by G: 0.027 G = 0.027
subtract this result form 0.46: 0.46 - 0.027 = 0.433
multiply this result by G: 0.433 G = 0.433
add this result to 0.58: 0.58 + 0.433 = 1.013
done

The result is too big by .013 or 1.3% off.

$ for G=5

multiply 0.027 by G: 0.027 G = 0.135
subtract this result form 0.46: 0.46 - 0.135 = 0.325
multiply this result by G: 0.325 G = 1.625
add this result to 0.58: 0.58 + 1.625 = 2,205
done

The result is again too small by .0139 or 1.4% off.

Enjoy, Peter

@walrath596
Copy link
Author

walrath596 commented Sep 16, 2024 via email

@walrath596
Copy link
Author

walrath596 commented Sep 28, 2024 via email

@PeterGraz
Copy link

When I made the suggestion with the approximation formula, I wasn't thinking about the implementation in Ethos. In the meantime, I have tried several times to realize my formula(s) using a calculated sensor. However, there are currently several problems when using a user-defined formula.
I will document some of the problems under Issues in the next few hours.

@walrath596
Copy link
Author

walrath596 commented Sep 30, 2024 via email

@PeterGraz
Copy link

Bertrand just fixed all the problems I discovered with Calculated Sensors. Therefore, with Ethos 1.5.16 you should be able to implement my approximations.

@walrath596
Copy link
Author

walrath596 commented Oct 2, 2024 via email

@PeterGraz
Copy link

Unfortunately, we still have to wait a bit.

@walrath596
Copy link
Author

walrath596 commented Oct 2, 2024 via email

@noamkrief
Copy link

Do you guys want me just to make a widget that runs in the background that will do sqrt until @bsongis-frsky hopefully ads it some day.

I just feel bad for you guys trying to figure it out.

Let me know - I can probably complete it tonight.

@walrath596
Copy link
Author

walrath596 commented Oct 2, 2024 via email

@noamkrief
Copy link

noamkrief commented Oct 3, 2024

Here you go:

  1. it can be on any screen. It doesn't have to be active screen to work.
  2. it will automatically create a sensor called sqrt in telemetry. Probably at the end.
  3. in the menu of my widget, select the source of what you want to sqrt of.
  4. it does square root of the absolute value. That's because the frksy reports the downward G's as -1 instead of +1
    sqrt.zip

Please let me know if it works or not.

attached

@bsongis-frsky bsongis-frsky self-assigned this Oct 3, 2024
@bsongis-frsky bsongis-frsky added the enhancement New feature or request label Oct 3, 2024
@bsongis-frsky bsongis-frsky added this to the 1.5.16 milestone Oct 3, 2024
@bsongis-frsky
Copy link
Collaborator

image

@walrath596
Copy link
Author

walrath596 commented Oct 4, 2024 via email

@noamkrief
Copy link

@walrath596
You misunderstood.
I made a workaround widget for you.
And frsky engineer just today made sqrt actually available as per original request.
Congratulations!!!

You'll just have to wait for the next release of ethos which will include it.
Till then, you can use mine.
Message me on FB if you need help with my widget.

@walrath596
Copy link
Author

walrath596 commented Oct 4, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants