How do people see average COG over minutes? App?

BilboRanger37

New member
6
1
Of course I can make a line heading back over my last minute of sailing and add 180 degrees, but there must be an
easy app or something to see my average course for the last 30 seconds, minutes, feet etc? I have androids apples, GPS etc.. All I want is something to give some slower feedback, tried max smoothing, not a long enough average to make tiller pilot and wind pilot changes.. Thanks so much y'all
 

mckenzie.keith

Aspiring Anarchist
1,427
546
Santa Cruz
You can also watch cross track error if you are going from one waypoint to another. If the cross-track error is changing slowly, you are parallel to your course (or maybe on your course). If the cross track error is changing fast, you are off course.
 

shaggybaxter

Super Anarchist
4,668
2,765
Australia
You can also watch cross track error if you are going from one waypoint to another. If the cross-track error is changing slowly, you are parallel to your course (or maybe on your course). If the cross track error is changing fast, you are off course.
Yep, CTE.
Prior to the race start, I take all the gribs and plot all the guesstimated gybe and tack points. When on the course it's then using % of polars to move/modify them. And doing it all the time.

Depending upon how sophisticated your nav software is will determine the type of info and how granular the detail you get, its then pretty much CTE. This then tells you when you need to change things.
 

noaano

Anarchist
722
363
All I want is something to give some slower feedback, tried max smoothing, not a long enough average to make tiller pilot and wind pilot changes.

I have a Hemisphere sat compass.

It has a command you can enter with laptop connected via serial:

$JTAU,COG,tau<CR><LF>

Where "tau" is a time constant (0.00 to 3600.00 seconds).

I would not be surprised if other units had similar internal setting.

I actually keep it quite "snappy" aka short, as the sat compass gives fast updating (10Hz) rock solid true HDG and that is what drives the AP (mainly), but yeah, it is there.
 

kent_island_sailor

Super Anarchist
28,572
6,313
Kent Island!
OpenCPN will average over whatever time you set:
1680129012894.png
 

kent_island_sailor

Super Anarchist
28,572
6,313
Kent Island!
In some ideal world, you'd want the raw data to remain high resolution, with the option to display filtered, smoothed data. So that the autopilot gets the fast updates that it needs, while the tactician or navigator can see the smoothed data.
So you want a display showing instant and smoothed data?
That seems like something that should exist if it doesn't.
 

kent_island_sailor

Super Anarchist
28,572
6,313
Kent Island!
I have been playing with an AI and got this python code to display instant and one-minute smoothed COG and SOG:

import socket
from datetime import datetime, timedelta

# UDP setup
UDP_IP = "0.0.0.0"
UDP_PORT = 2020
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.bind((UDP_IP, UDP_PORT))

# Constants for SOG and COG smoothing
SMOOTHING_WINDOW_SIZE = 60
SOG_WEIGHT = 0.5
COG_WEIGHT = 0.5

# Variables to store SOG and COG
sog_sum = 0
cog_sum = 0
sog_buffer = []
cog_buffer = []

# Main loop
while True:
data, addr = sock.recvfrom(1024) # Buffer size is 1024 bytes
if data.startswith(b"$GPVTG"): # Check if message is a VTG (course over ground and ground speed) sentence
vtg_fields = data.decode("utf-8").split(",") # Split the sentence into fields
if vtg_fields[7] == "N": # Check if speed is measured in knots
sog_knots = float(vtg_fields[5])
cog_degrees = float(vtg_fields[1])
# Add SOG and COG to the buffers
sog_buffer.append(sog_knots)
cog_buffer.append(cog_degrees)
sog_sum += sog_knots
cog_sum += cog_degrees
# Check if buffers are full and perform smoothing
if len(sog_buffer) == SMOOTHING_WINDOW_SIZE:
smoothed_sog = sog_sum / SMOOTHING_WINDOW_SIZE
smoothed_cog = cog_sum / SMOOTHING_WINDOW_SIZE
sog_sum -= sog_buffer.pop(0)
cog_sum -= cog_buffer.pop(0)
# Print instantaneous and smoothed SOG and COG
print(f"Instantaneous SOG: {sog_knots:.2f} knots, COG: {cog_degrees:.2f} degrees")
print(f"Smoothed SOG: {smoothed_sog:.2f} knots, COG: {smoothed_cog:.2f} degrees")


