Timestamp in msgPlayerUpdate and msgPlayerUpdateSmall

Place all meeting requests / announcements here...
Post Reply
User avatar
gnu-sense
Private First Class
Private First Class
Posts: 78
Joined: Wed Nov 22, 2006 1:21 am

Timestamp in msgPlayerUpdate and msgPlayerUpdateSmall

Post by gnu-sense » Mon Nov 12, 2007 4:27 am

I'm working on a modified bzadmin client that extracts and displays the player location information, etc. I have most things working acceptably, in spite of a lack of documentation on the protocol used by bzf. I am, however, running into a major problem understanding the timestamp field, normally the second thing in the msgPlayerUpdate and msgPlayerUpdateSmall packets. In both, the field is formatted as a float, and the code appears to handle it as a floating point number in calculation. However, displaying it as such results in near nonsense. Very large and very small values, and large positive and negative values come close together in time from the same player, suggesting that the information isn't naturally represented as a float. The other values that I see appear to be correct, so the field size does appear to be right. Can anyone suggest to me how I might be able to get meaningfully displayed information out of this field? I have tried several things involving other types, but I am casting about and not really getting anywhere. Below is the code I have that pertains to this, from the switch statement inside BZAdminClient::checkMessage() :

Code: Select all

            case MsgPlayerUpdateSmall:
            case MsgPlayerUpdate: {
                if (!messageMask[MsgPlayerUpdate]) break ;
                
                float timestamp; // could be used to enhance deadreckoning, but isn't for now
                int32_t order;                 // unused?
                short status;
                float velocity[3], pos[3], azimuth, angVel;
                
                vbuf = nboUnpackUByte(vbuf, p);
                vbuf = nboUnpackFloat(vbuf, timestamp);

                vbuf = nboUnpackUByte(vbuf, p);
                vbuf = nboUnpackInt(vbuf, order);
                vbuf = nboUnpackShort(vbuf, status);            
        
                it = players.find(p);
                victimName = (it != players.end() ? it->second.name : "<unknown>");
                lastMessage.first += TextUtils::format("%f",timestamp) + " '" + victimName + "' " ;
        
                if (code==MsgPlayerUpdateSmall) {
                    // the full scale of a int16_t  (less 1.0 for safety)
                    const float smallScale     = 32766.0f;
                    // 2 cm resolution  (range: +/- 655.32 meters)
                    const float smallMaxDist   = 0.02f * smallScale;
                    // 1 cm/sec resolution  (range: +/- 327.66 meters/sec)
                    const float smallMaxVel    = 0.01f * smallScale;
                    // 0.001 radians/sec resolution  (range: +/- 32.766 rads/sec)
                    const float smallMaxAngVel = 0.001f * smallScale;
                    
                    int16_t posShort[3], velShort[3], aziShort, angVelShort;
                    
                    vbuf = nboUnpackShort(vbuf, posShort[0]);
                    vbuf = nboUnpackShort(vbuf, posShort[1]);
                    vbuf = nboUnpackShort(vbuf, posShort[2]);
                    vbuf = nboUnpackShort(vbuf, velShort[0]);
                    vbuf = nboUnpackShort(vbuf, velShort[1]);
                    vbuf = nboUnpackShort(vbuf, velShort[2]);
                    vbuf = nboUnpackShort(vbuf, aziShort);
                    vbuf = nboUnpackShort(vbuf, angVelShort);
                        
                    for (int i=0; i<3; i++) {
                        pos[i] = ((float)posShort[i] * smallMaxDist) / smallScale;
                        velocity[i] = ((float)velShort[i] * smallMaxVel) / smallScale;
                    }
                    azimuth = (float)((aziShort * M_PI) / smallScale);
                    angVel = ((float)angVelShort * smallMaxAngVel) / smallScale;
                } else {
                    vbuf = nboUnpackVector(vbuf, pos);
                    vbuf = nboUnpackVector(vbuf, velocity);
                    vbuf = nboUnpackFloat(vbuf, azimuth);
                    vbuf = nboUnpackFloat(vbuf, angVel);
                }
        
                lastMessage.first += "x: " + TextUtils::format("%f",pos[0]) + " dx: " + TextUtils::format("%f", velocity[0]) + " " ; 
                lastMessage.first += "y: " + TextUtils::format("%f",pos[1]) + " dy: " + TextUtils::format("%f", velocity[1]) + " " ; 
                lastMessage.first += "z: " + TextUtils::format("%f",pos[2]) + " dz: " + TextUtils::format("%f", velocity[2]) + " " ; 
                lastMessage.first += "a: " + TextUtils::format("%f",azimuth) + " da: " + TextUtils::format("%f", angVel) ; 
        
                break;
            }
