Show Posts
Pages: [1] 2
1  Topics / Robotics / Re: IMU Filtering on: August 07, 2011, 05:06:48 am
I actually made a similar function when I first started working on this. It hade accelerometers and gyro, and i trusted the gyro reading at all times. When the accelerometers had a steady reading I used that to correct the gyro angle. That works great actually, but since I was going to use it for a quadcopter, the dynamic acceleration(not vibration noise but the vessel accelerating) caused this filter to be useless. for a balancing robot on the other hand, it would be great.

I posted a thread on this on the old forum.

Here is a RTR kalman filter(its simple, but it works great and has a great response time).,52717.0.html

The kalman filter actually solves your problem, determining the averaging factor for you. The good thing about this is that it recalculates them continously. A weighted average with fixed weights would never be as good as a adaptive one, so why struggle.
2  Topics / Robotics / Re: Balancing robot for dummies on: August 07, 2011, 04:25:12 am
If you look at the "opening" in the chest area, you can clearly see the "gyro" accelerating to counteract the grativtational forces making it tilt.
3  Topics / Robotics / Re: Kalman filter function on: March 25, 2011, 02:25:08 pm
Uhm... "dt" is the delta time value. ie. the cycle time. its determined by the time the program uses to run the program one cycle. a good way to determine it is:

int time, oldTime, dt = 0; //declare once

//put in loop()
oldTime = time;
time = millis();
dt = time - oldTime;

Ive used it in a balancing robot app that is not yet ready. Ive put it on hold due to temporary lack of interest.

Its very important that you tune the filter properly for it to work. I did this by logging gyrorate, accelerometer angle and dt on the computer(using serial monitor and copy paste). then i wrote the filter in matlab and ran it multiple times while tuning the parameters in between. when you plot it to graph it is much easier to see the effect of the filter.

hope this helps! if not, try to reformulate the question and i'll try to answer again smiley-razz


4  Topics / Robotics / Re: Kalman filter function on: February 18, 2011, 05:30:41 pm
Here is the link to Tom's tutorial. lots of great stuff on his site.


It would be great if anyone who uses it give some feedback or comment on it to make it easier for the next to impelement in their code.
5  Topics / Robotics / Kalman filter function on: February 18, 2011, 01:07:01 pm
Ive made a kalman filter function based on Tom Pyckes tutorial. Read the tutorial first, it will be easier to understand the function. The function lets you use the kalmanfilter on multiple axis. It works great, but youre gonna have to tune it to your application and IMU's(EDIT: to tune the filter you just change the values Sz and Sw. in the code you see Sz as 0.01 and Sw as 0.0000001 and 0.0000003(se Toms tutorial for explanation of these)).


double x[2][2];
double xv[2][2];
double p[2][4];
double pv[2][4];
double k[2][2];
double Inn[2];
double s[2];
double Sz = 0.01; // was 17.2 for dt =10. Sz is lower the higher delta time.

double KalmanFilter(int a, double y, double u){
x[a][1] = u+x[a][1]-dt*x[a][2];
x[a][2] = x[a][2];

Inn[a] = y-x[a][1];

s[a] = p[a][1]+Sz;

k[a][1] = (p[a][1]-dt*p[a][3])/s[a];
k[a][2] = p[a][3]/s[a];

xv[a][1] = x[a][1]+k[a][1]*(y-x[a][1]);
xv[a][2] = x[a][2]+k[a][2]*(y-x[a][1]);

x[a][1] = xv[a][1];
x[a][2] = xv[a][2];

pv[a][1] = 0.0000003+p[a][1]-k[a][1]*p[a][1]+dt*k[a][1]*p[a][2]-dt*p[a][3]-dt*(p[a][2]-dt*p[a][4]);
pv[a][2] = p[a][2]-k[a][1]*p[a][2]-dt*p[a][4];
pv[a][3] = dt*k[a][2]*p[a][2]+p[a][3]-dt*p[a][4]-k[a][2]*p[a][1];
pv[a][4] = 0.00000001-k[a][2]*p[a][2]+p[a][4];

p[a][1] = pv[a][1];
p[a][2] = pv[a][2];  
p[a][3] = pv[a][3];
p[a][4] = pv[a][4];

return x[a][1];


on top, you see the variables declared as field. you might declare them inside the function frame but make sure to make then "volatile". Kalman filter is a statistical optimal estimator so you need the previous values to make new ones.

a is the axis number(if you only have one axis, it would be "a=0")
y is the angle from the accelerometers
u is the gyro rate

In addtition to these you need a cycle time variable which Ive called dt.

Feel free to use it out of the box.
6  Topics / Robotics / Re: Cam and Arduino Duemilanove project on: February 17, 2011, 05:13:55 pm
If its fast enough, you might be able to use one of these(or similar)!

It allows you to read/write many pins using a few.
7  Using Arduino / Interfacing w/ Software on the Computer / Re: Processing question on: February 03, 2011, 01:59:05 pm
Thanks Olly. Thats all I needed to hear  =)
8  Using Arduino / Interfacing w/ Software on the Computer / Processing question on: February 02, 2011, 02:57:15 am

