Finding the Lateral Distances between two GPS Points - matlab

I have two Set of GPS Points recorded from High Precision GPS Receivers which travels from Point A to Point B . please see the Image attached.
Black Point is the GPS points of Vehicle 1 and its path... Blue Point is the GPS Points of Vehicle 2 and its path. Vehicle 2 should follow the same path as Vehicle 1 , But there exists some deviation in pratcical scenerios. So. I need to Caluculate how much deviation it has .
I am trying to find the lateral distance between the vehicle 1 and nearest vehicle 2 GPS Point.
What I did till now ?
*) Since vehicle 1 is ahead of vehicle 2 and , vehicle 2 reaches vehicle1 (approx) after some time (say buffer as 5 ~10 seconds )....
I am calculating the arc distance between Vehicle 1 GPS Point and a set of Vehicle 2 GPS Points (buffer) and finding the minimum of those Arc Distances.
*) By finding the Minimum of Arc Distance , I am finding the GPS Point which is nearest to the vehicle 1 GPS Point.. now , I am stuck at finding the Lateral Distance between these two GPS Points in an effecient manner.
Please let me know if u have any questions or comments on my procedure..

I assume both routes start from the same position. so i would do the following:
Resample each route to get a new set of points with a known sampling step from on another (You can interpolate the new points from the old see for example https://www.mathworks.com/matlabcentral/answers/278615-how-to-create-points-set-on-2d-polyline)
Once i have two sets of points that start from the same location and are in a constant sampling step just calculate the distance between each corresponding points.

Related

Question about Matlab's aerospace toolbox's gravitysphericalharmonic library

I'm currently trying to learn how to use the gravity models that Matlab's 'gravitysphericalharmonics' library has. In this documentation: https://www.mathworks.com/help/aerotbx/ug/gravitysphericalharmonic.html#mw_3bdd1e99-46be-4fd5-8b7c-6dd710546616
It gives us two examples:
Calculate the gravity in the x-axis at the equator on the surface of Earth. This example uses the default 120 degree model of EGM2008 with default warning actions.
gx = gravitysphericalharmonic([-6378.137e3 0 0])
Calculate the gravity at 25,000 m over the south pole of Earth.
[gx, gy, gz] = gravitysphericalharmonic([0 0 -6381.751e3],'EGM96','Error')
Here's my question, how did they get -6381.751e3 for the second question if they're just finding the gravity 25,000m above the surface of Earth? If Earth's radius is ~6378.137e3 meters, then calculating the gravity at 25,000m above Earth would just be the radius + 25,000 meters right?
Lastly, I wanted to just ask someone with more knowledge about this module why it was -6378.137e3 m for the first question. If we're taking the coordinate from just the surface of Earth, wouldn't that number have to be positive?
Sorry if this doesn't make any sense, I'm new to this stuff and I really want to learn! Thanks!
The first example uses a 3D position vector, in a coordinate system with its origin at the center of the planet (Earth). The position vector[-6378.137e3 0 0] is on the equator, as is [6378.137e3 0 0] (they are on opposite sides of the world). Any other position vector with magnitude 6378.137e3 and a Z component (the third number) of 0 would also be on the equator.
The Earth is not a perfect sphere; it is an oblate spheroid. The radius at the equator is 6378.137 km, but the radius at the poles is 6356.752 km. Their documentation is not great here, but they have arrived at the position vector in the second example by taking this polar radius and increasing the magnitude of the vector by 15 km. The Z component is negative because this example is at the South Pole; if the Z component were positive, it would be at the North Pole. Because it is negative, they have to add -15 km to get to a point that is 15 km above the surface (but if you were looking at a globe, and holding the globe so that north is up, that point would be below the globe).
They have probably used examples with negative values in the position vector precisely to ensure that people ask themselves the kinds of questions that you are asking.
The aerospace toolbox also provides a function ecef2lla to convert these position vectors into latitude, longitude, and altitude, which may help you understand them.

How to get distance bw 2 points in real world irrespective of diffrence in height?

i am using a pair of DW1000 UWB sensors and am able to get accurate distance bw them.
how can i get rid of (z1-z2) term in the final distance..i.e if both sensors are fixed at (x1,y1)and (x2,y2 ) respectively , how do i ensure that the distance (reported ) states constant even if i move the tags up or down
You need to give the (z1-z2) information to the anchor to calculate the horizontal distance. Use Pythagoras' Theorem. If z1-z2 is unknown, you need more sensors.

SyncStart with Codisys without PLCOPEN Part 4

I need to Approximate A SyncStart/SyncStop Function in Codesys using PLCOPEN. I don't have access to Part 4 that contains the Synchronized motion stuff. Any ideas on how to start down the right path this in ST would be Awesome.
Like you said there is not a syncstart/syncstop in this version of codesys. If I were you I would
find which axis of motion has the longest distance to travel
find the total time it takes for that axis to travel that distance at its max velocity
find the time it takes for every axis you want to sync
get the ratio of the time for each axis over the time of the longest travel time
multiply that ratio to velocity, accel,decel, and jerk for the corresponding axis.
That will get you pretty darn close.

How do I calculate the distance to the nearest point along a path?

I am looking for how to calculate the distance along a path in a binary array.
I imported a map as a matrix in matlab. There is a binary image of a river crossing two cities. I only found out how to calculate the distance from the river points to the nearest city but I don't manage to compute the shortest distance along the river.
I made a vector with the indices of all river points but I don't know how to get the distance to the nearest city from that...
Image
So I am looking for the shortest distance through the red line towards one of the light blue points it crosses !
Thnx
If I understand you in the right way it is not very difficult: Just do a dfs or bfs (8-neighbourhood) starting at each river-town and add sqrt(2) if you go diagonal and 1 if you go to a 4-neighbour. At each river pixel you can finally decide by taking the minimum value. You can develop it further stopping at river pixels with already smaller distance to another city...
I really hope I got you in the right way :)

Accuracy of Distance between two lat long ios

I am calculating the distance between two lat long coordinates using -(CLLocation)distanceFomLocation:(CLLocation) and Haversine formula. But its not giving the correct result.
I am using core location framework to find out the lat long of two posions which are 1 meter apart in actual but the above formula gives the distance some times 40m sometimes 30m and so on. I have set the desired accuracy is ten meters. I am using iPhone 4s device.
Just want to know that what is accuracy of method -(CLLocation)distanceFomLocation:(CLLocation) for calculating the distances? I have to calculate the distances whth in 10 m range.
The formula is correct, for 1m distance the acuarcy is under 1/1000 of milimeter. That what is wrong is your lat/lon position you got from the GPS device, which can deviate that 40m.
For 10m distance the formula used in either haversine or distanceFromLocation are perfectly accurate. It starts to get interesting when distances are some kilometer apart.
So don't worry. But yor main problem is to get such acurate positions, and that depends what you need it for.
Do you need distance meassure of the coordinates of ONE GPS device, (that works) or between differnet GPS devices (can be appart 30m for two device on same position, but usually 3-6m GPS accuracy when having good view to open sky.
Further make sure that you use desiredAccuracy BestForNavigation or Best.