gyro, accelerometer, magnetometer and Kalman filter - filter

I want to use gyro, accelermeter and magnetometer to get a full smooth rotation in 3 axis.
The first problem is that my outputs individualy has very noise and I want to know how can I remove it.
The second problem is the gyro drift that I think it should solve with Kalman filter.
The third problem is the accelerometer. If I combine the gyro and accelermeter when I move the device without rotating the device the output will change. Is Kalman filter can remove the moving effect from output too?

the first problem is that my outputs individualy has very noise and i want to know how can i remove it.
Yes, that is natural, do not worry, you can remove the noise.
the second problem is the gyro drift that i think it should solve with kalman filter.
Yes, Kalman filter is one way to go. You may find these answers useful:
Sensor fusioning with Kalman filter
Combine Gyroscope and Accelerometer Data
the third problem is the accelerometer.if i combine the gyro and accelermeter when i move the device without rotating the device the output will change.
I am not sure I understand that correctly. If you have magnetometer Kalman filter can remove the gyro drift even if you are not rotating the device. Is that what you are asking?
EDIT: Depending on your application, you can assume that the acceleration is zero on average. Read this, especially page 24:
http://gentlenav.googlecode.com/files/DCMDraft2.pdf
I use this assumption in my application for human motion sensing and it works perfectly.

Related

Multiple Tangos Looking at one location - IR Conflict

I am getting my first Tango in the next day or so; worked a little bit with Occipital's Structure Sensor - which is where my background in depth perceiving camera's come from.
Has anyone used multiple Tango at once (lets say 6-10), looking at the same part of a room, using depth for identification and placement of 3d character/content? I have been told that multiple devices looking at the same part of a room will confuse each Tango as they will see the other Tango's IR dots.
Thanks for your input.
Grisly
I have not tried to use several Tangos, but I have however tried to use my Tango in a room where I had a Kinect 2 sensor, which caused the Tango to go bananas. It seems however like the Tango has lower intensity on its IR projector in comparison, but I would still say that it is a reasonable assumption that it will not work.
It might work under certain angles but I doubt that you will be able to find a configuration of that many cameras without any of them interfering with each other. If you would make it work however, I would be very interested to know how.
You could lower the depth camera rate (defaults to 5/second I believe) to avoid conflicts, but that might not be desirable given what you're using the system for.
Alternatively, only enable the depth camera when placing your 3D models on surfaces, then disable said depth camera when it is not needed. This can also help conserve CPU and battery power.
It did not work. Occipital Structure Sensor on the other hand, did work (multiple devices in one place)!

Filtering rotational acceleration (Appropriate use for Kalman filter?)

