Giter Club home page Giter Club logo

gps.js's People

Contributors

0xflotus avatar anthony-bernardo avatar brandonros avatar bryanluman avatar ianalexander avatar infusion avatar psiphi75 avatar rosostolato avatar theprojectsomething avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gps.js's Issues

Updating state based on multiple sentences

Hey, Thanks for this awesome tool!

I have a use case where I'm consuming lots of NMEA sentences in short bursts. (10 sentences every .25 seconds).
If I've read the code correctly, every call to GPS.update() overwrites the current state if the state property exists in the message (e.g. VTG will overwrite state.track).

In my case I resorted to GPS.Parse()-ing all data and then averaging the parsed results.

Does support for either a multiline message or a collection of messages sound like something that would be in scope of this project? I don't know how common of a use case this is so maybe it might be overkill to add it straight to this library.

Error: Invalid GGA length

I've written a simple node.js server to capture the NMEA sentence transmitted from my GPS receiver. This works for a period of time, and then dies because gps.js throws and error of 'Invalid GGA length'. So far, I'm not seeing anything wrong with the length of the alleged offending sentence.

Here is my code:

const gts = new net.Server( function (socket) {
  socket.on('data', (nmea) => {
    myLatLng = nmea.toString();
    console.log(myLatLng);
      var gps = new GPS;
      gps.on('data', (parsed) => {
          console.log(parsed);
          console.log('At %s, your location was: Lat: %f, Lng: %f.', parsed.time, parsed.lat, parsed.lon);
          myLatLng = parsed;
      }); //end gps.on 
      gps.update(nmea.toString()); 
  }); // end socket.on
}); //end gts

gts.listen(PORT, function() {
  console.log('GPS Tracking Server enabled');
});

And here is what shows in the console (I've changed the lat/lng values for privacy, but not the checksum):

{ time: 2018-02-26T02:07:54.000Z,
lat: 40.00449745,
lon: -74.12672576666667,
alt: 502.6,
quality: 'fix',
satelites: 10,
hdop: 0.9,
geoidal: -20,
age: null,
stationID: null,
raw: '$GPGGA,020754.0,4000.269847,N,07407.603546,W,1,10,0.9,502.6,M,-20.0,M,,*6C\r\n',
valid: true,
type: 'GGA' }
At Sun Feb 25 2018 20:07:54 GMT-0600 (CST), your location was: Lat: 40.00449745, Lng: -74.12672576666667.
$GPGGA,020854.0,4000.269917,N,07407.603578,W,1,10,0.8,502.7,M,-20.0,M,,*6A

{ time: 2018-02-26T02:08:54.000Z,
lat: 40.004498616666666,
lon: -74.1267263,
alt: 502.7,
quality: 'fix',
satelites: 10,
hdop: 0.8,
geoidal: -20,
age: null,
stationID: null,
raw: '$GPGGA,020854.0,4000.269917,N,07407.603578,W,1,10,0.8,502.7,M,-20.0,M,,*6A\r\n',
valid: true,
type: 'GGA' }
At Sun Feb 25 2018 20:08:54 GMT-0600 (CST), your location was: Lat: 40.004498616666666, Lng: -74.1267263.
$GPGGA,020954.0,4000.269955,N,07407.603597,W,1,10,0.8,502.9,M,-20.0,M,,*62
$GPGGA,020955.0,4000.269955,N,07407.603597,W,1,10,0.8,502.9,M,-20.0,M,,*63

/home/tim/projects/rv-gps/node_modules/gps/gps.js:302
throw new Error('Invalid GGA length: ' + str);
^

Error: Invalid GGA length: $GPGGA,020954.0,4000.269955,N,07407.603597,W,1,10,0.8,502.9,M,-20.0,M,,*62

I have not dug into the code nor added any error handling, but if you know of an obvious fix, please let me know.

Serial port closes after some time and gps.js randomly throws errors

I am using neo 6m gps module with raspberry pi 3 , i have attached it on serial port ttyAMA0 , but it reads data for only small time and then port closes automatically , and sometime gps.js module to throw an error.
Here is my edited version of maps example :

var app = require('express')();
var http = require('http').Server(app);
var io = require('socket.io')(http);


var file = '/dev/ttyAMA0';

const SerialPort = require('serialport');
const parsers = SerialPort.parsers;

const parser = new parsers.Readline({
  delimiter: '\r\n'
});

const port = new SerialPort(file, {
  baudRate: 9600
});

port.pipe(parser);


var GPS = require('../../gps.js');
var gps = new GPS;

gps.on('GGA', function(data) {
  io.emit('position', data);
  console.log("Latitiude :", data.lat);
  console.log("Longitude :", data.lon);
});

app.get('/', function(req, res) {
  res.sendFile(__dirname + '/maps.html');
});

http.listen(3000, function() {

  console.log('listening on *:3000');
});

port.on('data', function(data) {	
  gps.updatePartial(data);
});

process.on('unhandledRejection', function (reason, p) {
  //I just caught an unhandled promise rejection, since we already have fallback handler for unhandled errors (see below), let throw and let him handle that
  console.log("=============");
  console.log(reason);
  console.log("=============");
  return;
});

process.on('rejectionHandled', () => {});

process.on('uncaughtException', function (error) {
	console.log(error);
});

port.on('close', function(data) {
	
  console.log("Port closed");
  console.log(port.binding);
	
	});

Output

Please help me with the issue i will be very grateful.

solution for make the weft more reliable ?

Hi, tx for ur job i am using your module for my gps iot project but i didn't find any data to be sure of my lat/lon , no TTFF or other information about the fix , do u have a solution for good and reliable tracking lat/lon

Example issue

Hello!

I'm trying to run the example dashboard script but I keep getting the following error, any suggestions?

Tylers-iMac:dashboard tyleryouschak$ node server.js 
/Users/tyleryouschak/Desktop/GPS.js/examples/dashboard/server.js:14
  parser: SerialPort.parsers.readline('\r\n')
                             ^

TypeError: SerialPort.parsers.readline is not a function
    at Object.<anonymous> (/Users/tyleryouschak/Desktop/GPS.js/examples/dashboard/server.js:14:30)
    at Module._compile (module.js:569:30)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)
    at Function.Module.runMain (module.js:605:10)
    at startup (bootstrap_node.js:158:16)
    at bootstrap_node.js:575:3

