I have two apps communicating over
UDP. One of the apps is a remote control and the other is a robot.
When the robot has some new data, for example a new sensor reading or GPS coordinate, I simply put this in an
UDP packet on it's way to the remote for display and that is that. Since the sensor data has a short time span of validity it does not matter when the packet is lost, because a new one will follow with more updated data shortly anyways.
Similarly when the remote wants the robot to change behavior, I put the new desired behavior in an
UDP packet on its way to the remote for execution. The only difference now is that this time I also send an "acknowlegement" packet back to the remote so that it will know that the the command was well received. Still this is a simple case.
However in the case where there is a state in the robot that BOTH the robot itself and the remote may change, for example if there is a "panic button" that can both be operated from the remote and the robot, how can the state be kept in sync? Since there is no guarantee the
UDP packets will reach their destinations, I imagine there needs to be set up some kind of acknowledgement scheme that does not effectuate a command unless it knows that both remote and robot know what is about to happen. But to me this seems impossible to accomplish.