I'm working on a project in which a rod is attached at one end to a rotating shaft. So, as the shaft rotates from 0 to ~100 degrees back-and-forth (in the xy plane), so does the rod. I mounted a 3-axis accelerometer at the end of the moving rod, and I measured the distance of the accelerometer from the center of rotation (i.e., the length of the rod) to be about 38 cm. I have collected a lot of data, but I'm in need of help to find the best method to filter it. First, here's a plot of the raw data:
I think the data makes sense: if it's ramping up, then then I think at that point the acceleration should be linearly increasing, and then when it's ramping down, it should linearly decrease. If its moving constantly, the acceleration will be ~zero. Keep in mind though that sometimes the speed changes (is higher) from one "trial" to the other. In this case, there were ~120 "trials" or movements/sweeps, data sampled at 148 Hz.
For filtering, I've tried a low pass filter and then an exponentially decreasing moving average, and both plots weren't too hot. And although I'm not good at interpreting these: here is what I got when coding a power frequency plot:
What I was hoping to get help with here is, attain a really good method by which I can filter this data. The one thing that keeps coming up again time and time again (especially on this site) is the Kalman filter. While there's lots of code online that helps implementing these in MATLAB, I haven't been able to actually understand it that great, and therefore neglect to include my work on it here. So, is a kalman filter appropriate here, for rotational acceleration? If so, can someone help me implement one in matlab and interpret it? Is there something I'm not seeing that may be just as good/better that is relatively simple?
Here's the data I'm talking about. Looking at it more closely/zooming in gives a better appreciation for what's going on in the movement, I think:
http://cl.ly/433B1h3m1L0t?_ga=1.81885205.2093327149.1426657579
Edit: OK, here is the plot of both relavent dimensions collected from the accelerometer. I am neglecting to include the up and down dimension as the accelerometer shows a near constant ~1 G, so I think its safe to say its not capturing much rotational motion. Red is what I believe is the centripetal component, and blue is tangential. I have no idea how to combine them though, which is why I (maybe wrongfully?) ignored it in my post.
And here is the data for the other dimension:
http://cl.ly/1u133033182V?_ga=1.74069905.2093327149.1426657579
Forget the Kalman filter, see the note at the end of the answer for the reason why.
Using a simple moving average filter (like I showed you on an earlier reply if i recall) which is in essence a low-pass filter :
n = 30 ; %// length of the filter
kernel = ones(1,n)./n ;
ysm = filter( kernel , 1 , flipud(filter( kernel , 1 , flipud(y) )) ) ;
%// assuming your data "y" are in COLUMN (otherwise change 'flipud' to 'fliplr')
note: if you have access to the curvefit toolbox, you can simply use: ys = smooth(y,30) ; to get nearly the same result.
I get:
which once zoomed look like:
You can play with the parameter n to increase or decrease the smoothing.
The gray signal is your original signal. I strongly suspect that the noise spikes you are getting are just due to the vibrations of your rod. (depending on the ratio length/cross section of your rod, you can get significant vibrations at the end of your 38 cm rod. These vibrations will take the shape of oscillations around the main carrier signal, which definitely look like what I am seeing in your signal).
Note:
The Kalman filter is way overkill to do a simple filtering of noisy data. Kalman filter is used when you want to calculate a value (a position if I follow your example) based on some noisy measurement, but to refine the calculations, the Kalman filter will also use a prediction of the position based on the previous state (position) and the inertial data (how fast you were rotating for example). For that prediction you need a "model" of the behavior of your system, which you do not seem to have.
In your case, you would need to calculate the acceleration seen by the accelerometer based on the (known or theoretical) rotation speed of the shaft at any point of time, the distance of the accell to the center of rotation, and probably to make it more precise, a dynamic model of the main vibration modes of your rod. Then for each step, compare that to the actual measurement... seems a bit heavy for your case.
Look at the quick figure explaining the Kalman filter process in this wikipedia entry : Kalman filter, and read on if you want to understand it more.
I will propose for you low-pass filter, but ordinary first-order inertial model instead of Kalman. I designed filter with pass-band till 10 Hz (~~0,1 of your sample frequency). Discrete model has following equation:
y[k] = 0.9418*y[k-1] + 0.05824*u[k-1]
where u is your measured vector, and y is vector after filtering. This equation starts at sample number 1, so you can just assign 0 to the sample number 0.

how to make navigation with 3-axis accelerometer and 3-axis gyroscope and gps

