# How can I get Reach heading output

I’m looking into integrating my Reach module into my rover control application.

I plan to obtain position information from a tcp stream.

Is there a way to obtain heading information from the Reach module over TCP?

(I think I may have overlooked some documentation?)

There is no heading provided in NMEA yet, but since heading calculation in GPS is very straightforward you can do it on the rover side. It is simply the direction from the previous point to the current one + some low pass filter.

Has anyone implemented this calculation?

I followed the haversine formula, but I need a filter, for sure, because the position values jump around, especially when I’m not in a “fix” solution status.

Essentially, if my lat or long values change by 0.000001 (which is about 10cm in my latitude), I calculate a heading.

I use the formula atan2( cos(lat1) * sin(lat2)-sin(lat1) * cos(lat2)* cos(long2-long1), sin(long2-long1) * cos(lat2) )

(I convert my lat/long to radians for the trig functions, then convert back to degrees for the user interface)

but the result of this calculation really bounces around, since the coordinates randomly pop in. As a result, the direction my rover is pointing bounces around and doesn’t match what it actually is.

Emlid/Igor - I’d really like to pull the value from the onboard IMU!

I did switch to the geodesic library’s calculation of heading. The haversine formula assumes a spheroid, but the geodesic library works with the WGS84 ellipsoid. For my purposes, both are probably fine, but I’ll go with the geodesic.

``````g = Geodesic.WGS84.Inverse(lat1,long1, lat2, long2, outmask=1929)
print g.azi2
``````

I still need either a filter or the ability to pull a value from the IMU (which shouldn’t jump around as much)

The problem is that point to point calculations will give you your course, not your heading! For some of us, heading is very important and often quite different to the course. As an example, consider a boat travelling across a current or the wind, or a boat turning corners. I really, really want the data from the integrated IMU - heading especially, but also pitch and yaw. Any ETA on when we are going to get this, as it has been quite a while now…!

hi exist some way to obtein the heading