This code listens for UDP messages on port 2020, assumes that the GPS data is in NMEA format, and extracts the SOG and COG fields from the VTG sentence. It then calculates the SOG in knots, adds it and the COG to their respective buffers, and performs smoothing by calculating the mean of the last 60 values in the buffer. The smoothed SOG and COG are printed to the console along with their instantaneous values. Note that this is just a basic example and you may need to modify it to fit your specific needs.

* OpenCPN will output UDP data to a specified port, that seemed the easiest way to try this. I have not tried this yet myself, so YMMV.
 

noaano

Anarchist
722
363
This code listens for UDP messages on port 2020, assumes that the GPS data is in NMEA format, and extracts the SOG and COG fields from the VTG sentence. It then calculates the SOG in meters per second, adds it and the COG to their respective buffers, and performs smoothing by calculating the mean of the last 60 values in the buffer.

If you're using custom code, a median or median (lets say center 50%) weighted mean will give a better result, as it clips the outliers.

Also why convert SOG to m/s?

also:

sog_mps = sog_knots * 0.514444

seems strange pre-optimisation

sog_mps = sog_knots * 1852 / 60 / 60

is easier to understand (and gives more accurate result)
 
Last edited:

kent_island_sailor

Super Anarchist
28,572
6,313
Kent Island!
If you're using custom code, a median or median (lets say center 50%) weighted mean will give a better result, as it clips the outliers.

Also why convert SOG to m/s?

also:

sog_mps = sog_knots * 0.514444

seems strange pre-optimisation

sog_mps = sog_knots * 1852 / 60 / 60

is easier to understand (and gives more accurate result)
That was the first shot from openAI, you frequently have to back in several times to get what you want exactly.
I am using it for a few things, some days it would be quicker to do it yourself and some days it totally nails it first try.
 

noaano

Anarchist
722
363
That was the first shot from openAI, you frequently have to back in several times to get what you want exactly.
I am using it for a few things, some days it would be quicker to do it yourself and some days it totally nails it first try.

Yeah, its scary good, but also makes very dangerous mistakes.

Have to verify everything by hand, but still beats writing all that boilerplate yourself.
 

fboats

Member
120
63
This conversation reminds me of an engineer that brought a TI-82 on board a race boat to calculate VMG in 2005...hello, it's called a GPS.

2023, basic instrument systems already do this. Maybe you should hire a pro to explain it to you?
 

kent_island_sailor

Super Anarchist
28,572
6,313
Kent Island!
This conversation reminds me of an engineer that brought a TI-82 on board a race boat to calculate VMG in 2005...hello, it's called a GPS.

2023, basic instrument systems already do this. Maybe you should hire a pro to explain it to you?
VMG is easily found. VMG with variable damping is a bit trickier, depending on exactly what you have.
 

kent_island_sailor

Super Anarchist
28,572
6,313
Kent Island!
My pet project I have going now with it is a GPS dashboard that will show the output of 3 or 4 GPSs, flag the ones not locked, and average the good ones. It will also through out the outlier data, so if there are 4 of them and one is 200 feet away from the rest it will be ignored.
No idea if this will be useful, but I am entertaining myself with it.
 

noaano

Anarchist
722
363
My pet project I have going now with it is a GPS dashboard that will show the output of 3 or 4 GPSs, flag the ones not locked, and average the good ones. It will also through out the outlier data, so if there are 4 of them and one is 200 feet away from the rest it will be ignored.
No idea if this will be useful, but I am entertaining myself with it.

A man without a GPS does not know where he is.

A man with a GPS knows where he is.

A man with multiple GPSs is not so sure where he is.


But get one ublox multiband F9 and a good antenna. No need for anything else.

Or two if you want true heading as well. Or three if you want true heel as well.
 
Last edited:
Top