[GIS] How to stream attitude (roll,pitch,yaw) into Google Earth

google earthgpsnmea

I am streaming position data (lat, lon) of an airplane into Google Earth via NMEA 0183 ($GPRMC, $GPGGA sentences) and it works OK (I generate and stream these from my own software). Now I would also like to stream attitude (roll, pitch, yaw) but I can't find any NMEA sentence for this, except proprietary vendor sentences which Google Earth seem to ignore.

In Google Earth, I selected Tools -> GPS -> Real Time -> NMEA, but I haven't tried "Garmin PVT" yet as I can't find any reference to the protocol in connection with roll, pitch and yaw (found this document though).

Is there any way? I know .kml files can include this information, but I can't stream a .kml file into GE (only one-time import).


This is what I see now. Notice no pitch, roll or yaw data:

enter image description here

Roll, pitch and yaw:

enter image description here

Best Answer

I have given up on my original idea to stream NMEA into Google Earth.. and found a better solution!

I was able to solve this by programmatically generating KML file for each position and attitude change and then opening up an instance of Google Earth with the generated KML file as parameter. This is happening in 250ms loop which makes the transitions smooth. Also, Google Earth detects that another instance is already running and therefore it only loads the KML file.

Here is a capture:

enter image description here

I was able to accomplish generating of KML using C# and SharpKml software library. Here is a code example:

private void GenerateKML()
{
    SharpKml.Dom.Location loc = new SharpKml.Dom.Location();
    loc.Latitude = currentLat;
    loc.Longitude = currentLon;
    loc.Altitude = currentAlt;

    SharpKml.Dom.Model model = new SharpKml.Dom.Model();
    model.Location = loc;
    model.AltitudeMode = SharpKml.Dom.AltitudeMode.Absolute;

    SharpKml.Dom.Orientation ori = new SharpKml.Dom.Orientation();
    ori.Roll = currentRoll;
    ori.Tilt = currentPitch;
    ori.Heading = (currentTrack + 180) % 360;
    model.Orientation = ori;

    SharpKml.Dom.Link link = new SharpKml.Dom.Link();
    link.Href = new Uri("model.dae", UriKind.Relative);
    model.Link = link;

    SharpKml.Dom.Placemark pmplane = new SharpKml.Dom.Placemark();
    pmplane.Geometry = model;

    File.Delete(AppDomain.CurrentDomain.BaseDirectory + kmlFileName);

    SharpKml.Engine.KmlFile kml = SharpKml.Engine.KmlFile.Create(pmplane, false);
    using (var stream = System.IO.File.OpenWrite(kmlFileName))
        kml.Save(stream);
}

If you also want custom viewpoint of the model in Google Earth, instantiate LookAt object and assign it to model.Viewpoint.