Kalman Filter Interpolation - gps

I'm building a system that receives a stream of live GPS coordinates, around every second or two. I would like to smooth out the visualisation of it so that the location doesn't jump too much when there is a less then accurate datapoint. I would also like to visualise the speed of the moving point, not just jump from one to another.
To do it I have implemented a Kalman filter that gets the coordinates and models speed and acceleration. This helps smooth out the curve but the output of a Kalman filter has the same rate of one data point per second. I thought I would be able to interpolate this by running the "predict" part of Kalman filter 60 times per second, while the update part would only be done when a new coordinate arrives.
However, it turns out this results in a non continuous function and there is a visual jump after a new update comes in.
How can I solve this problem? Is there an algorithm that would output a continuous smooth path while feeding it coordinate points?

Related

Calculating heading value in a quad copter

I'm building an autonomous quad copter I'm trying to move the quad to a target GPS co-ordinate, I'm calculating the distance of the target using haversine formula, and now I want to calculate the heading.
For example, I want the quad to turn to the direction of the target and move forward until it reaches the destination (this part is already done).
How do I calculate the yaw so that it turns to the direction of target?
Calculating it using only the GPS co-ordinates is very inaccurate. If I use a magnetometer, the declination angle changes from place to place.
How do I calculate this? How does ardu pilot do this calculation?
One way to develop control algorithms that deal with inaccurate measures is to combine different measures by some sort of filtering. In that sense, your set point reference is built based on both GPS and magnetometer measures.
There are several ways to accomplish this task. Many applications use data fusion based on Kalman Filters. The general idea is that you are going to use a predictor (or state observer) to achieve a better estimate of the heading. I suggest some research on these topics: data fusion, Kalman filtering.
Here is an example:
http://scholarscompass.vcu.edu/cgi/viewcontent.cgi?article=4188&context=etd

Distance estimation based on signal strength

I have set of data which includes position of a car and unknown emitter signal level. I have to estimate the distance based on this. Basically signal levels varies inversely to the square of distance. But when we include stuff like multipath,reflections etc we need to use a diff equation. Here come the Hata Okumura Model which can give us the path loss based on distance. However , the distance is unknown as I dont know where the emitter is. I only have access to different lat/long sets and the received signal level.
What I am asking is could you guys please guide me to techniques which would help me estimate the distance based on current pos and signal strength.All I am asking for is guidance towards a technique which might be useful.
I have looked into How to calculate distance from Wifi router using Signal Strength? but he has 3 fixed wifi signals and can use the FSPL. However in an urban environment it doesnot work.
Since the car is moving, using any diffraction model would be very difficult. The multipath environment is constantly changing due to moving car, and any reflection/diffraction model requires well-known object geometry around the car. In your problem you have moving car position time series [x(t),y(t)] which is known. You also have a time series of rough measurement of the distance between the car and the emitter [r(t)] of unknown position. You need to solve the stationary unknown emitter position (X,Y). So you have many noisy measurement with two unknown parameters to estimate. This is a classic Least Square Estimation problem. You can formulate r(ti) = sqrt((x(ti)-X)^2 + (y(ti)-Y)^2) and feed your data into this equation and do least square estimation. The data obviously is noisy due to multipath but the emitter is stationary and with overtime and during estimation process, the noise can be more or less smooth out.
Least Square Estimation

Paraview. Volume fraction and/or mass flow rate

My goal is to achieve something that was previously asked in this site (outside from SO). In this external site the questions is unanswered, and in order to give more visibility and to try to get an answer I translate it to here:
The issue is:
I have a small simulation of particles flowing through a wire mesh structure, and I'm interested in calculating the mass flow rate and volume fraction of particles at certain cross sections. I think I understand how to calculate mass flow rate by setting up small regions and dumping particle count and velocity from that region. I assume that volume fraction works in a similar fashion, except I only need to know the size of my particles and my dump region.
What I'm wondering is this - is it possible to do these things in Paraview? I can set up planes and slices and such, but I can't seem to extract much useful information out of them.
Further on down the road, what I would like to do would be to plot contours of volume fraction at certain planes, and plot the volume fraction along the vertical axis so I can see how high the particles are piling up on top of the screen, based on particle size, wire size, etc. Can Paraview do any of this?
This is a visualization issue. I don't know how make it with Paraview. The idea is count how much particles cross the slice.
My first approach was piped: DataReader | Spherical Glyph | Slice with normal fixed handly along z axis but nothing results. Also I tried to adding the filter Surface Flow and nothing too. Probably I am piping the data in a bad way.
To see the pipelining process I add an image (focus in PlotOverLine1 and its above pipes):

Approximate and Interpolate GPS Trajectory

I have a sequence of gps values each containing: timestamp, latitude, longitude, n_sats, gps_speed, gps_direction, ... (some subset of NMEA data). I'm not sure of what quality the direction and speed values are. Further, I cannot expect the sequence to be evenly spaced w.r.t. the timestamp. I want to get a smooth trajectory at an even time step.
I've read the Kalman Filter is the tool of choice for such tasks. Is this indeed the case?
I've found some implementations of the Kalman Filter for Python:
http://www.scipy.org/Cookbook/KalmanFiltering
http://ascratchpad.blogspot.de/2010/03/kalman-filter-in-python.html
These however appear to assume regularly spaced data, i.e. iterations.
What would it take to integrate support of irregularly spaced observations?
One thing I could imagine is to repeat/adapt the prediction step to a time-based model. Can you recommend such a model for this application? Would it need to take into account the NMEA speed values?
Having looked all over for an understandable resource on Kalman filters, I'd highly recommend this one: https://github.com/rlabbe/Kalman-and-Bayesian-Filters-in-Python
To your particular question regarding irregularly spaced observations: Look at Chapter 8 in the reference above, and under the heading "Nonstationary Processes". To summarize, you'll need to use a different state transition function and process noise covariance for each iteration. Those are the only things you'll need to change at each iteration, since they're the only components dependent on delta t.
You could also try kinematic interpolation to see if the results fit to what you expect.
Here's a Python implementation of one of these algorithms: https://gist.github.com/talespaiva/128980e3608f9bc5083b

Algorithm for reducing GPS track data to discard redundant data?

We're building a GIS interface to display GPS track data, e.g. imagine the raw data set from a guy wandering around a neighborhood on a bike for an hour. A set of data like this with perhaps a new point recorded every 5 seconds, will be large and displaying it in a browser or a handheld device will be challenging. Also, displaying every single point is usually not necessary since a user can't visually resolve that much data anyway.
So for performance reasons we are looking for algorithms that are good at 'reducing' data like this so that the number of points being displayed is reduced significantly but in such a way that it doesn't risk data mis-interpretation. For example, if our fictional bike rider stops for a drink, we certainly don't want to draw 100 lat/lon points in a cluster around the 7-Eleven.
We are aware of clustering, which is good for when looking at a bunch of disconnected points, however what we need is something that applies to tracks as described above. Thanks.
A more scientific and perhaps more math heavy solution is to use the Ramer-Douglas-Peucker algorithm to generalize your path. I used it when I studied for my Master of Surveying so it's a proven thing. :-)
Giving your path and the minimum angle you can tolerate in your path, it simplifies the path by reducing the number of points.
Typically the best way of doing that is:
Determine the minimum number of screen pixels you want between GPS points displayed.
Determine the distance represented by each pixel in the current zoom level.
Multiply answer 1 by answer 2 to get the minimum distance between coordinates you want to display.
starting from the first coordinate in the journey path, read each next coordinate until you've reached the required minimum distance from the current point. Repeat.