There looks to be an issue with the readline parser not being available, but I'm not familar with the SerialPort library.

Error: Invalid RMC length

Hello!
Using VDB-800SG (ublox 6 with G-sensor) for fetching nmea.
But, getting Invalid RMC length error randomnly while parsing it with gps.js.

Error: Invalid RMC length: $GNRMC,132452.00,A,4109.76817,N,00838.23846,W,0.120,,170320,,,A*$GNVTG,,T,,M,0.120,N,0.222,K,A*3C

Code which is being used:
.......

gps.on('data', function(parsed) {
    console.log('Lat: %f, Lng: %f.', gps.state.lat, gps.state.lon);
});

gpsPort.on('data', function(nmea) {                
    try {
        gps.updatePartial(nmea);
    } catch (error) {
        console.log('ERROR IN UPDATE PARTIAL:::'); 
    }
});

Please help.
Thanks.

GSV merge is inconsistent, "blinking" satsVisible / it disappears and reappears.

Hello,

I get random OK/NOK on state.satsVisible object, it disappears and reappears a lot of time, I use 10Hz refresh rate, my NMEA look OK, some GPS are OK, some GPS I get the "blinking" satsVisible.

I think this is this TODO

    // TODO: better merge algorithm:
    // 1. update every sat and mark as updated.
    // 2. If last msg, delete all unmarked sats & reset mark
    if (data['type'] === 'GSV') {
 
      var sats = data['satellites'];
      for (var i = 0; i < sats.length; i++) {
        collectSats.push(sats[i]);
      }
 
      // Reset stats
      if (data['msgNumber'] === data['msgsTotal']) {
        state['satsVisible'] = collectSats; 
        collectSats = [];
      }
    }

can you add altitude to kalman filter?

Hello!

I have rocket model with gps and use your module with kalman filter but it does not use altitude\height. Can you add altitude to filter too?

Thanks

regarding previous Issue on kalman filter