as the title stated, I want to make Dead Reckoning with accelerometer and gyroscope. The accelerometer could apply with linear accleration and then used to get velocity by one time integration or get runing distance in the gap of sample time by twice integration. and also I could get changed angle by integration of gyroscope output value. so on the condition of initial position, I can get new postion by DR with distance and angle.
thought is perfect but fact is not so simple. acceleromter and gyroscope is unstable and always affected by temperature or unaligned axis direction. I have know there is one popular method called kalman filter to combined this sensors with gps to protect navigation from noise of output, but I think it's out of my comptent by now.
firstly, I want to know how to remove gravity force which is mixed with real accelerometer ouput?
sencond, how to correct gyroscope error?
the last, how to realize kalman filter with accelerometer, gyroscope and gps?
any suggestion is good to me, if you can give some code that's best of all!
thank you
[edit #2013/12/12]:
I have given up using accelemeter for calculating velocity and distance due to it's big drift. And also the error can become more and more under the influence of double integration. But there is a lucky thing that this work for a car in tis case. so I prefer to select receiving velocity from CAN, it was proven to be more exactly than accelerometer. By now a solution about velocity has been resolved, but the other question is still not sure in my opinion. expect more nice answer.
look here https://stackoverflow.com/a/19764828/2521214
And read the whole thing !!!
including the comments
and view also this http://www.youtube.com/watch?v=C7JQ7Rpwn2k ...
video link is from AlexWien answer in the same thread

Question on tracking a moving ball using Kalman filter

I want to learn to track a moving ball using Kalman filter. Although many tutorial are available, I still have some questions.
If we can extract the ball in each frame of the video sequence, we will know the position of the ball. Then, why do we need to use Kalman fiter anymore? What is the job of Kalman filter here?
Kalman filter: x(k+1) = A.x(k) + B.u(k) + noise
y(k) = C.x(k) + noise
Then, how do we define A, B, C ? suppose we want to track the moving ball?
3 . If we know the previous state x(k-1) and the measurement of the current state y(k), we can compute the estimated state. What is the "measurement" in case of tracking the moving ball?
well basically you use tracking method to follow the ball in your scene. You'd still have to detect the ball in each timestep.
(1)
Assume you come to a point where another ball comes into the scene. So you need to find a method to identify each ball. Make it worse and even let them cross each other or have obstacles in the way which might hide the ball for a little while.
Your tracking method (i.e. Kalman filter) will then continue its movement on the estimated trajectory, based on how the ball has moved before.
So if you just want to know where the ball is in each frame you don't need a tracking method, but if yo uwant to identify and follow one ball you'd need a tracker, i.e. a Kalman filter or for multi-object tracking I'd prefer a Particle Filter (http://en.wikipedia.org/wiki/Particle_Filter).
(2)
Can't help you here right now since I am not too far into the Kalman Filter right now.
But basically A should be the transition matrix from step x(t-1) to x(t) and B should be the reference model. But as I've said if its likely you get more than one ball you might wanna have a look at the particle filter.
(3)
The measurement would be the position you measured on you image. Basically the midpoint of your ball. You'd use this measurement to correct the estimated path. So basically you compare the position the ball should be at at current timestep (depending on it's former movement) with it's actual position.
I hope that helps... if not, keep asking...
I will answer your questions one by one.
The Kalman filter is only used for estimation, it means reducing mistakes. When you are just tracking a single target, such as a ball, if you can detemine the position of the ball in each frame of the image, I think it is not necessary to use Kalman filter. However, in multi-target tracking ,if you need to match the same target in two consecutive frames, using Kalman filter can reduce mistakes.
For the principle of Kalman filter, I am not very clear.
I think "measurement" is the detection of the moving target in the current frame. The detected parameters include the target's centroid position and contour size.
These are my personal opinion. If there are anything wrong, I hope to be corrected.

Kalman filter for car's tracking path

I am having a set of Points like Point(x,y). After the car gone through so many ways in the same road it is almost messing the resulting map. I heard that Kalman filter can make a sigle path from the available paths.
Can any body say how to make it? I am not from computer science. So please explain me about that concept and those matrices. Then I will code them. Please anybody enlighten me about the concept.
As far as I know is the Kalman filter capable to combine several sources of the same information to get a more precise measurement of the observed variable. It could be possible to combine also with the same measruement device measured multiple times.
Here is a good introduction:INTRO, AnotherOne
I don't know if this question is still active, but if your intressted in learning more about the Kalman filter I can strongly recomend this short matlab script. Even if you dont have matlab installed it should be about the simplest example on Kalman your likely to find!
I don't see how exactly a Kalman filter would be applied here.
I would approach this problem either by image processing, so a thick path would be reduced to a thin line or by successive linear regression on the path segments.
You're probably trying to use the detected coordinates of a car, to determine where a road is, when there is no roadmap information available. Trying to create a road when there is no road, right?
The Kalman Filter is meant to smoothen values obtained from a sensor. When a sensor detects a car, the sensor may not give the car's actual position. It will contain some errors in x and y coordinates.
You have to feed these x,y values to the Kalman filter while the data is being obtained from the sensor. Or at least in the correct order that it was obtained from the sensor.
The Kalman filter will give you the estimated values (smoothened values) of x and y positions, which will tell you approximately the correct position of the car.
Assuming that the car is travelling in the middle of the road, these estimated (filtered) x,y values are what you can take as the midpoints of the road.
I saw your question only now. I know it's late, but I hope that helped?

Resources