Go to Post I think this is the forest that ChiefDelphi often misses as we're picking the branches off every tree. - Libby K [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 30-05-2013, 13:19
ktrobotcreator's Avatar
ktrobotcreator ktrobotcreator is offline
Programmer
FRC #1245 (Shazbots)
Team Role: Programmer
 
Join Date: Jul 2012
Rookie Year: 2007
Location: Colorado
Posts: 38
ktrobotcreator is an unknown quantity at this point
Read a GPS through a Serial Port

Hi Chief Delphi Community!

For a separate robotics competition (The Sparkfun Autonomous Vehicle Competition, if you were wondering) we are using the FRC control system. For the competition we have to autonomously navigate a course and race other robots around a parking lot, and we aim to do so by using GPS. We have a working GPS chip on an Arduino system that can output to a serial port, and so we would like to use the one on the cRIO to get the data. We have verified the chip can output the correct data using other software, but when we try to read it from the code, we get a bunch of nonsense. The baud rate is correct, so we don't know why we are getting this data. Any help is appreciated! Thanks!

-Katy

Code:
 
package edu.wpi.first.wpilibj.templates;

import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.SerialPort;
import edu.wpi.first.wpilibj.visa.VisaException;

public class RobotTemplate extends IterativeRobot {
    
    SerialPort gps;
    
    int dataCount;
        
    public void robotInit() {
        try {
            gps = new SerialPort(9600);
            this.gps.disableTermination();
        }
        catch (Exception e) {
            System.out.println("something went wrong, " + e.getMessage());
        }
    }
    
    public void autonomousInit() {
        dataCount = 0;
        
        try {
            gps.reset();
        } catch (VisaException ex) {}
    }
    
    public void autonomousPeriodic() {
        
        try {
            System.out.println("DC " + dataCount + " " + gps.readString());
        } catch (VisaException ex) {}
        
        dataCount ++; //this is just to make sure our output is updating
    }   
}
Reply With Quote
  #2   Spotlight this post!  
Unread 30-05-2013, 14:26
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,572
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Read a GPS through a Serial Port

Is the console out switch on the cRIO off? Make sure the cRIO isn't imaged with the serial CAN plugin.

What serial levels does the arduino serial port use? Many microcontrollers use TTL levels, which violate the RS-232 spec. You'd need a level converter like the MAX232 to use it with the cRIO.

If you post the gibberish and an example of what the GPS sends, someone might be to make sense of it.
Reply With Quote
  #3   Spotlight this post!  
Unread 30-05-2013, 15:42
androb4's Avatar
androb4 androb4 is offline
..is trying to take this year off.
AKA: Andrew A.
no team
Team Role: Alumni
 
Join Date: Feb 2010
Rookie Year: 2003
Location: Houston, TX
Posts: 220
androb4 is a splendid one to beholdandrob4 is a splendid one to beholdandrob4 is a splendid one to beholdandrob4 is a splendid one to beholdandrob4 is a splendid one to beholdandrob4 is a splendid one to beholdandrob4 is a splendid one to behold
Re: Read a GPS through a Serial Port

Yea it's most likely that you need a logic level converter as stated above, because its working on a arduino which uses TTL.
__________________
FRC 441 Mentor 2012-2015
FRC 441 Alumni 2009-2012
FTC 4673 Alumni 2011-2012
FRC 1484 Alumni 2006-2008

Reply With Quote
  #4   Spotlight this post!  
Unread 30-05-2013, 16:23
ktrobotcreator's Avatar
ktrobotcreator ktrobotcreator is offline
Programmer
FRC #1245 (Shazbots)
Team Role: Programmer
 
Join Date: Jul 2012
Rookie Year: 2007
Location: Colorado
Posts: 38
ktrobotcreator is an unknown quantity at this point
Re: Read a GPS through a Serial Port

The console out switch is off. I don't have the data with me now but the next time we meet I can try posting some output. You're probably right about the TTL thing, thanks! I will look into that.
Reply With Quote
  #5   Spotlight this post!  
