Welcome, Guest. Please Login.
Surveyor Corporation Surveyor SRV-1
Home Help Search Login

Surveyor Robotics Forum

Welcome to the user support forum for Surveyor SRV-1 robots, SRV-1 robot controllers and SVS stereo vision systems. To register for this forum, please send an email to support@surveyor.com which includes your desired forum user name, your registration email address, and a brief explanation of why you wish to join, and we will create a forum account for you.

Please note that there is a Search button in the forum toolbar for forum topics. Another effective search method for the entire surveyor.com site is to use Google, e.g. "xyz site://www.surveyor.com" where "xyz" is the search topic.



Pages: 1
Send Topic Print
SRV-1 programming in Java (Read 2237 times)
sajid
YaBB Newbies
*




Posts: 3
SRV-1 programming in Java
08/07/07 at 7:10am
 
I've come across posts about programming the SRV-1 in C and C++.
 
However, I would like to program the SRV-1 in Java as i'm most familiar with this language.
 
How do i go about this, and how do i import a library for neural networks?
Back to top
 
 
  IP Logged
admin
YaBB Administrator
*****




Posts: 3676
Re: SRV-1 programming in Java
Reply #1 - 08/07/07 at 12:40pm
 
This has been done with Python - see http://www.surveyor.com/cgi-bin/yabb2/YaBB.pl?num=1175456528
 
I don't know of anyone working on neural nets with the SRV-1 in Java, but using neural nets in Java seems to be common -  
 
* http://fbim.fh-regensburg.de/~saj39122/jfroehl/diplom/e-index.html
* http://www.jeffheaton.com/ai
* http://www.ibm.com/developerworks/library/l-neural/
 
Basically, you just need to create a Java application that communicates with the serial port to send and receive SRV_protocol commands to the robot ( see protocol definition at http://www.surveyor.com/SRV_protocol.html ) which gather sensor data and send motor commands.  You'll probably want to use the RXTXcomm.jar library for serial communications.   Here's some code for setting up the serial port -
 
    private void openSerialPort()
    {
    Enumeration portList;
    CommPortIdentifier portId;
 
    if (comPort == null || "".equals (comPort)) {
       error("no COM port specified");
    }
 
    portList = CommPortIdentifier.getPortIdentifiers();
 
    while (portList.hasMoreElements()) {
 
       portId = (CommPortIdentifier) portList.nextElement ();
       if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) {
               
       if (comPort.equals(portId.getName ())) {
 
           trace("opening " + portId.getName () + "...");
 
           try {
           serialPort =
               (SerialPort) portId.open("SRV Console", 0);
           }
           catch (PortInUseException e) {
           trace("RS232 port in use");
           return;
           }
 
           setBps (115200);
 
           try {
           out = serialPort.getOutputStream();
           is = new BufferedInputStream(serialPort.
                            getInputStream(), 16384);
           } catch (IOException e2) {
           error(e2.toString());
           }
 
           serialPort.setDTR(false);
           serialPort.setRTS(false);
 
           /*
           try {
           serialPort.addEventListener(this);
           } catch (TooManyListenersException e) {    }
           serialPort.notifyOnDataAvailable(true);
           */
 
           trace("connected to " + portId.getName ());
           return;
       }
       }
    }
    }
 
    private void closeSerialPort()
    {
    try {
       if (out != null)    out.close ();
       if (is != null)    is.close ();
       if (serialPort != null)    serialPort.close();
           
       out = null;
       is = null;
       serialPort = null;
    } catch (IOException ioe) {
       trace ("Error closing SRV connection: " + ioe);
    }
    }
 
 
    private boolean setBps(int bps)
    {
    boolean r = false;
 
    try {
       serialPort.setSerialPortParams (bps,
                       SerialPort.DATABITS_8,
                       SerialPort.STOPBITS_1,
                       SerialPort.PARITY_NONE);
 
       serialPort.setFlowControlMode(SerialPort.FLOWCONTROL_NONE);
       r = true;
    } catch (UnsupportedCommOperationException e3) {
       error ("error configuring RS232 port");
       e3.printStackTrace ();
    }
 
    return r;
    }
     
Back to top
 
 

SRV-1 Development Team
Surveyor Corporation
Email WWW   IP Logged
sajid
YaBB Newbies
*




Posts: 3
Re: SRV-1 programming in Java
Reply #2 - 08/17/07 at 1:47pm
 
thanks yabb.
 
i had a few errors with the code, managed to fix them and it now compiles.
i added a main method to call the serial class but i get an error with the portID.
 
 
 
So, i was hoping to get the source code for the SRV-1 Java Console? is this available? How do i obtain it?
 
Back to top
 
 
  IP Logged
admin
YaBB Administrator
*****




Posts: 3676
Re: SRV-1 programming in Java
Reply #3 - 08/17/07 at 2:18pm
 
Just send an email requesting the source to support@surveyor.com
Back to top
 
 

SRV-1 Development Team
Surveyor Corporation
Email WWW   IP Logged
Pages: 1
Send Topic Print