Hi,
The previous "issue" write about "add altitude to Kalman filter".
Does the module already "adjust" lat & lon with Kalman filter ?
I try with a small GPS device (HiLetgo GY-NEO6MV2 NEO-6M GPS Flight Controller Module 3V-5V with Ceramic Antenna for Arduino EEPROM APM 2.5, https://www.amazon.fr/gp/product/B07B4658XJ/ref=ppx_yo_dt_b_asin_title_o06_s00), but the position is not stable and move when vehicle is stopped ? May be a problem of quality of my device ? or an interpolation in your code ?
Best regards.

Loading with wp_enqueue_script into WordPress

Hey, I was hoping to experiment with your code as part of a WordPress plugin. I'm pretty new to a lot of this, so it might be more of an issue of my not understanding what needs to happen.

Basicallly, when I try to load the GPS.js using wp_enqueue_script, Wordpress whines in the console that loading failed. Interestingly, gps (the handle I give it in wp_enqueue_script()) is shown as loaded, but var gps = new GPS gives and error of undefined.

Have you used this in a plugin/php environment? Any pointers on how to wrap my head around why this doesn't load properly?

Thanks.

Invalid GGA length

Hi There,

I noticed some more errors trying to process the following GGA data:

$GPGGA,033016,1227.2470,S,13050.8514,E,2,6,0.9,11.8,M,,M4A
$GPGGA,033631,1227.2473,S,13050.8504,E,2,6,0.9,7.4,M,,M
70
$GPGGA,034030,1227.2475,S,13050.8528,E,2,6,0.9,8.1,M,,M*72

Issue parsing BDGSV

Hello,

Sometimes the raw data coming from BeiDou satellites has an extra 0, between the satellite data and the checksum. This causes the module to throw when checking the GSV array length.

GPS.js/gps.js

Line 497 in 2f6eff6

if (gsv.length % 4 % 3 === 0) {

Here's some raw data examples:

$GLGSV,3,1,09,78,33,298,28,88,12,160,20,87,38,120,24,67,28,232,32,1*7B
$GLGSV,3,2,09,68,34,293,25,86,28,040,,77,59,023,,76,21,075,,1*7B
$GLGSV,3,3,09,69,08,338,,1*4E
$GPGSV,4,1,13,02,10,135,20,10,03,278,21,12,63,277,27,13,06,161,22,1*6A
$GPGSV,4,2,13,15,22,187,29,17,14,039,16,19,34,050,19,24,83,081,28,1*63
$GPGSV,4,3,13,25,26,260,28,06,15,091,,23,,,,32,13,319,,1*5F
$GPGSV,4,4,13,49,,,34,1*6C
// Breaks from here on out
$BDGSV,4,1,16,01,,,37,02,,,38,03,,,39,05,,,37,0,4*6A
$BDGSV,4,2,16,06,,,32,07,,,36,08,,,32,09,,,30,0,4*6B
$BDGSV,4,3,16,10,,,35,11,,,37,13,04,092,31,15,,,32,0,4*55
$BDGSV,4,4,16,16,,,34,17,,,33,19,,,32,20,,,34,0,4*61

For now I monkey patched the GSV parser removing the length check and haven't noticed any problems.

I am wondering if this is a common issue with that kind of satellites and should skip their data or it can be solved at a library level.

Cheers,

GPS Port Check

Is it possible to add a layer / functionality to check to see if a selected port is a gps? If it isn't then throw an error and stop the gps and serialport instance?

Just a thought and suggestion!

Adding state['heading'] for $GPHDT

Hello,

Is it possible for you to adding the heading state when we update the GPS with a "$GPHDT" ?

We just need to add the following code at L.27 in gps.js :

if (data['type'] === 'HDT') { state['heading'] = data['heading']; state['trueNorth'] = data['trueNorth']; }

Thanks a lot !

Alex.

GST not yet supported in current release

The README states that GST messages are supported. However that GST parsing code is only in master and not yet part of any release.

I know this is motly a Github issue as it shows the README file from master. Still maybe this ticket could stay here for others until the code has been released - would have saved me some debugging :)

Latest release 0.4.0 - Aug 1, 2017
Support for GST added - Oct 6, 2017

GDOP and Hv

hi!

wish you re right since you helped me on my F9P problems :)

one of the company i work with ask me the GDOP and Hv values ???

is it possible to add it to the lib ? (can t find informations on this "Hv" thought)...

thanks !

Dashboard Examples Issue

Hello , I run the dashboard Examples on windows 10 pc but i get this issue :
listening on *:3000
(node:16360) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Opening /dev/ttyS1: Unknown error code 3.

