Kalman filtering - latitude longitude needs to be converted to meters? - gps

I have to implement kalman filtering to filter latitude longitude(from a gps sensor) to get precise position information.
i would be getting distance traveled from a wheel sensor and angle from magnetometer or i can also use gps course from gps sensor. I have latitude longitude in degrees or radians and distance in meters.
So before applying the kalman filtering i need to convert this lat/lon to meters, correct?
With this information i think i can predict using the following equation
x=x+dt*xVelocity;
y=y+dt*yVelocity;
I can calculate velocity using the following formula
xVelocity=distance*cos(angle);
yvelocity=distance*sin(angle);
So the problem here is the conversion. i tried to convert the above lat/lon to UTM and then performed the above calculation and just for testing converted it back to lat and lon to give the desired location but the results seemed wrong
For example-
double latitude=24.55662435;
double longitude=55.3525234;
double north,east;
latLonToUTM(latitude,longitude,&north,&east);
int distance=5;//5 meters
int course=200
double xVel=distance*cos(course);
double yVel=distance*sin(course);
north+=yVel;
east+=xVel;
double nxtLat,nxtLon;
UTMtoLatLon(north,east,&nxtLat,&nxtLon);
double distance=calculateDistace2LatLon(latitude,longitude,nxtLat,nxtLon);// Used online tool to get this distance
double bearing=calculateAnglebetween2LatLon(latitude,longitude,nxtLat,nxtLon);//used online tool to get angle also
here the obtained distance is not 5m and angle is 200..
Since this basic test itself is failing i am yet to go to kalman filtering.
First this conversion should be precise to even go further.
Can someone guide me to which method to use to convert this lat/lon to meters to apply velocity to get nxt meter or location?
Also if there is no need to convert then how can we add the distance travelled which is in meters to this lat lon?

Related

What a set of GPS coordinates means?

I have a set of GPS coordinates 12.9611159,77.6362214. What exactly do these mean? How can I convert them to degrees of longitude and latitude? What formula should I use to get accurate distance between two sets of coordinates when the order of distance is 10km.
Most likely 12.9611159 is the latitude in degrees, 77.6362214 the longitude. In that case, the coordinate is in India. If latitude and longitude are reversed, you end up in the Greenland Sea.
You can easily check this by entering the coordinate pair in the Google maps search box. Google expects latitude first.
For the distance, in python you can easily use the haversine package:
from haversine import haversine
my_coord = (12.9611159,77.6362214)
other_coord = (12.9, 77.6)
distance = haversine(my_coord, other_coord)
This will give you the distance in km.

How to calculate Altitude using GPS latitude and longitude

How to calculate Altitude from GPS Latitude and Longitude values.What is the exact mathematical equation to solve this problem.
It is possible for a given lat,lon to determine the height of the ground (above sea level, or above Referenz Elipsoid).
But since the earth surface, mountains, etc, do not follow a mathematic formula,
there are Laser scans, performed by Satelites, that measured such a height for e.g every 30 meters.
So there exist files where you can lookup such a height.
This is called a Digital Elevation Modell, or short (DEM)
Read more here: https://en.wikipedia.org/wiki/Digital_elevation_model
Such files are huge, very few application use that approach.
Many just take the altidude value as delivered by the GPS receiver.
You can find some charts with altitude data, like Maptech's. Each pixel has a corresponding lat, long, alt/depth information.
As #AlexWien said these files are huge and most of them must be bought.
If you are interest of using these files I can help you with a C++ code to read them.
You can calculate the geocentric radius, i.e., the radius of the reference Ellipsoid which is used as basis for the GPS altitude. It can be calculated from the the GPS latitude with this formula:
Read more about this at Wikipedia.

Formula/algorithm to offset GPS coordinations

I have GPS coordinates provided as degrees latitude, longitude and would like to offset them by a distance and an angle.E.g.: What are the new coordinates if I offset 45.12345, 7.34567 by 22km along bearing 104 degrees ?Thanks
For most applications one of these two formulas are sufficient:
"Lat/lon given radial and distance"
The second one is slower, but makes less problems in special situations (see docu on that page).
Read the introduction on that page, and make sure that lat/lon are converted to radians before and back to degrees after having the result.
Make sure that your system uses atan2(y,x) (which is usually the case) and not atan2(x,y) which is the case in Excell.
The link in the previous answer no longer works, here is the link using the way back machine:
https://web.archive.org/web/20161209044600/http://williams.best.vwh.net/avform.htm
The formula is:
A point {lat,lon} is a distance d out on the tc radial from point 1 if:
lat=asin(sin(lat1)*cos(d)+cos(lat1)*sin(d)*cos(tc))
IF (cos(lat)=0)
lon=lon1 // endpoint a pole
ELSE
lon=mod(lon1-asin(sin(tc)*sin(d)/cos(lat))+pi,2*pi)-pi
ENDIF
This algorithm is limited to distances such that dlon <pi/2, i.e those that extend around less than one quarter of the circumference of the earth in longitude. A completely general, but more complicated algorithm is necessary if greater distances are allowed:
lat =asin(sin(lat1)*cos(d)+cos(lat1)*sin(d)*cos(tc))
dlon=atan2(sin(tc)*sin(d)*cos(lat1),cos(d)-sin(lat1)*sin(lat))
lon=mod( lon1-dlon +pi,2*pi )-pi

GEOS C API - calculating areas with WGS84 coords (SRID=4326)

I create a polygon where each x/y point is WGS84 format
lat/long values.
The polygons are good approximations to circles and sectors of
radius R (each circumference/arc point is a projected lat/long
value of distance R from a centre/apex coordinate - which I have
verified is correct by computing the Haversine distance between
the edge and reference points and getting a value of R back) .
I use GEOSSetSRID(4326) to indicate the coords are WGS84 format.
GEOSGetSRID() confirms the SRID is set.
Use of GEOSArea then gives a value not even remotely close to
the expected value.
I do not see what else I can programmatically do.
If I set the points in cartesian format, and then set the SRID to
4326, will GEOS implicitly convert the polygon points to WGS84 ??
Is the basic GEOS C API incapable of doing the above ??
Dos SRID have no meaning to the API at all ??
Any info/pointers to correct usage/solutions would be much appreciated.
TIA.
The distance that is given is something like degrees between the two points. In actuality, the GEOS API (at least the C++ interface) is units agnostic; the units it gives the distance in is based on whatever you passed in.
In general, multiplying the result you get by 111000 gives you a fairly accurate measurement in meters. For area, you have to do 111000^2.

GPS delta coordinates to meters

Greetings,
I have two coordinates:
(52.4412396, -6.563223)
and
(52.8912397, -6.683669)
The delta is:
(-0.4499999, 0.120446)
The distance moved is:
sqrt((-0.4499999)^2+(0.120446)^2)
=.465840261
How do I convert this to meters?!
I hope someone can help.
Many thanks in advance,
You have mistakenly done the sum of squares on spherical coordinates. Each difference has to be converted to its longitudinal and latitudinal distance before getting the hypotenuse. While latitude converts directly to distance, (each degree is equal to 60 nautical miles) the longitude will only do that at the equator) That means that you have to multiply the above by the cosine of the latitude. Then you can move on to a simple hypotenuse calculation before converting to meters.