Base setup: collecting averaged position coordinates

Sometimes an accurate lat/long/height is not available for the base station position, and if one is doing real RTK work and not just post-processing, then this needs to be entered into ReachView’s config tab for the base station setup.

One way to get the base station coordinate at an unknown point is to temporarily put the base station in rover mode long enough to get a single solution coordinate. Even better would be to log those coordinates for a little while and and then take the average position.

We know that this feature is on Emlid’s to-do list for ReachView, but until then, here is a one-liner script that you can paste onto your command line for averaging coordinates from Reach’s tcp server output:

num_positions=0; avg_lat=0; avg_long=0; avg_height=0; netcat 9000 | sed -u -n '/^[0-9]\+\s\+[0-9.]\+\s\+[-0-9.]\+\s\+[-0-9.]\+\s\+[-0-9.]\+\s\+[0-9]\s\+/p' | while read line; do ((num_positions++)); this_lat="`echo "${line}" | awk '{print $3}'`"; this_long="`echo "${line}" | awk '{print $4}'`"; this_height="`echo "${line}" | awk '{print $5}'`"; if [[ num_positions == 1 ]]; then avg_lat="${this_lat}"; avg_long="${this_long}"; avg_height="${this_height}"; else avg_lat="`echo "scale=9;${avg_lat}*(${num_positions}-1)/${num_positions}+${this_lat}/(${num_positions})" | bc -l`"; avg_long="`echo "scale=9;${avg_long}*(${num_positions}-1)/${num_positions}+${this_long}/(${num_positions})" | bc -l`"; avg_height="`echo "scale=4;${avg_height}*(${num_positions}-1)/${num_positions}+${this_height}/(${num_positions})" | bc -l`"; fi; echo "I: $this_lat $this_long $this_height O: $avg_lat $avg_long $avg_height P: $num_positions"; done

Do as above, but change the first part where it says “netcat 9000”:

  • change to Reach’s IP address
  • change 9000 to Reach’s tcp port

In ReachView, my settings were:

  • rover mode
  • positioning mode: dgps
  • used positioning systems: gps, sbas
  • u-blox configuration file: GPS_14Hz
  • solution 1 output path: tcpsvr 9000
  • solution 1 output format: llh

You can run this by pasting into your local command prompt in Linux/Mac. Unfortunately it doesn’t work Reach itself over ssh / Putty.exe because a lack of the bc calculator.
Use CTRL-c to stop

I saved it as and gave it executable permissions.

The output format:
I: current_latitude current_longitude current_height
O: average_latitude average_longitude average_height
P: number_of_averaged_positions

After running this for a little while, you can see the current position bouncing around (I:) and the average position (O:) settling down. When you are happy, stop the script and record the average position.

I tested this with Reach indoors and all sats in the yellow (<45dB SNR) for about 20 minutes and got 20,000 iterations. By this time the average position was moving around about 0.1mm per iteration. That is not to say that this average position is in any way accurate by our standards, but it should be pretty close. What it does say is that averaging for a couple of minutes is probably good enough and 20 minutes is just wasting time!

Feel free to post a better version if you have one! There’s lots of room for improvement.