Sorry for the large message, but I wanted to be specific.

gnu-sense

User avatar
gnu-sense
Private First Class
Private First Class
Posts: 78
Joined: Wed Nov 22, 2006 1:21 am

Sample output

Post by gnu-sense » Mon Nov 12, 2007 4:31 am

A bug in Safari prevented me from including this in the previous post; hence the double post.
The following is sample output:

Code: Select all

27 MsgPlayerUpdateSmall : 912458674134621884763277885440.000000 'Alec' x: 15.960000 dx: 243.129990 y: -10.240000 dy: -112.639999 z: 5.080000 dz: 1.820000 a: 0.466646 da: 4.352000
27 MsgPlayerUpdateSmall : 915592209859063003584116293632.000000 'Alec' x: 41.579998 dx: 79.400002 y: 112.639999 dy: -163.839996 z: 0.020000 dz: 1.830000 a: 0.000192 da: 15.616001
27 MsgPlayerUpdateSmall : -9669889.000000 'Alec' x: -527.059998 dx: 217.509995 y: 291.839996 dy: 281.600006 z: 5.020000 dz: 1.710000 a: -0.907980 da: 4.096000
27 MsgPlayerUpdateSmall : 918609688704821118004182908928.000000 'Alec' x: 72.299995 dx: 92.199997 y: 230.399994 dy: -166.399994 z: 0.020000 dz: 1.810000 a: -1.325824 da: -4.352000
27 MsgPlayerUpdateSmall : 0.182308 'Alec' x: -395.100006 dx: 189.399994 y: -414.720001 dy: -10.240000 z: 0.180000 dz: 2.430000 a: 1.178073 da: -17.408001
27 MsgPlayerUpdateSmall : 0.000791 'Alec' x: -185.019989 dx: -189.539993 y: 634.919983 dy: -151.050003 z: -174.080002 dz: 50.759998 a: -0.981712 da: -1.536000
27 MsgPlayerUpdateSmall : 0.000000 'Alec' x: 275.380005 dx: -253.509995 y: 384.100006 dy: -76.799995 z: -189.300003 dz: 2.280000 a: 2.306960 da: -7.936000
27 MsgPlayerUpdateSmall : 109345408361520345120768.000000 'Alec' x: -598.260010 dx: 261.160004 y: 76.799995 dy: -212.479996 z: 0.020000 dz: 1.800000 a: 1.276638 da: 4.352000
27 MsgPlayerUpdateSmall : 0.000804 'Alec' x: -185.019989 dx: -28.260000 y: 291.880005 dy: -151.059998 z: -204.819992 dz: -92.599998 a: -0.441813 da: 2.048000
27 MsgPlayerUpdateSmall : 0.000000 'Alec' x: 608.179993 dx: 176.569992 y: 102.500000 dy: 319.989990 z: -189.300003 dz: -2.860000 a: 1.153240 da: -4.352000
27 MsgPlayerUpdateSmall : 0.000000 'Alec' x: -635.219971 dx: -122.799995 y: -133.119995 dy: 179.199997 z: 5.000000 dz: 0.860000 a: -1.178169 da: 0.000000
27 MsgPlayerUpdateSmall : -11727361.000000 'Alec' x: 153.879990 dx: -64.099998 y: 163.839996 dy: -168.959991 z: 5.040000 dz: 1.790000 a: 0.663008 da: 4.352000
27 MsgPlayerUpdateSmall : 110885711491675092680704.000000 'Alec' x: -480.500000 dx: 17.959999 y: 588.799988 dy: -148.479996 z: 0.020000 dz: 1.830000 a: 2.085958 da: -4.352000
27 MsgPlayerUpdateSmall : 0.000000 'Alec' x: 199.360001 dx: 258.630005 y: 593.919983 dy: -5.120000 z: 5.000000 dz: 0.890000 a: 1.080180 da: 27.648001
27 MsgPlayerUpdateSmall : 1505420509184.000000 'Alec' x: -4.180000 dx: 0.000000 y: -332.799988 dy: 0.000000 z: 0.000000 dz: 1.190000 a: -0.196074 da: 4.352000
27 MsgPlayerUpdateSmall : 1510923436032.000000 'Alec' x: 123.820000 dx: -122.889999 y: -358.399994 dy: 112.639999 z: 0.080000 dz: 1.210000 a: 1.546635 da: 4.352000
27 MsgPlayerUpdateSmall : 6163089395763696893952.000000 'Alec' x: 461.479980 dx: 0.000000 y: 51.239998 dy: 0.000000 z: -92.159996 dz: 2.210000 a: -1.374914 da: -4.352000
27 MsgPlayerUpdateSmall : 112794949503304031272960.000000 'Alec' x: -306.419983 dx: 307.100006 y: -128.000000 dy: -66.559998 z: 5.040000 dz: 1.760000 a: -0.859465 da: -4.352000
27 MsgPlayerUpdateSmall : -13834497.000000 'Alec' x: -199.440002 dx: 227.739990 y: -92.159996 dy: 248.319992 z: 5.080000 dz: 1.840000 a: -1.276733 da: -4.352000
27 MsgPlayerUpdateSmall : 0.190270 'Alec' x: 70.799995 dx: 168.919998 y: -143.360001 dy: -71.680000 z: 0.180000 dz: 2.420000 a: -1.325440 da: 6.656000
27 MsgPlayerUpdateSmall : 10.330078 'Alec' x: 434.139984 dx: 245.709991 y: 624.679993 dy: 207.360001 z: -97.259995 dz: 0.750000 a: -1.030706 da: -32.256001
27 MsgPlayerUpdateSmall : 0.000000 'Alec' x: 178.899994 dx: -153.539993 y: -547.839966 dy: -291.839996 z: 4.960000 dz: 0.980000 a: -2.380596 da: 2.816000
27 MsgPlayerUpdateSmall : 114402122080725975957504.000000 'Alec' x: 569.099976 dx: 233.000000 y: 240.639999 dy: 179.199997 z: 0.040000 dz: 1.710000 a: 2.650497 da: -4.352000
27 MsgPlayerUpdateSmall : 0.000000 'Alec' x: -307.500000 dx: -319.940002 y: -138.239990 dy: 174.080002 z: 4.960000 dz: 0.990000 a: 3.141593 da: -6.656000
27 MsgPlayerUpdateSmall : 0.000000 'Alec' x: 628.619995 dx: 163.769989 y: 353.380005 dy: 325.089996 z: -578.419983 dz: -84.939995 a: 2.896045 da: -1.536000
27 MsgPlayerUpdateSmall : 10.525879 'Alec' x: 638.940002 dx: -186.929993 y: 35.880001 dy: 281.600006 z: -97.259995 dz: 0.780000 a: -2.135432 da: -16.896000

User avatar
JeffM
Staff Sergeant
Staff Sergeant
Posts: 5193
Joined: Fri Dec 13, 2002 4:11 am
Location: https://github.com/OmniTanks
Contact:

Post by JeffM » Mon Nov 12, 2007 5:14 am

the timestamp field is not set correctly for 2.0.x. It was added but never fully implemented, and is unused. It is set to a server synced lag compensating clock value in 2.1.
ImageJeffM

Post Reply