FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Topics & Contributions
   Tools
(Moderator: REAS)
   GPS Connection
« Previous topic | Next topic »

Pages: 1 2 
   Author  Topic: GPS Connection  (Read 7532 times)
Glen Murphy

WWW Email
GPS Connection
« on: Aug 20th, 2003, 9:23am »

The following will connect to a GPS over a serial connection and begin parsing either GPGGA or GPRMC sentences, it provides methods for accessing and converting the information to more useful formats.
 
http://bodytag.org/p5gps/p5gps.pde
 
mKoser

WWW Email
Re: GPS Connection
« Reply #1 on: Aug 20th, 2003, 2:19pm »

(VERY NICE INDEED!)
 
Goddamit Glen....  
now I have to go out and buy a USB-GPS gadget to try your code!
 
...what kind of experiments have you done with this?
 

mikkel crone koser | www.beyondthree.com | http://processing.beyondthree.com
Ale_k

WWW
Re: GPS Connection
« Reply #2 on: Aug 20th, 2003, 2:34pm »

Hi,
Very interesting!
Could you post any examples?
 
Alessandro
 
Glen Murphy

WWW Email
Re: GPS Connection
« Reply #3 on: Aug 20th, 2003, 3:50pm »

Currently the code above is the only example - I've written some simple stuff in Python that I may convert.
 
I will be changing and cleaning the code if there's interest, as it was written at lunchtime, and there may be crumbs in the sauce.
 
benelek

35160983516098 WWW Email
Re: GPS Connection
« Reply #4 on: Aug 21st, 2003, 1:44am »

*yippee!*
 
i'm a member of the UNSW Solar Racing Team, and i was trying to write something like this a while ago. unfortunately there wasn't much support for serial connection at the time, and i kinda abandoned it. we've been using GPS data in saved text files, processed later on for useable race information.
 
as a bit of a sidenote Glen, have you done any work on land-mass compensation (ie, determining gravitational direction and intensity on irregular continent masses such as Australia)?
 
Glen Murphy

WWW Email
Re: GPS Connection
« Reply #5 on: Aug 21st, 2003, 2:25am »

That's a negatory reading drive A:, big buddy. My interest in GPS tech is in relation to augmented reality systems.
 
catalog


Re: GPS Connection
« Reply #6 on: Dec 18th, 2003, 1:13am »

Hello,
 
Thanks for the program, I'm actually re-working GPS data in Director, assembling it with pictures, etc… could be the occasion to learn a bit of Proce55ing.
 
When trying to lauch the program (OSX 10.3.1, Garmin GPS device, USB Keyspan adapter), proce55ing saying:
No method named "split" was found in type "java.lang.String"
Do you kwow why and how to fix this problem?
 
 
amoeba

WWW
Re: GPS Connection
« Reply #7 on: Dec 18th, 2003, 4:30pm »

the reason for the error is that the String.split() method is only available in Java 1.4.
 
for a replacement that assumes that space is always the divider between words in the string, use the following:
 
Code:
String[] split(String s) {
  int cnt=0,index;
  String parsed[],tmp;
 
// Strip trailing spaces...    
  while(s.endsWith(" ")) s=s.substring(0,s.length()-1);
 
// Find number of words in string
  for(int i=0; i<s.length(); i++)  
    if(s.charAt(i)==' ') cnt++;
  parsed=new String[cnt+1];
 
  tmp=s;
  for(int i=0; i<cnt+1; i++) {
    index=tmp.indexOf(" ");
    if(index!=-1) {
      parsed[i]=tmp.substring(0,index);
      tmp=tmp.substring(index+1);
    }
    else parsed[i]=tmp;
  }
 
  return parsed;
}

 
if Glen's code relies on the regular expression functionality of split(), or it uses a non-space divider you might need to modify the above.
« Last Edit: Dec 18th, 2003, 4:32pm by amoeba »  

marius watz // amoeba
http://processing.unlekker.net/
catalog


Re: GPS Connection
« Reply #8 on: Feb 21st, 2004, 1:44am »

Thanks for help, but:
should your code be added to Glen's or should it totally replace the line:
String[] dataBlock = nmea.split(",");
??
Sorry but I'm not so good with programming.
 
amoeba

