network_race_statistics 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #!/bin/bash
  2. # Start an STK client with:
  3. # --log=0 --stdout=client --online --logbuffer=100000
  4. # Add "--history=2" if you want to use a replay.
  5. # Start a server with:
  6. # --log=0 --stdout=server --lan-server=lan-server --no-graphics --online --logbuffer=100000
  7. # Remove --no-graphics if you also want to see the graphics on the server
  8. # Then do a race, and stop/abort on the client. Wait a long time for
  9. # the log file to be flushed!!! The server will trigger flushing its
  10. # log buffer when the client disconnects as well. So wait for both
  11. # 'server' and 'client' files to stay unchanged.
  12. # First extract the phsyicsafter lines, which contain physics
  13. # information to evaluate client/server consistency.
  14. cat server | grep physicsafter > xx.s
  15. cat client | grep physicsafter > xx.c
  16. # Each log line done during a rewind will start with 'Rewind '. The
  17. # space at the beginning changes the column numbers used in gnuplot
  18. # for each field (as a result rewind lines are not plotted by default)
  19. # Removing the space means that rewind data will be plotted as well
  20. cat xx.c | sed 's/Rewind /Rewind/' >xx.cc
  21. # Now compute the error per client timestep. The parametrs are:
  22. # -f which fields to use: first field is the world time, then one
  23. # or more fields. The script will compute for each client frame the
  24. # earliest immediate previous and next data from the server at the
  25. # client time. Based on those two data points it will interpolate
  26. # the data of the server at the client time, and compute the
  27. # distance between client and server.
  28. # For column numbers check the xx.s files: each name contains the
  29. # column numbers in (), e.g.:
  30. # xyz(9-11) 0.1 0.2 0.3
  31. # This indicates that the column 9-11 in the file are the xyz position
  32. # It saves column counting if the heading is kept up to date
  33. # Comparison of (physical) position used in STK:
  34. ~/stk-code/tools/compute_client_error.py -f 6,9,10,11 xx.s xx.cc >pos
  35. # Comparison of physical position at the end of the last full
  36. # bullet time step (i.e. multple of 1/120).
  37. ~/stk-code/tools/compute_client_error.py -f 6,12,13,14 xx.s xx.cc >phys-pos
  38. # Comparison of velocity
  39. ~/stk-code/tools/compute_client_error.py -f 6,16,17,18 xx.s xx.cc >v
  40. # Comparison of steering
  41. ~/stk-code/tools/compute_client_error.py -f 6,20 xx.s xx.cc >steering
  42. # Useful gnuplot commands:
  43. # Plot the path taken for client and server (use xx.c instead of xx.cc not
  44. # remove rewinds):
  45. # plot "xx.cc" u 9:11 w lp lw 2, "xx.s" u 9:11 w lp, "recorded/xx.c" u 9:11 w lp
  46. # Plot steering values used:
  47. # a=20; plot "xx.cc" u 6:a w lp lw 2, "xx.s" u 6:a w lp, "recorded/xx.c" u 6:a w lp
  48. # Change a=XX if you want to display a different value
  49. #
  50. # It can be useful to plot the time step size:
  51. # plot "xx.s" u 6:7 w lp, "xx.cc" u 6:7 w lp
  52. # and also to check that the game time is in sync between client and server:
  53. # Field 29 is the real time clock, so they can be compared if you are running
  54. # on the same machine. So this shows what the game clock is at a given real
  55. # time. Note that the client must be somewhat ahead of the server!
  56. # plot "xx.cc" u 29:6 w lp lw 2, "xx.s" u 29:6 w lp