![]() |
|
Averaging of angles done incorrectly - Printable Version +- OpenMarine (https://forum.openmarine.net) +-- Forum: Pypilot (https://forum.openmarine.net/forumdisplay.php?fid=17) +--- Forum: General discussion (https://forum.openmarine.net/forumdisplay.php?fid=18) +--- Thread: Averaging of angles done incorrectly (/showthread.php?tid=6343) |
Averaging of angles done incorrectly - mgrouch - 2025-07-07 I looked at heading_filter function as example. It applies low pass on angle value. Angle value is a circular parameter. I think it’s invalid way to average angles. Correct way of averaging angles is low pass on sin and cos, the normalization and reverting back to angle with atan2. It seems everywhere in the code averaging of angles is not right. Average between 170 and -170 degrees is 180. It’s not 0 or whatever weighted currently coded in low pass filters. Average between 1 and 359 is 0. It’s not 180 This will be possibly the reason people can’t get heading right even with working IMUs. I think it a serious bug. I’ve reported it here: https://github.com/pypilot/pypilot/issues/258 Thanks, Fair Winds! RE: Averaging of angles done incorrectly - seandepagnier - 2025-07-08 it does resolve the headings so that the first one is +- 180 of the second one before. I dont think this is a bug. I tried all your cases it works as expected. However using vectors requires more trig to be computed. RE: Averaging of angles done incorrectly - mgrouch - 2025-07-08 Actually no issue there. The original code correctly used short path. My bad and apologies for waisted time. RE: Averaging of angles done incorrectly - seandepagnier - 2025-07-09 Its ok I have done this myself. I'm glad you are looking into details trying to find issues. RE: Averaging of angles done incorrectly - ironman - 2025-07-09 Gee, brilliant. Spent in some other project hours of coding trying to do it without trigonometric functions, then succumbed to those functions and subsequently running into quadrant ambiguity until I learned about atan2. Now it turns out it is as simple as this. Simplicity is engineer's perfection. Any time learning is certainly not wasted! RE: Averaging of angles done incorrectly - PaddyB - 2025-07-10 (2025-07-09, 09:30 PM)ironman Wrote: Any time learning is certainly not wasted! Multi tasking too these days. With google set on the phone to use Gemini, making coffee this morning - "OK google, write a radio documentary about atan2" Couple of minutes of a nice lady talking. Ah, the unsung hero of the digital world, works in all 4 quadrants of the cartesian plane.
RE: Averaging of angles done incorrectly - ironman - 2025-07-10 Didn't know Gemini would work this way. This accelerates learning even more! RE: Averaging of angles done incorrectly - PaddyB - 2025-07-10 (2025-07-10, 07:48 PM)ironman Wrote: Didn't know Gemini would work this way. This accelerates learning even more! I use it quite a lot, something to listen to washing the dishes "You are a geoligist and radio presented and sailor. Desribe the rock formations and geological history on a sailing trip down the french, spanish and portuguese coasts to Gibraltar." Works on the laptop as well, at the bottom of the response click the 3 dots "More" there's a listen button. " Good evening, fellow adventurers of the sea and land! This is your resident geologist, radio presenter, and sometime sailor, here to take you on a truly epic voyage down the Atlantic coasts of France, Spain, and Portugal, culminating at the grand Rock of Gibraltar. Prepare to be amazed by the ancient stories etched in the very rocks beneath our keel....."
|