How do I implement a robust algorithm for tracking object positions which is able to overcome out-of-order and missing messages?    

In general, you can't rely on PubNub to never miss a message or deliver a message out of order. You can augment normal message delivery with your own protocol (embedded within the message payload) to overcome such imperfections, however rare they may be. Techniques for this robust protocol may include (depending on the app requirements):

  • A running message counter included with the published message by the sender side
  • Subscriber verifies increasing order of counter values in received message sequence
  • Messages received out of order are dropped on the client side
  • Object position is interpolated when a gap is detected to provide for smooth movement (albeit at a possible time delay)
  • Use a physics model for object movement whereby received messages adjust the model rather than the position directly
  • Many, many other techniques used in gaming to overcome network and latency issues