FrSkyRC / ETHOS-Feedback-Community

Feedback & suggestions are welcomed here for ETHOS by FrSky
190 stars 85 forks source link

Square Root math for Calculated Sensors #4491

Closed walrath596 closed 1 month ago

walrath596 commented 1 month ago

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 commented 1 month ago

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 commented 1 month ago

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 commented 1 month ago

... 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 commented 1 month ago

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

walrath596 commented 1 month ago

Not sure I’m reading this correctly?  Is your formula  .75 + G multiplied by .3 - .006g So 1G would be  .75 + 1 x .3 - .006 = .514 That doesn’t work. What am I doing wrong? 

Sent from Yahoo Mail for iPhone

On Monday, September 16, 2024, 12:14 PM, noamkrief @.***> wrote:

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

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

PeterGraz commented 1 month ago

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 commented 1 month ago

Ahhhh, thank you for that!!!  I should have paid attention better in math. I figured I had the parentheses wrong. lol 

Sent from Yahoo Mail for iPhone

On Monday, September 16, 2024, 1:39 PM, PeterGraz @.***> wrote:

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

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

walrath596 commented 1 month ago

Hello, How do you use the parentheses in the X20S with ethos 1.5.15?Also, the second formula seems to be better, but does it not work past 5G? Thanks! Sent from my iPhoneOn Sep 16, 2024, at 8:32 AM, PeterGraz @.***> wrote: ... 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

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.***>

PeterGraz commented 1 month ago

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 commented 1 month ago

I was afraid of that answer. lol. I couldn’t see how to do it either. Thanks. Keep me posted please. 😊

Sent from Yahoo Mail for iPhone

On Monday, September 30, 2024, 6:42 AM, PeterGraz @.***> wrote:

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.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

PeterGraz commented 1 month ago

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 commented 1 month ago

1.5.16 is out? 

Sent from Yahoo Mail for iPhone

On Wednesday, October 2, 2024, 3:40 PM, PeterGraz @.***> wrote:

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.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

PeterGraz commented 1 month ago

Unfortunately, we still have to wait a bit.

walrath596 commented 1 month ago

👍

Sent from Yahoo Mail for iPhone

On Wednesday, October 2, 2024, 3:47 PM, PeterGraz @.***> wrote:

Unfortunately, we still have to wait a bit.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

noamkrief commented 1 month ago

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 commented 1 month ago

Wow, sure, if it’s not too much trouble. But it’s not a big deal really. I don’t mind waiting 

Sent from Yahoo Mail for iPhone

On Wednesday, October 2, 2024, 4:35 PM, noamkrief @.***> wrote:

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.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

noamkrief commented 1 month ago

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 commented 1 month ago

image

walrath596 commented 1 month ago

Hello,  I’m trying it now. I don’t get the same telemetry line as in your image.  It shows up under telemetry as sqrt not custom.  What am I missing?  Thanks! 

Sent from Yahoo Mail for iPhone

On Friday, October 4, 2024, 1:27 PM, Bertrand Songis @ FrSky @.***> wrote:

Closed #4491 as completed.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

noamkrief commented 1 month ago

@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 commented 1 month ago

Ok excellent!! Thank you so much. 😊 Sent from my iPhoneOn Oct 4, 2024, at 3:16 PM, noamkrief @.***> wrote: @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.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.***>