WWW
Re: GPS Connection
« Reply #9 on: Feb 21st, 2004, 4:34pm »

Yes, replace nmea.split(",") with split(nmea);
 
Hmm, the "," parameter Glen is using would indicate that the data uses commas and not spaces to separate data. Here is a new version of the code that allows you to specify the separator just like the Java split() does.  
 
Now your new command will be split(nmea,"'").
 
Code:
String[] split(String s,char separator) {  
  int cnt=0,index;  
  String parsed[],tmp;  
 
// Strip trailing separators...      
  while(s.endsWith(separator))  
    s=s.substring(0,s.length()-1);  
 
// Find number of words in string  
  for(int i=0; i<s.length(); i++)  
    if(s.charAt(i)==separator) cnt++;  
  parsed=new String[cnt+1];  
 
  tmp=s;  
  for(int i=0; i<cnt+1; i++) {  
    index=tmp.indexOf(separator);  
    if(index!=-1) {  
      parsed[i]=tmp.substring(0,index);  
      tmp=tmp.substring(index+1);  
    }  
    else parsed[i]=tmp;  
  }  
 
  return parsed;  
}

 
Good luck!
« Last Edit: Feb 21st, 2004, 4:35pm by amoeba »  

marius watz // amoeba
http://processing.unlekker.net/
mohn

WWW Email
Re: GPS Connection
« Reply #10 on: Feb 21st, 2004, 5:09pm »

on Dec 18th, 2003, 4:30pm, amoeba wrote:
the reason for the error is that the String.split() method is only available in Java 1.4.

 
you could also switch your p5 to 1.4 - it uses 1.3.1 by default (due to random problems with 1.4 pre 10.3):
------
to do so, right-click or control-click the processing application and select "Show Package Contents". go to Contents -> Resources -> and then open MRJApp.properties in a text editor. make sure this line is commented out:
com.apple.mrj.application.JVMVersion=1.3.1
 
and that this line is not:
com.apple.mrj.application.JVMVersion=1.3+
 
as amoeba points out the spit() method should work then... or you could also use the code he provides, just wanted to point out how you could switch java VM versions...
 
Glen - really nice work!
 
catalog


Re: GPS Connection
« Reply #11 on: Feb 26th, 2004, 7:17pm »

Thanks guys, I made the switch in the MRJApp.properties (and learned someting by the way!)
I managed to parse gps nmea data with lingo in Director, but I have some problems with the java code that I absolutely don't know.
_
Now I retried to launch glen's code, but got the following error message:
You need to modify your classpath, sourcepath, bootclasspath, and/or extdirs setup. Package "netscape/javascript" could not be found in:
_
I read some stuff about the same message displayed with older versions of p5 and QuickTime. No I'm trying the 0068.
_
Did you heard about this?
 
fry

WWW
Re: GPS Connection
« Reply #12 on: Feb 26th, 2004, 9:28pm »

simpler is also to just use splitStrings(), which is a 1.1-savvy p5 function, and that'll save you the trouble of moving to 1.4, since it's likely to be pretty flakey on the mac.
 
jennie Stenhouse
Guest
Email
Re: GPS Connection
« Reply #13 on: Mar 26th, 2004, 5:59pm »

Hey all  
 
How successfull was the mac setup catalog? I am going to  be using the same set up so would be intreasted. Also how quickly does it sample from the gps and one last question Does any one know about adjusting long/lat to northing eastign values?  
 
Cheers
 
 
Jennie
 
wilson


Re: GPS Connection
« Reply #14 on: Apr 23rd, 2004, 1:53am »

Hi all.
 
thanks to Glen for his code... been helping me do a bunch of stuff...yes.
 
noticed that the program wasn't grabbing the digital compass --
 
compass data can be grabbed via the nmea type: $HCHDG which only is ouput on certain garmin devices.
 
so you can add this code to the wonderful processNMEA function:
 
else if (nmeaType.equals("$HCHDG")) {
   compass = dataBlock[1];
}
 
and add the function
 
float compass() {
 if(!available) return 0;
 return Float.valueOf(compass).floatValue();    
}
 
again, I have to say that this bit of code has helped me start to build a lot of the projects floating around in my head -- so thanks.
 
_will
 
Pages: 1 2 

« Previous topic | Next topic »