Does processing leave you with a runnable file(like java.jar or C#.exe), or do you always have to have the processing IDE available to execute programs ?

I've only used processing once, and at that point I did'nt need to run it without processing IDE, so i never checked.

9  Forum 2005-2010 (read only) / Syntax & Programs / Re: Copter with Gyro stabilization. on: November 17, 2009, 03:53:18 am
simple question now: I have a small electric helicopter that heeps iself pretty level with no help from me.  Just balanced and it hangs from the rotors I guess.  Is there anything in that?

I think you are right. it also have the tail rotor to keep it from spinning the opposite way of the rotor. that same rotor can turn the copter around its own axis(which goes through the center of the lift rotor).

This post might get more responses in a hardware area by the way - not sure how you'd get it moved though.

I think i've found a way, so I don't really need help no more. I think.
Can just leave the post open, just in case anyone have something.
Thanks for your help.

I can not believe the stuff you can buy these days!  You probably know you can buy two axis gyros from sparkfun but i would never have dreamed it.  In their writeup it ref's RC helicopters so it must be a well-known application.  Maybe you could fire a question to their customer support or see if they have a forum you could post in.

That is one cheap gyro. but looks like it does'nt got any electronics on it. then its worth paying a couple of dollars extra to get it all on one board. But thanks. It would have been great to use with the project:D

10  Forum 2005-2010 (read only) / Syntax & Programs / Re: Copter with Gyro stabilization. on: November 16, 2009, 07:37:15 am
thaks for answering.

14 kg is like an assumtion of what the actual throttle is going to be. 3.3*4 is actually 13.2kg. that is with an ideal propellar and ideal powersupply(LiPo batteries).
I guess the frame size will be 75-100 cm across. i guess probably something like 75cm*75cm.

I was playing with the thought of using accelerometers, but since this is a dynamic object, which has an dynamic acceleration in addition to the "acceleration" the tilt wil give out, i would rather just use something to measure just the angles. an accelerometer will probably be used to measure the initial angles of the copter, because the intergrated gyro will have a logical 0 angle at the initial state of the copter. so if the copter is not totally horizontal both axes, it wont know what is horizontal.

I really suck at explaining so sorry if it makes no sense.
11  Forum 2005-2010 (read only) / Syntax & Programs / Copter with Gyro stabilization. on: November 13, 2009, 05:47:59 am
I'm planning a new project. I'm planning to make a 4 motor, 2 axis copter(like the silverlit x-ufo).
I've ordered in one motor, esc and connectors, just to see if i can get enough throttle.
Theoratically, I should get a total of 14 kg throttle(3.3kgx4motors). I've come up with a couple of problems of which I have to solve. Havent got any parts yet.
Using a gyro with a numeric integrator i would, i think, get a drift, because the sample-period would be to long. but I don't know for sure.
It will be a fairly large program, so I guess the sample time would be even greater than e forsee.

Most of the problems are already solved, but the tilt-measuring is still a problem.

Anyone have a suggestion of what to do ?
If there is a different hardware for tilt measurement, I am all ears.
If not, how do i get a gyro to measure the correct angle over a longer periode of time. with no drift.
numeric integrator:
angle = angle + W*sampletime; //W = angle-velocity.
values in the integrator will be scaled, so that 0 degrees = 0, and a positive angle gives positive W, and negative angles give a negative W. so that 0 degrees ---> angle = 0.

Thanks for all help. Daniel.
12  Forum 2005-2010 (read only) / Interfacing / Re: XV-3500CB, Sure electronics. on: December 16, 2009, 12:06:19 pm
Would I get the values i want if i get the data using the IIC protocol ? Or would the data have the same wierd scaling ?
13  Forum 2005-2010 (read only) / Interfacing / XV-3500CB, Sure electronics. on: December 14, 2009, 02:20:21 pm
I have a problem measuring angle using the XV-3500CB (w/breakpout) angular rate sensor(gyroscope).
The static voltage output is 1350mV(as it says in the datasheet).

It seems to have a have a different voltage output CCW and CW with the same angular rate(w), so that when i integrate the readings, the drift is like 20%+ 90 degrees and back.

Anyone have any experience with this gyro or have had a similar problem with different hardware ? I guess it might be possible(if the difference CW and CCW is linear) to just scale it. I should have bought a different one i know, but it was just for testing, and it was cheap.(don't think about the integrator drift, as the cycle time was 10ms, and angular rate was sloooow smiley-razz  )

All help appriciated.


EDIT: I have scaled the analog read so that when w = 0, the reading is 0(so it wont have a contribution to the integral, and the ccw rotation will be negative, and cw is positive).
14  Forum 2005-2010 (read only) / Exhibition / Re: Orientation without kalman filter. on: April 30, 2010, 08:00:33 am
procreating shit. the shit wont procreating work.

the "filter" needs sudden changes to work. if the changes come over time, it wont do shit. it responds very well to vibrations and such, but long time steady movements it cant tell is noise.


if you are making a procreating balancing robot, use it. if not, procreate it.

i'm pissed. I'm going to need the kalman filter after all. if anyone have a kalman filter that I can use(angle + angular rate fusion) please let me know. I can adapt it and tune it myself.
15  Forum 2005-2010 (read only) / Exhibition / Re: Orientation without kalman filter. on: April 27, 2010, 02:43:38 pm

why do I need it... why would you have 500 bhp in a car. just for fun. also, it is usually better to have to much, than to little. power that is.
I should post a video. but i dont have a camera yet. e mobile camera video would just be annoying.


it seems you put some thought into this while writing. i like ideas, but i think a nitro Quad would be way more expensive and more problematic to build and program(due to extra noise filtering aso).

the best way to do this, i think, would be to use ONE oversized motor, with 4 drive shafts, one to each arm, powering 4 variable pitch propellers. so that you would adjust the lift on each arm with pitch instead of RPM. not to easy to accomplish i  think.


the build is interesting, but in no way important. mount them together. make the angles straight. thats it smiley-grin all unforseen problem you're gonna have to solve on the go.
the video is hard to make happen due to lack of camera. As soon as i get it up in the air i'll get a camera smiley-grin
Pages: [1] 2