Probably the most important task for long range machine to machine communication is to know exactly where our roving machines are, and even the stationary ones. In many cases, ordinary GPS/GNSS satellite positioning would be fine, giving an accuracy of about 2 metres for a moving machine. The accuracy of a stationary machine can be much better if thousands of readings are averaged over 24 hours or even a whole week. To get the positional accuracy of moving machines to an acceptable levels, correction data needs to be sent to the machine (Dog) itself for it to calculate an accurate position for itself, which can then be transmitted back to Mission Control (Nest). The idea of correction data is a slightly abstract concept and has a few logical fundamentals to be aware of:
- Data sent from satellites travel through the Earth's atmosphere, which causes the time component to vary slightly causing a subsequent small error.
- This error can be largely corrected for a stationary module in the Nest by taking an average of many thousands of readings over a whole week.
- We now know the exact position of this one module located in the Nest.
- The Dog is roaming around within a few miles from the Nest and so the data from the satellites goes through pretty much the same chunk of Earth's atmosphere as the Nest.
- The error for the Dog and Nest is pretty much the same.
- The Nest module knows exactly where it is, so it also knows the error at any given time.
- If the Nest can send the error details to the Dog, then the Dog would also know the error and so be able to correct it's own position.
Fortunately, the Ublox module does a lot of the work for us and all we have to do it to configure it to export the correction data if the module is in the Nest and import it if it is on a Dog. Configuration files are available in the Github repo. The Ublox configuration is done on a Windows computer running the free Ucenter app, which is quite vast and may take a bit of time to navigate - but it's quite fun to see all the satellites buzzing about the sky and the true positional accuracy of our machines.
Normally, we'd just get a radio module for the Ublox module, bolt it on and job done, but I chose to take control of the correction data and route it into a LoRa module for long range transmission. I wanted to have ROS enabled in all the machines, so it was logical to get the data moving trough the ROS, which proved to be quite 'interesting'. In a previous iteration , we used RTKLIB and it's str2str app, which worked really well through WIFI, but with very limited range. Getting the data moving through ROS meant changing it from ASCII characters into HEX format, changing HEX into a string, and then splitting the HEX string data into packets of size 45 characters each. The data is given a 'start' and 'finish' flag and then gets relayed to an Arduino MCU through ROS which is then transmitted through LoRa, one packet at a time with additional data such as signal strength and such like bolted on. It's quite satisfying to see the data come over on the Dog and the process for getting the received data into the Dog's Ublox module is just a matter of reversing what was done in the Nest.
If anybody's interested in the actual code that handles this, it's located in a file called: nest_slave_talker_listener.py in the custom made nest_slave_talker_listener ROS package. Serial data is handled very nicely by the Python Serial library.