snstac / adsbxcot

Display Aircraft in TAK
https://adsbxcot.rtfd.io
Apache License 2.0
51 stars 14 forks source link

Symbol heading is off for ADS-B tracks #14

Open ampledata opened 1 year ago

ampledata commented 1 year ago

From a user:

It looks like all headings are off by some fixed offset between the Magnetic heading and the on-icon caret

Screen Shot 2023-07-20 at 4 30 52 PM Screen Shot 2023-07-20 at 4 31 03 PM Screen Shot 2023-07-20 at 4 31 14 PM

Per https://www.dev.adsbexchange.com/version-2-api-wip/:

track: true track over ground in degrees (0-359)

Per CoT Spec:

The track element specifies direction and speed of travel. It has two required attributes: course and speed. It also has optional attributes for specifying the vertical component of the motion vector (slope) and errors associated with course, speed, and slope. Course denotes the direction of motion and is specified as the number of degrees measured clockwise from true North. Speed is specified in meters per second as speed over ground. There is no constraint on the precision used for these values.

ampledata commented 1 year ago

If you're also seeing this on AirTAK, it's running adsbcot, and the bug was reported with adsbxcot. It could be we're not converting from ADS-B values to CoT values correctly across the board.

Here's how adsbcot is converting ADS-B trk/track to CoT track: track.set("course", str(craft.get("trk", craft.get("track", "9999999.0"))))

Here's how adsbxcot is converting ADS-B track to CoT: track.set("course", str(craft.get("track", "9999999.0")))

From the dump1090-fa documentation: track: true track over ground in degrees (0-359)

Both say they reference 'true'

Heading is referring to the direction the aircraft is pointed at, whereas track is referring to the actual direction of the aircraft travelling across the ground.

True (Desired) Course +/- Wind Correction Angle = True Heading True Heading +/- Magnetic Variation = Magnetic Heading Magnetic Heading +/- Deviation = Compass Heading

ampledata commented 1 year ago

Here's how dump1090-fa spits out heading

    if (mm->heading_valid && mm->heading_source == HEADING_TRUE && accept_data(&a->heading_valid, mm->source, now)) {
        a->heading = mm->heading;
    }

    if (mm->heading_valid && mm->heading_source == HEADING_MAGNETIC && accept_data(&a->heading_magnetic_valid, mm->source, now)) {
        a->heading_magnetic = mm->heading;
    }
ampledata commented 1 year ago

From the CoT Spec:

            <xs:attribute name="course" use="required">
                <xs:annotation>
                    <xs:documentation>Direction of motion with respect to true north. Measured in degrees.</xs:documentation>
                </xs:annotation>
                <xs:simpleType>
                    <xs:restriction base="xs:decimal">
                        <xs:minInclusive value="0"/>
                        <xs:maxExclusive value="360"/>
                    </xs:restriction>
                </xs:simpleType>
            </xs:attribute>