[TeamTalk 261]: [797] trunk/TeamTalk: 1) Changes in Pendecoder map display to properly render the current livemaps.

tk@edam.speech.cs.cmu.edu tk at edam.speech.cs.cmu.edu
Tue Oct 2 00:26:54 EDT 2007


An HTML attachment was scrubbed...
URL: http://mailman.srv.cs.cmu.edu/pipermail/teamtalk-developers/attachments/20071002/d94b86e9/attachment.html
-------------- next part --------------
Modified: trunk/TeamTalk/Agents/PenDecoder/src/edu/cmu/ravenclaw/pendecoder/MapCanvas.java
===================================================================
--- trunk/TeamTalk/Agents/PenDecoder/src/edu/cmu/ravenclaw/pendecoder/MapCanvas.java	2007-10-01 17:20:14 UTC (rev 796)
+++ trunk/TeamTalk/Agents/PenDecoder/src/edu/cmu/ravenclaw/pendecoder/MapCanvas.java	2007-10-02 04:26:54 UTC (rev 797)
@@ -344,11 +344,11 @@
             byte run_value = (byte) (encoded_map[i] & 0x000000FF);
             dirty |= run_value != MapBufferedImage.MAP_UNCHANGED;
             switch(row_order) {
-                case Y_MAJOR:
+                case X_MAJOR:
                     Arrays.fill(decoded_map, j, run_terminus, run_value);
                     j = run_terminus;
                     break;
-                case X_MAJOR:
+                case Y_MAJOR:
                     for (; j < run_terminus; j++) decoded_map[(j%y)*x+j/y] = run_value;
                     break;
                 default:
@@ -472,8 +472,8 @@
      */
     public void setPreferredSize(Dimension d) {
         view_size = d;
-        map_to_screen.setToScale(view_size.width / native_width, view_size.height / native_height);
-        map_to_screen.translate(-x_origin, -y_origin);            
+        map_to_screen.setToScale(view_size.width / native_width, -view_size.height / native_height);
+        map_to_screen.translate(-x_origin+native_width, -y_origin);
         try {
             screen_to_map = map_to_screen.createInverse();
         } catch (NoninvertibleTransformException e) {

Modified: trunk/TeamTalk/Libraries/PrimitiveComm/udpsocket.cc
===================================================================
--- trunk/TeamTalk/Libraries/PrimitiveComm/udpsocket.cc	2007-10-01 17:20:14 UTC (rev 796)
+++ trunk/TeamTalk/Libraries/PrimitiveComm/udpsocket.cc	2007-10-02 04:26:54 UTC (rev 797)
@@ -332,13 +332,19 @@
   return (int) udp_clients.size();
 }
 
-bool UDPSocket::waitForData() {
+bool UDPSocket::waitForData(double timeout) {
   if (status <= 0) return 0;
 
   fd_set rdfs;
   FD_ZERO(&rdfs);
   FD_SET(fd, &rdfs);
-  return select((int)fd+1, &rdfs, NULL, NULL, NULL) > 0;
+
+  if(timeout) {
+    timeval tm;
+    tm.tv_sec = (long)timeout;
+    tm.tv_usec = (long)((timeout - tm.tv_sec)*1e6);
+    return select((int)fd+1, &rdfs, NULL, NULL, &tm) > 0;  
+  } else return select((int)fd+1, &rdfs, NULL, NULL, NULL) > 0;
 }
 
 bool UDPSocket::readyForRecv()

Modified: trunk/TeamTalk/Libraries/PrimitiveComm/udpsocket.h
===================================================================
--- trunk/TeamTalk/Libraries/PrimitiveComm/udpsocket.h	2007-10-01 17:20:14 UTC (rev 796)
+++ trunk/TeamTalk/Libraries/PrimitiveComm/udpsocket.h	2007-10-02 04:26:54 UTC (rev 797)
@@ -147,7 +147,7 @@
 
   // Returns if the socket can be written, read, or accepted without blocking.
   bool readyForRecv();
-  bool waitForData(); //blocking version of readyForRecv()
+  bool waitForData(double timeout=0.); //blocking version of readyForRecv()
   bool readyForSend();
   bool readyForAccept();
 

Modified: trunk/TeamTalk/Libraries/boeingLib/boeing/boeing_robot_client.cc
===================================================================
--- trunk/TeamTalk/Libraries/boeingLib/boeing/boeing_robot_client.cc	2007-10-01 17:20:14 UTC (rev 796)
+++ trunk/TeamTalk/Libraries/boeingLib/boeing/boeing_robot_client.cc	2007-10-02 04:26:54 UTC (rev 797)
@@ -337,22 +337,8 @@
   if (!isConnected()) 
     return NULL;
 
-  struct pollfd pfd;
-  pfd.fd=sock->getFD();
-  pfd.events=POLLIN;
-  pfd.revents=0;
-
-  int rv=poll(&pfd,1,(int)ceil(timeout*1e3));
-  if (rv<0) {
-    sock->disconnect();
-    printf("BoeingRobotClient::Connection error\n");
-    return NULL;
-  } else if (rv==0) {
-    // timeout
-    return NULL;
-  } else {
-    return getNextMessage();
-  }
+  if(!sock->waitForData(timeout)) return NULL;
+  else return getNextMessage();
 }
 
 

Modified: trunk/TeamTalk/Libraries/boeingLib/coralshared/udpsocket.cc
===================================================================
--- trunk/TeamTalk/Libraries/boeingLib/coralshared/udpsocket.cc	2007-10-01 17:20:14 UTC (rev 796)
+++ trunk/TeamTalk/Libraries/boeingLib/coralshared/udpsocket.cc	2007-10-02 04:26:54 UTC (rev 797)
@@ -400,6 +400,47 @@
   return (false);
 }
 
+bool UDPSocket::waitForData(double timeout)
+{
+  if (status <= 0) 
+    return 0;
+
+  if (status == Server && last_message_bytes > 0) 
+    return true;
+
+  pollfd pfd;
+
+  pfd.fd = fd;
+  pfd.events = POLLIN;
+
+  if (poll(&pfd, 1, timeout*1e3) <= 0)
+    return(false);
+
+  //  if (pfd.revents & (POLLERR | POLLNVAL)) {
+  if (pfd.revents & POLLERR) {
+    perror("UDPSocket:");
+    fprintf(stderr, "error, shutting down socket..., fd %i perr %i, pnval %i\n",
+            fd,pfd.revents & POLLERR, pfd.revents & POLLNVAL);
+    disconnect();
+
+    return (false);
+  }
+
+  // check for new data
+  if(pfd.revents & POLLIN) {
+    if (status == Server) {
+      udpServerRecv();
+      return (last_message_bytes > 0);
+    } else {
+      //          printf("can read from %d\n",i);
+      return(true);
+    }
+  }
+
+  Assert(0, "How did we get here?");
+  return (false);
+}
+
 bool UDPSocket::readyForSend()
 {
   if (status <= 0) 

Modified: trunk/TeamTalk/Libraries/boeingLib/coralshared/udpsocket.h
===================================================================
--- trunk/TeamTalk/Libraries/boeingLib/coralshared/udpsocket.h	2007-10-01 17:20:14 UTC (rev 796)
+++ trunk/TeamTalk/Libraries/boeingLib/coralshared/udpsocket.h	2007-10-02 04:26:54 UTC (rev 797)
@@ -141,6 +141,7 @@
 
   // Returns if the socket can be written, read, or accepted without blocking.
   bool readyForRecv();
+  bool waitForData(double timeout); //blocking version of readyForRecv()
   bool readyForSend();
   bool readyForAccept();
 


More information about the TeamTalk-developers mailing list