Opened 12 years ago

Last modified 8 years ago

#3926 enhancement new

— at twisted.protocols.positioning -- a better positioning frameworkjkInitial Version

Reported by: lvh Owned by: Glyph
Priority: normal Milestone:
Component: core Keywords: protocols gps positioning
Cc: ashfall Branch:
Author: lvh


As some of you have undoubtedly noticed, Twisted's current GPS support (twisted.protocols.gps) has issues:

  1. The public API sucks:
    1. Fourteen arguments? All of them positional? Really?
    2. fooReceived methods are organized by what happens to be easy for NMEA sentences, not what makes sense
    3. It's hard to extend, raw objects are passed instead of pretty wrappers that abstract technology details away
    4. It's very protocol centric: the API changes between NMEA and Zodiac, a good API would look the same for any positioning technology
  2. There are no unit tests.
  3. It assumes we're using satellite navigation (well, not really, but only because there's no interface that says what it does)

This ticket is about a proposed alternative, twisted.protocols.positioning, which hopefully will:

  1. deprecate the existing code
  2. support more than satellite-based navigation (such as cell triangulation) or maybe just more than GPS (Galileo comes to mind)

After reviewing preliminary code and discussing the issue, we came to the following conclusions:

We need to have an interface (tentative name: IPositioningDataReceiver) that implements a number of methods, such as:

  1. positionRecieved(self, position)
  2. altitudeReceived(self, altitude)
  3. headingReceived(self, heading)
  4. ...

The parameters of these methods should not be simple objects (like floats or strs or bools), but Position, Heading... objects so that more API can be added later as required.

The classes that implement this should not continuously update their own state. Doing that is the job of the application that uses the framework.

Originally we thought it would be cool if accuracy data came together with positioning data, however this idea was dropped because it was unrealistic with real world positioning devices.

We should try to keep this API as general as possible (making as few assumptions about the underlying protocol as possible).

First thing to do should probably be finalizing the IPositioningDataReceiver interface. Getting it right is extremely important and has big implementation consequences: NMEA might present data in an illogical or useless order, but this shouldn't change our interface significantly.

This raises problems with the fooReceived methods, since data that is made available in chunks (headingRecieved doing both magnetic and true headings for example) might not have that data made available in the underlying implementation (some NMEA sentences only provide true heading, some proprietary ones only provide magnetic heading, and some sentences provide both -- it doesn't make sense to ignore the data from the first two types of sentence simply because they didn't have both kinds of heading).

The easy way out is to make the objects that the interface deals with as abstract as possible. With enough eyes, every problem is tiny, so your comments are much appreciated as usual.

A fork has been created on launchpad:

Discussions should preferably be either here or on IRC (my nick is 'lvh' on freenode, you can find me in #python and #twisted) :-)

Change History (0)

Note: See TracTickets for help on using tickets.