From: Kurt K. <kon...@AI...> - 2006-06-26 21:29:50
Attachments:
diff.txt
|
Folks, here's a new diff for MapInterface.java, fixing a problem with compressed map tiles. The previous version didn't uncompress the tile; this version uses Java's ZLIB classes to do it. Tested with Player 2.0.2. Cheers --Kurt |
From: Radu B. R. <ru...@cs...> - 2006-06-30 08:47:01
|
Patched and committed to the SVN repository. Thanks Kurt! Best, R. Kurt Konolige wrote: > Folks, here's a new diff for MapInterface.java, fixing a problem with > compressed map tiles. The previous version didn't uncompress the tile; > this version uses Java's ZLIB classes to do it. Tested with Player 2.0.2. > > Cheers --Kurt > > > ------------------------------------------------------------------------ > > Index: MapInterface.java > =================================================================== > --- MapInterface.java (revision 68) > +++ MapInterface.java (working copy) > @@ -34,6 +34,8 @@ > import javaclient2.structures.map.PlayerMapData; > import javaclient2.structures.map.PlayerMapDataVector; > > +import java.util.zip.*; > + > /** > * The map interface provides acces to an occupancy grid map. This interface returns no data > * and accepts no commands. The map is delivered in tiles, via a sequence of configuration > @@ -147,14 +149,15 @@ > */ > public void requestMapData (PlayerMapData pmd) { > try { > - sendHeader (PLAYER_MSGTYPE_REQ, PLAYER_MAP_REQ_GET_DATA, 20); > - XdrBufferEncodingStream xdr = new XdrBufferEncodingStream (20); > + sendHeader (PLAYER_MSGTYPE_REQ, PLAYER_MAP_REQ_GET_DATA, 24); > + XdrBufferEncodingStream xdr = new XdrBufferEncodingStream (24); > xdr.beginEncoding (null, 0); > xdr.xdrEncodeInt (pmd.getCol ()); > xdr.xdrEncodeInt (pmd.getRow ()); > xdr.xdrEncodeInt (pmd.getWidth ()); > xdr.xdrEncodeInt (pmd.getHeight ()); > xdr.xdrEncodeInt (0); > + xdr.xdrEncodeInt (0); > xdr.endEncoding (); > os.write (xdr.getXdrData (), 0, xdr.getXdrLength ()); > xdr.close (); > @@ -203,12 +206,13 @@ > } > case PLAYER_MAP_REQ_GET_DATA: { > // Buffer for reading col, row, width, height, data_count > - byte[] buffer = new byte[20]; > + // NOTE: extra 4 bytes are also returned > + byte[] buffer = new byte[24]; > // Read col, row, width, height, data_count > - is.readFully (buffer, 0, 20); > - > - pmdata = new PlayerMapData (); > - > + is.readFully (buffer, 0, 24); > + > + pmdata = new PlayerMapData (); > + > // Begin decoding the XDR buffer > XdrBufferDecodingStream xdr = new XdrBufferDecodingStream (buffer); > xdr.beginDecoding (); > @@ -224,13 +228,31 @@ > buffer = new byte[PLAYER_MAP_MAX_TILE_SIZE]; > // Read data > is.readFully (buffer, 0, pmdata.getData_count ()); > - pmdata.setData (new String (buffer).toCharArray ()); > - > - // Take care of the residual zero bytes > - if ((pmdata.getData_count () % 4) != 0) > - is.readFully (buffer, 0, 4 - (pmdata.getData_count () % 4)); > - > - readyPmdata = true; > + > + try > + { > + byte [] outbuffer = new byte[PLAYER_MAP_MAX_TILE_SIZE]; > + Inflater decomp = new Inflater(); > + decomp.reset(); > + // NOTE: need to offset input buffer by 4 bytes > + decomp.setInput(buffer,0,pmdata.getData_count()); > + int len = decomp.inflate(outbuffer); > + pmdata.setData (new String (outbuffer).toCharArray ()); > + > + // Take care of the residual zero bytes > + if ((pmdata.getData_count () % 4) != 0) > + is.readFully (buffer, 0, 4 - (pmdata.getData_count () % 4)); > + > + // Reset data count > + pmdata.setData_count(len); > + System.err.println("Map decompress: "+pmdata.getData_count()+" bytes"); > + readyPmdata = true; > + } > + catch (Exception ex) > + { > + ex.printStackTrace(); > + } > + > break; > } > case PLAYER_MAP_REQ_GET_VECTOR: { > > > ------------------------------------------------------------------------ > > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > > > ------------------------------------------------------------------------ > > _______________________________________________ > Java-player-developers mailing list > Jav...@li... > https://lists.sourceforge.net/lists/listinfo/java-player-developers -- | Radu Bogdan Rusu | http://rbrusu.com/ | http://www9.cs.tum.edu/people/rusu/ | Intelligent Autonomous Systems | Technische Universitaet Muenchen |