Unread 30-05-2013, 18:15
mman1506's Avatar
mman1506 mman1506 is online now
Focusing on Combat Robots!
AKA: Marcus Quintilian
no team (WARP7)
Team Role: Alumni
 
Join Date: Mar 2012
Rookie Year: 2012
Location: Toronto
Posts: 802
mman1506 has a reputation beyond reputemman1506 has a reputation beyond reputemman1506 has a reputation beyond reputemman1506 has a reputation beyond reputemman1506 has a reputation beyond reputemman1506 has a reputation beyond reputemman1506 has a reputation beyond reputemman1506 has a reputation beyond reputemman1506 has a reputation beyond reputemman1506 has a reputation beyond reputemman1506 has a reputation beyond repute
Re: Read a GPS through a Serial Port

BTW, most GPS modules output in serial in NEMA format anyway so using an arduino seems kind of unnecessary.
__________________
2014-2015: FRC 865 Warp7 Team Captain
2016: FRC 865 Mentor

2017: Free Agent Mentor, Inspector
Reply With Quote
  #6   Spotlight this post!  
Unread 30-05-2013, 18:57
RufflesRidge RufflesRidge is offline
Registered User
no team
 
Join Date: Jan 2012
Location: USA
Posts: 989
RufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant future
Re: Read a GPS through a Serial Port

This bug report suggests that the Serial port in Java is broken:
http://firstforge.wpi.edu/sf/go/artf...3699545405 50
Reply With Quote
  #7   Spotlight this post!  
Unread 30-05-2013, 19:58
androb4's Avatar
androb4 androb4 is offline
..is trying to take this year off.
AKA: Andrew A.
no team
Team Role: Alumni
 
Join Date: Feb 2010
Rookie Year: 2003
Location: Houston, TX
Posts: 220
androb4 is a splendid one to beholdandrob4 is a splendid one to beholdandrob4 is a splendid one to beholdandrob4 is a splendid one to beholdandrob4 is a splendid one to beholdandrob4 is a splendid one to beholdandrob4 is a splendid one to behold
Re: Read a GPS through a Serial Port

Quote:
Originally Posted by RufflesRidge View Post
This bug report suggests that the Serial port in Java is broken:
http://firstforge.wpi.edu/sf/go/artf...3699545405 50
That was in January. Has there been an update for that?
__________________
FRC 441 Mentor 2012-2015
FRC 441 Alumni 2009-2012
FTC 4673 Alumni 2011-2012
FRC 1484 Alumni 2006-2008

Reply With Quote
  #8   Spotlight this post!  
Unread 30-05-2013, 20:17
ktrobotcreator's Avatar
ktrobotcreator ktrobotcreator is offline
Programmer
FRC #1245 (Shazbots)
Team Role: Programmer
 
Join Date: Jul 2012
Rookie Year: 2007
Location: Colorado
Posts: 38
ktrobotcreator is an unknown quantity at this point
Re: Read a GPS through a Serial Port

I know there have definitely been updates since January 20, but I don't remember seeing anything about Serial Ports. If that's the case then this may all be a lost cause, even with a converter...
Reply With Quote
  #9   Spotlight this post!  
Unread 30-05-2013, 20:22
androb4's Avatar
androb4 androb4 is offline
..is trying to take this year off.
AKA: Andrew A.
no team
Team Role: Alumni
 
Join Date: Feb 2010
Rookie Year: 2003
Location: Houston, TX
Posts: 220
androb4 is a splendid one to beholdandrob4 is a splendid one to beholdandrob4 is a splendid one to beholdandrob4 is a splendid one to beholdandrob4 is a splendid one to beholdandrob4 is a splendid one to beholdandrob4 is a splendid one to behold
Re: Read a GPS through a Serial Port

Quote:
Originally Posted by ktrobotcreator View Post
I know there have definitely been updates since January 20, but I don't remember seeing anything about Serial Ports. If that's the case then this may all be a lost cause, even with a converter...
Alternatively you can read the GPS data via the arduino's serial port, then send that data over I2C to the digital sidecar.
__________________
FRC 441 Mentor 2012-2015
FRC 441 Alumni 2009-2012
FTC 4673 Alumni 2011-2012
FRC 1484 Alumni 2006-2008

