# How can i use this formula to obtain distance from home from the data flash log?

Hi all,
I would like to graph my RSSI and distance from home from the data flash log.

How can i use this formula :
sqrt(XKF1.PE^2 + XKF1.PN^2)

to get distance from home?

It would be nice to have this value pre-calculated and ready for selection from the mission planner.Thanks.

1 Like

i can look at adding this, but just note its distance from EKF origin… not home.

2 Likes

That would be great Michael.Even EKF origin is fine.Many thanks!!

1 Like

Or this formula for distance from home?I took this example from Henry’s GitHub for dashware OSD implementation.Not sure this will help to implement as I have no expertise to read and understand it.It just looks like a trigonometric formula to me but don’t know how it’s derived ## Distance from Home

Since ArduPilot does not provide this as a logged value, once you have created the .CSV file, you will need to add a column next to the GPS Lat/Lon column labeled “Home_Dist” and at the first row with a value, add something like this for the Home_Dist calculation for row 18, with GPS Lat and Lon in columns H and I,and home value in row 8,for example:

`=IF (I18 = "", "",ACOS( SIN(\$H\$8*PI()/180)*SIN(H18*PI()/180) + COS(\$H\$8*PI()/180)*COS(H18*PI()/180)*COS(I18*PI()/180-\$I\$8*PI()/180) ) * 6371000)`

where the home lat long is in H8/I8 (or change to whatever row has the home gps value after lock) and then fill the column downward with this formula in order to compute each GPS entry into a distance (in meters) from home. Note: you wont see this formula in the example file, since its already been converted back to CSV."

1 Like

Thanks a lot Michael for adding this feature!! Its going to be quite useful in plotting distance vs RSSI.

I found there are 2 options for the same graphs.