예제 #1
0
  /**
   * Asks the robot for its position
   *
   * @return The position of the robot
   */
  public Point3Dim getRobotPos() {

    // Request calibration point
    String t = new String("REQ_CAL");
    serialCom.writeString(t);

    // Wait for response from robot, time out if no response
    if (!waitForResponse()) {
      return null;
    }

    String stringData = new String(inData);

    /* Is it calibration value? */
    if (stringData.startsWith("CAL")) {
      String[] data = stringData.split(";");
      Double d1 = new Double(data[1]);
      Double d2 = new Double(data[2]);
      Double d3 = new Double(data[3]);

      Point3Dim point = new Point3Dim(d1, d2, d3);
      inData = null; // reset indata after having read it
      System.out.println("Read robotvalue: " + point.toString());
      return point;
    } else return null;
  }
예제 #2
0
 /**
  * Connects to a serialport to prepare for transmission
  *
  * @param comPort The port to connect to
  */
 public void connect(String comPort) {
   try {
     serialCom = new SerialCom(this);
     serialCom.connect(comPort);
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
예제 #3
0
 /* (non-Javadoc)
  * @see java.io.InputStream#available()
  */
 public int available() {
   return p.getStatus(SerialCom.AVAILABLE_INPUT_STATUS);
 }
예제 #4
0
 /* (non-Javadoc)
  * @see java.io.InputStream#read(byte[], int, int)
  */
 public int read(byte[] b, int off, int len) throws IOException {
   if (b == null) throw new NullPointerException();
   if (off < 0 || len < 0 || len > b.length - off) throw new IndexOutOfBoundsException();
   return p.readBytes(b, off, len);
 }
예제 #5
0
 /* (non-Javadoc)
  * @see java.io.InputStream#read(byte[])
  */
 public int read(byte[] b) throws IOException {
   if (b == null) throw new NullPointerException();
   return p.readBytes(b, 0, b.length);
 }
예제 #6
0
 /* (non-Javadoc)
  * @see java.io.InputStream#read()
  */
 public int read() throws IOException {
   return p.read();
 }
예제 #7
0
 /**
  * Commands the robot to go to a position and read a value.
  *
  * @param point The position to go to.
  * @param zNormal
  * @param yNormal
  * @param xNormal
  */
 public void robotGoTo(Point3Dim point, double angle) {
   String t = new String("GOTO_POS;" + point.x + ";" + point.y + ";" + point.z + ";" + angle);
   serialCom.writeString(t);
 }