Reply With Quote
  #10   Spotlight this post!  
Unread 30-05-2013, 20:26
ktrobotcreator's Avatar
ktrobotcreator ktrobotcreator is offline
Programmer
FRC #1245 (Shazbots)
Team Role: Programmer
 
Join Date: Jul 2012
Rookie Year: 2007
Location: Colorado
Posts: 38
ktrobotcreator is an unknown quantity at this point
Re: Read a GPS through a Serial Port

Quote:
Originally Posted by androb4 View Post
Alternatively you can read the GPS data via the arduino's serial port, then send that data over I2C to the digital sidecar.
Hmmm... Thanks for the suggestion, we can check that out next time we meet.
Reply With Quote
  #11   Spotlight this post!  
Unread 30-05-2013, 21:00
Mike Bortfeldt Mike Bortfeldt is offline
Registered User
FRC #1126 (& 1511)
Team Role: Mentor
 
Join Date: Oct 2004
Rookie Year: 2004
Location: Rochester, NY
Posts: 119
Mike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud of
Re: Read a GPS through a Serial Port

Quote:
Originally Posted by androb4 View Post
Alternatively you can read the GPS data via the arduino's serial port, then send that data over I2C to the digital sidecar.
If you use I2C to communicate between the cRIO and Arduino, be sure to "setCompabilityMode(true)" on the I2c object otherwise you will probably experience sporatic communication failures. Also, there is a bug in the i2c.java code that treats all sent data bytes (cRIO to Arduino) as signed instead of unsigned (java doesn't have an unsigned byte), this causes it overwrite some bytes with a 255 (0xFF) when it combines the bytes into 32 bit integers prior to transmitting. This bug has been fixed for the next release of WPILib, but probably still resides in your code. You can fix this yourself if it becomes a problem.

Mike
Reply With Quote
  #12   Spotlight this post!  
Unread 30-05-2013, 21:11
androb4's Avatar
androb4 androb4 is offline
..is trying to take this year off.
AKA: Andrew A.
no team
Team Role: Alumni
 
Join Date: Feb 2010
Rookie Year: 2003
Location: Houston, TX
Posts: 220
androb4 is a splendid one to beholdandrob4 is a splendid one to beholdandrob4 is a splendid one to beholdandrob4 is a splendid one to beholdandrob4 is a splendid one to beholdandrob4 is a splendid one to beholdandrob4 is a splendid one to behold
Re: Read a GPS through a Serial Port

Quote:
Originally Posted by ktrobotcreator View Post
Hmmm... Thanks for the suggestion, we can check that out next time we meet.
No problem.
__________________
FRC 441 Mentor 2012-2015
FRC 441 Alumni 2009-2012
FTC 4673 Alumni 2011-2012
FRC 1484 Alumni 2006-2008

Reply With Quote
  #13   Spotlight this post!  
Unread 31-05-2013, 11:31
otherguy's Avatar
otherguy otherguy is offline
sparkE
AKA: James
FRC #2168 (The Aluminum Falcons)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2009
Location: CT
Posts: 431
otherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to behold
Re: Read a GPS through a Serial Port

Quote:
Originally Posted by RufflesRidge View Post
This bug report suggests that the Serial port in Java is broken:
http://firstforge.wpi.edu/sf/go/artf...3699545405 50
I wrote that bug... and it's not fixed as far as I know.

Not being able to clear the read buffer makes the serial port quite useless. Any imput data just continues to stack up. So every time you read you get a complete history of the past data.

I tihnk you could recompile the source locally to fix the problem. I didn't have a lot of data to send, I just used a bunch of relay channels for the signals I needed to send. It would be really nice to have a useable RS232 port though in the future.
__________________
http://team2168.org
Reply With Quote
  #14   Spotlight this post!  
Unread 31-05-2013, 13:55
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,572
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Read a GPS through a Serial Port

Updated serial port files were just attached to the bug report in FIRST Forge.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 11:35.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi