DSPRelated.com
Forums

kalman filter to improve the gps data received from an iPhone

Started by andreivig May 25, 2010
On 05/26/2010 01:23 AM, claudegps wrote:
> On 26 Mag, 09:00, "andreivig"<vig.andrei@n_o_s_p_a_m.gmail.com> > wrote: >> On an iPhone I have a GPS and 3 axis accelerometer. I can also get the >> heading. I use the GPS data for my navigation, but as I said this is >> sometimes really bad. Sometimes I receive a position with an error within >> 100 to 400 meters. >> >> Is there any algorithm that I could use to optimize/smoothen this data? > > Maybe that you can just try to filter out the "bad" fixes by looking > at the solution status. > If you can have access to GPS data like N. of satellites used in the > solution, their CN0 and DOPs you can determine which fixes have a good > probability to be accurate and which ones have a really poor accuracy > (few satellites, low CN0s, high DOPs) >
Any halfway decent GPS receiver will already do that. And GPS receivers are _terrible_ at figuring out their DOP from multipath effects -- they can easily get confused by reflections and have you teleporting over 100 meters sideways, up, or down. Without an independent measurement of some sort there's just not information there to filter out. (Note that a surveyor's GPS _does_ get independent information -- you set it down, and you push a button that basically tells the GPS that it isn't moving. Then, because it _knows_ it isn't moving, it makes a more-accurate estimate of position). -- Tim Wescott Control system and signal processing consulting www.wescottdesign.com
[cut]
> > Maybe that you can just try to filter out the "bad" fixes by looking > > at the solution status. > > If you can have access to GPS data like &#4294967295;N. of satellites used in the > > solution, their CN0 and DOPs you can determine which fixes have a good > > probability to be accurate and which ones have a really poor accuracy > > (few satellites, low CN0s, high DOPs) > > Any halfway decent GPS receiver will already do that. &#4294967295;And GPS receivers > are _terrible_ at figuring out their DOP from multipath effects -- they > can easily get confused by reflections and have you teleporting over 100 > meters sideways, up, or down.
It depends: the receiver can easily determine it's status (DOPs, CN0, residuals ecc...) and decide to invalidate the solution. But... it maybe just working in way that is "just give out what you have, whatever it is", without discarding any fix even if it's very bad. This approach is often used in mobile phones where you privilege the location avalability instead of the general accuracy.
> Without an independent measurement of some sort there's just not > information there to filter out.
You could filter bad fixes and take into account only the fixes you define as good (Max DOP, Min CN0, min N of sats used in solution ecc...). Of course, the price is that you have less availability of the navigation solution. The accelerometer could be used in some ways to give an independent measurement of the dynamics, but should be done in "thigly coupled" way. Not just using GPS solution as Lat/lot/alt information (PVT solution...)
On 05/25/2010 07:28 AM, andreivig wrote:
> Hi, > > I am currently working on an navigation application for an iPhone device. > The GPS data that I receive is not very accurate and I want to use a kalman > filter. The problem is that I don't really know how to build the kalman > equations for x and y coordinates. What kind of model should I use?
I just realized that I left out my intuitive explanation of why a coupled IMU/GPS solution works, and why a Kalman filter helps. A GPS receiver generally does a really good job of delivering a position solution that is correct _on average_. In other words, if you have a reasonably clear sky, and you set the receiver down in one spot where it won't move, you can average a bunch of position estimates from the receiver and get down to millimeter accuracy. This is far more reliable if you have clear sky in all directions, but you can still do pretty well if there aren't too many confounding reflections. (obviously it won't work at all if you're in deep forest or underground or some other situation where you can't receive satellite data). But a GPS receiver is fairly poor at telling you where you are from moment to moment. The position estimate jumps around, and for most GPS receivers it does so more when it is being moved. A six-axis IMU, i.e. three accelerometers and three gyros, does a really good job of telling you what's happening _this instant_ -- it measures acceleration and rotation, after all, which are second and first derivatives, respectively, of physical and angular position. Theoretically, if you start with a perfect IMU and a perfect model of the earth's gravity and motion, you can navigate all over the world, endlessly, with just IMU data. In practice, the IMU has its own noise and bias and drifts, so it doesn't work so well. But for any given IMU you can always _start_ at a known position, velocity and orientation, and for some amount of time that varies depending on how good the IMU is, you can keep track of your position, velocity, and orientation. The problem is that the worse (and less expensive) that the IMU is, the sooner you completely lose track. So the GPS is really good with slow position measurements, and the IMU is really good with fast position measurements. What a Kalman filter lets you do is to take the "GPS is good at slow" and "IMU is good at fast" and put them together. It merges the data, smooths out the bumps, and gives you an overall system that's better (perhaps far better) than the GPS for instantaneous positions, and that's always far better than the IMU for long-term positions. So there's no magic involved -- the Kalman filter is just letting already-existing capabilities work together. Conversely, in the case of the iPhone you only have a three-axis IMU, and insufficient compass resources to tell which way vertical lies. Without knowing the orientation of an accelerometer you have no way of knowing your own acceleration in any absolute sense. As an example, if the accelerometer reads 9.8m/s^2 in a particular direction, you don't know if that means that you're standing still or if you're accelerating downward at 19.6m/s^2, or some combination of forward and downward acceleration. Similarly, if the accelerometer says that you're accelerating at 10.45m/s^2, you don't know if you're staying level and accelerating at 7.35m/s^2 horizontally, or if you're accelerating upward at 2.45m/s^2, or what. So that three-axis IMU is _completely useless_ by itself for inertial navigation. Even if it were perfect -- which it is not -- it is still delivering totally insufficient information for navigation. Given that, there is no filter in the world that will rescue you with just the information from a GPS. Add a good three-axis gyro and you've essentially got a 6-axis IMU. Add a heading and vertical reference, and you're all set -- but all reasonable vertical references that work when you're moving need accelerometers. Much as I hate to say it, there is no software solution to this hardware problem. You just can't get there from here, at least without adding more hardware to the solution than is to be found inside of an iPhone. -- Tim Wescott Control system and signal processing consulting www.wescottdesign.com
On May 25, 10:28&#4294967295;am, "andreivig" <vig.andrei@n_o_s_p_a_m.gmail.com>
wrote:
> Hi, > > I am currently working on an navigation application for an iPhone device. > The GPS data that I receive is not very accurate and I want to use a kalman > filter. The problem is that I don't really know how to build the kalman > equations for x and y coordinates. What kind of model should I use?
First thing is to use a gps with WAAS. This helps substantually. Also use one with good sensitivity such as one based on a SIRF chipset. My handheld unit almost always has me to within 10 meters. And it is quite often better than 5 meters. Clay
On 27 Mai, 16:36, Clay <c...@claysturner.com> wrote:
> My > handheld unit almost always has me to within 10 meters. And it is > quite often better than 5 meters.
Eh... how would you know? What do you use for reference? Rune
On 2010-05-27 12:29:32 -0300, Rune Allnor <allnor@tele.ntnu.no> said:

> On 27 Mai, 16:36, Clay <c...@claysturner.com> wrote: >> My >> handheld unit almost always has me to within 10 meters. And it is >> quite often better than 5 meters. > > Eh... how would you know? What do you use for reference? > > Rune
I have heard stories of folks with GPS devices who were driving down a major highway and the device was telling them to take the next exit to get off the service road and onto the highway. Was the map wrong or was the device wrong? I have had several instances of my GPS getting upset with me for driving through the farmers field just because the highway was so new that the map had not yet been updated.
On 05/27/2010 08:34 AM, Gordon Sande wrote:
> On 2010-05-27 12:29:32 -0300, Rune Allnor <allnor@tele.ntnu.no> said: > >> On 27 Mai, 16:36, Clay <c...@claysturner.com> wrote: >>> My >>> handheld unit almost always has me to within 10 meters. And it is >>> quite often better than 5 meters. >> >> Eh... how would you know? What do you use for reference? >> >> Rune > > I have heard stories of folks with GPS devices who were driving down > a major highway and the device was telling them to take the next exit > to get off the service road and onto the highway. > > Was the map wrong or was the device wrong?
(snip) It's fairly common for the GPS to indicate that the car has teleported several meters laterally due to multipath interference. It's a pain to try to compensate for, because the vehicle trajectory looks very believable other than being offset. So it's a tossup, although in the US (and probably Europe) it's rare to have the government's maps messed up, and most mapmakers go from that, so if it's the map it's a transcription error. If the GPS unit paid attention to altitude it'd spend more time advising you to get a shovel and breathing apparatus, or to come in to a safe landing, more than anything else. -- Tim Wescott Control system and signal processing consulting www.wescottdesign.com
On May 27, 11:29&#4294967295;am, Rune Allnor <all...@tele.ntnu.no> wrote:
> On 27 Mai, 16:36, Clay <c...@claysturner.com> wrote: > > > &#4294967295;My > > handheld unit almost always has me to within 10 meters. And it is > > quite often better than 5 meters. > > Eh... how would you know? What do you use for reference? > > Rune
I'm a little wierd. Before I go on hiking trips, I input surveyed point data from national geographic trail maps and then on the hike I see how the unit's result compares. I.e., I look at campsite, stream, trail crossings etc. UTM grids work great for this sort of thing. Also when I did cell tower work for 2 years, I would also compare my unit's results with the official surveyed locations for the towers. Several mountains near me have NGS markers. See http://en.wikipedia.org/wiki/U.S._National_Geodetic_Survey for an example picture. Even the altitudes for the mountains as indicated by the gps come in amazingly close to the official published values. For example the top of Half Dome (in Yosemite National Park) is officially listed at 8842 feet. My unit agreed within 10 feet! To be sure there are times when the unit is fooled such as when you are in a canyon and it is picking indirect signals reflecting off of the canyon walls. This will certainly make your indicated position vary by quite a bit. Clay
On May 27, 11:34&#4294967295;am, Gordon Sande <Gordon.Sa...@gmail.com> wrote:
> On 2010-05-27 12:29:32 -0300, Rune Allnor <all...@tele.ntnu.no> said: > > > On 27 Mai, 16:36, Clay <c...@claysturner.com> wrote: > >> My > >> handheld unit almost always has me to within 10 meters. And it is > >> quite often better than 5 meters. > > > Eh... how would you know? What do you use for reference? > > > Rune > > I have heard stories of folks with GPS devices who were driving down > a major highway and the device was telling them to take the next exit > to get off the service road and onto the highway. > > Was the map wrong or was the device wrong? > > I have had several instances of my GPS getting upset with me for > driving through the farmers field just because the highway was so new > that the map had not yet been updated.
Certainly keeping your maps up to date is important. Garmin usually offers updated maps yearly. And I've seen where the mapping engine is unaware of closed, new or moved roads.I've litterally spent 1000s of hours driving with guidance from gpses. Clay
On 27 Mag, 17:34, Gordon Sande <Gordon.Sa...@gmail.com> wrote:
> On 2010-05-27 12:29:32 -0300, Rune Allnor <all...@tele.ntnu.no> said: > > > On 27 Mai, 16:36, Clay <c...@claysturner.com> wrote: > >> My > >> handheld unit almost always has me to within 10 meters. And it is > >> quite often better than 5 meters. > > > Eh... how would you know? What do you use for reference? > > > Rune > > I have heard stories of folks with GPS devices who were driving down > a major highway and the device was telling them to take the next exit > to get off the service road and onto the highway. > > Was the map wrong or was the device wrong?
Impossible to know. Even if I would bet on the GPS. GPS receiver may be affected by errors, but also the map cannot be considered 100% reliable, especially if not frequently updated.
> I have had several instances of my GPS getting upset with me for > driving through the farmers field just because the highway was so new > that the map had not yet been updated.
Yes... old maps may lead your navigation system to mistakes because it also uses map-matching.