I can acces to the dashboard from my phone on this adress "http://192.168.8.103" but i get all values empty :( .

Invalid GLL length

Hi,

I get the following error:
Invalid GLL length: $GPGLL,5000.05254,N,04500.02356,E,090037.059,A*35
when using a GPS simulator https://gpsgate.com/support/gps_simulator

I don't know enough about the message standard to know if this is the simulators fault and its not generating the data in the correct format...

This is my code:

const path = 'COM2'
const SerialPort = require('serialport')
const parsers = SerialPort.parsers
const parser = new parsers.Readline({
delimiter: '\r\n'
})
const port = new SerialPort(path, {
baudRate: 4800
})

port.pipe(parser)

let GPS = require('gps')
let gps = new GPS

gps.on('data', function(data) {
console.log(data)
})

parser.on('data', function(data) {
gps.update(data)
})

"Satelites" should be spelled "satellites"

Just noticed tonight that the parser misspells the word, and it should have to of the letter 'l'.

Although minor, it could cause confusion if someone were trying to reference the field.

Thanks.

zed-f9P ardusimple compatibility

hi!

thanks for this library first it s great :)

So i have the new ardusimple board, i had to change few things to get it working with your lib (change gngga gst length... don t understand why) it works but still have few doubts on the results because of this (i receive data from bluetooth)

how can i get the speed and accuracy in the gps.state directly ?

next step is to build an ntrip-client for rtk corrections! nothing in node/react-native for this incredible !!!

thanks

Consider using your own Fraction.js as a dependency

Hi!

Using the package I've noticed that the lat/longs sometimes suffers from normal precision issues. Maybe a solution could be to use your own package? This will still keep the dependencies down to an acceptable number.

Thanks for the great package! Really saved me for a lot of work!

Best
Thomas

GPS.DISTANCE returns distance in km rather than meters as specified in the function protoype.

Relevant files:

  1. gps.js
  2. gps.d.ts (for documentation)

The static method GPS.HEADING returns the distance between two lat/long pairs in km rather than meters as specified above the function definition. This is not a big issue as it is just a documentation fix; I just thought it would be helpful since hovering over the function in text editors/IDE's often display the function documentation which specifies the return value will be in meters. In the future this may save some people time (albeit not much) by not requiring them to verify from the source.

Invalid GGA/GSV length

Hello! I'm experiencing an issue: the gps library frequently throws errors that the GSV or sometimes the GGA message has incorrect length - log:
Invalid GSV length: $GPGSV,4,,,A*7A
or
Invalid GGA length: $GPGGA,223154.00,5025.333,E,223154.00,A,A*67

I'm 100% sure the data isn't malformed or broken. I can enclose the gps.update(...) within try/catch to omit crash, but I'd like to have the code running without such problems. Maybe it's due to the NMEA standard length difference ('note' there: http://www.trimble.com/oem_receiverhelp/v4.44/en/nmea-0183messages_gga.html)?

My exact code:

nmeaData.split(/\r?\n/).forEach(function(nmeaLine) {
    try {
        gps.update(nmeaLine);
    } catch(e){
        console.log("Caught GPS lib error: " + JSON.stringify(e));
    }
}, this);

I'm running node v9.2.0, npm v5.5.1 and tried both gps v0.3 and v0.4.1

Invalid GGA Fix For new GPS

INVALID GGA FIX: 0
Eror Help Me Please if running Showing erorr

Error: INVALID GGA FIX: 0
at parseGGAFix (/home/pi/Documents/Myproject/skripsi/GPS.js/gps.js:205:11)
at Object.GGA (/home/pi/Documents/Myproject/skripsi/GPS.js/gps.js:346:20)
at Function.GPS.Parse (/home/pi/Documents/Myproject/skripsi/GPS.js/gps.js:667:38)
at GPS.update (/home/pi/Documents/Myproject/skripsi/GPS.js/gps.js:745:30)
at GPS.updatePartial (/home/pi/Documents/Myproject/skripsi/GPS.js/gps.js:774:23)
at SerialPort. (/home/pi/Documents/Myproject/skripsi/GPS.js/server.js:199:7)
at SerialPort.emit (events.js:187:15)
at addChunk (_stream_readable.js:283:12)
at readableAddChunk (_stream_readable.js:264:11)
at SerialPort.Readable.push (_stream_readable.js:219:10)
at binding.read.then.bytesRead (/home/pi/Documents/Myproject/skripsi/GPS.js/node_modules/@serialport/stream/stream.js:384:12)

@infusion

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.