Polar Plot (Polar Graph)

Polar Plot (Polar Graph)

How to transform polar coordinates to rectangular coordinates and display on a Canvas polar Plot display (example 1) . How the plot might be used in an app with data collected from NMEA sentences (from satellites) where you plot the satellite PRN, azimuth and elevation angle to show where individual GPS satellites are is example 2.

==========
Example 1

Given the polar coordinate (r,θ), convert to x=rcosθ and y=rsinθ
polarToRectangular'
PolarPlotGraph1.aia (9.2 KB)

===========
Example 2

Shows how to post GPS satellite positions for all the PRN satellites that are heard with your Android gps hardware at the time. It shows graphically where the satellites are positiioned overhead. Assumes you are at the center of the plot and looking North (0 degrees).

The example NMEA satellite test Data Set for example 2 as a csv table:

asimuth,elevation,PRN,signaldb,hasAlmanac,hasEphemeris,usedinFix\n
201.0,18.0,3,19.0,true,true,true\n
146.0,82.0,4,38.0,true,true,true\n
295.0,28.0,7,23.0,true,true,true\n
150.0,38.0,8,27.0,true,true,true\n
312.0,58.0,9,29.0,true,true,true

The example uses TableViewer [FREE] TableViewer - fully style customized to show table data by Kevinkun to show the plotted data. The extension is not needed to demonstrate the polar plot.

PolarPlotDataTest.aia (33.5 KB)

4 Likes

Example 3. Where are the GPS Satellites Now?

The SatellitesOverhead app displays the current viewable positions of all the satellites received on an Android GPS receiver. The app makes a Polar Plot of the current satellite positions from the satellite broadcasts. It uses the Android gps receiver hardware in your Android 11+.

SatellitesOverhead.aia (56.0 KB)

GPS satellites broadcast information about their operation. NMEA is the data protocol (the satellite sends the data as ASCII sentences). These 'sentences' are read and used for a variety of purposes. One of the sentences ($GPGSV and its variants) contains data to know where the individual satellites are at any point in time.

Juan Antonio's NMEA extension parses the broadcasts from many satellites and the data is plotted using PolarPlot (described in Example 1). A PRN number (satellite ID), azimuth (between 0 and 359 degrees) and elevation (between 0 and 90 degrees) are read from $GPGSV broadcasts and extracted from the NMEA sentence.

Depending on your Android version and your gps receiver hardware it is possible to receive the locations of multiple satellite Constelations. As built, the example app listens for $GPGSV and $GLGSV sentences and parses the strings. $GBGSV and $GAGSV satellites are coded but disabled. All gps receivers can receive $GPGSV; some receivers can receive the other constellations.

================
NMEA

Two good NMEA primers explaining the contents and format of NMEA sentences (among many) are http://aprs.gids.nl/nmea/ and NMEA-0183 message: GSV These links explain what information the satellites broadcast.

================

How to use the example SatellitesOverhead app

  • load the app
  • press the Start NMEA listening button ( the app samples and logs the NMEA GSV data stream for about seven seconds)
  • wait for the Polar Plot display and table to appear.
  • that's all folks; the app doesn't do anything else other than plot satellite locations ( unless you decide to use the NMEA extension blocks and a Map component to plot your location on a map in addition to displaying the viewable satellites locations in the sky).

Be aware, this example may only work on Android 11+ .

=======================================

About

Example 3 uses two free extensions. The extensions are also part of the Example 3 aia:

Juan Antonio's Create Build Crear App Inventor Extensiones Extensions. Latitud, longitud, Nmea, GPS. extracts data from the NMEA $GPGSV (etc.) sentences that contains the satelite location information. It provides the PRN numbers and azimuth and elevation for the satellites in view of and heard by your gps receiver.

Kevinkun's TableViewer [FREE] TableViewer - fully style customized to show table data provides the PRN, azimuth and evaluation values in a table.

The documentation for both extensions explain how the tools work.

I originally developed a similar app using Niclas Gins AdvancedLocationSensor. It worked very well until Google and MIT made changes in policy and code such that Niclas' excellent extension is unable to render the NMEA sentences on higher number Android versions.

================

Testing

Tested the example using an Android 13 Samsung A13 cell phone and an Android 8.1 tablet. The example does not work with the tablet. I suspect the KIO4_NmeaMessage extension is incompatible with Android 8.1 and lower. It is also possible that TableView extension might also be an issue.

SatellitesOverhead provides a PolarPlot similar to GnssLogger

https://play.google.com/store/apps/details?id=com.google.android.apps.location.gps.gnsslogger&hl=en_US&gl=US .

GnssLogger also provides numerous other features which a developer might code for SatellitesOverhead using the NMEA extension.

================

What to do next

  • build another Project?
  • add features you want to the example (a map of your location, information from other NMEA sentances other than the GSV sentences etc.
  • solve the bug issues and provide a better interface

================================

Known bugs

The gps hardware receives all the broadcasts from all the satellites within view as a data stream. The NMEA module doesn't filter sentences without Block assistance. You must provide Blocks to avoid getting duplicate information. I am able to filter and
eliminate blocks with the same PRN number but have as yet to write code to disallow repeats of a PRN that show a changed az or el value. If one samples too long the display results in overplots whenever a satellite decides to send revised az or el data etc.

The NMEA extension is probably incompatible with Android versions probably lower than 11.

=================
Thanks

Thanks for extensions by Kevinkun @Kevinkun and Juan Antonio @Juan_Antonio .

==================

I hope this information proves useful to others building their own apps involving gps and NMEA protocol.

Regards,
SteveJG

1 Like