Discussion building quad-rotor heli from scratch

 #1 haobuhao Dec 13, 2007 11:38 AM

I have the gizmo basically built - 4 rotors, carbon fiber and aluminum frame.
Electronics consist of 3 single axis gyros and 1 triple axis accelerometer hooked up to an atmega168 controller. I've written my kalman filter code so that from the gyro and accel I can get a roll and pitch estimate. For the yaw estimate, I basically integrate the angle seen over time.

I've read a lot of interesting papers from all over the world that discuss the flight control of the quadrotor. I will try to summarize what I want to do below.

If the motor is configured like so:

leftfront rightfront

leftback rightback

leftfront and rightback share rotational direction, and leftback and rightfront share the opposite direction.

I can see how to easily use the kalman estimates to send offsets to the pair of motors to balance them out. But, I have yet to wrap my head around how to balance each motor individually within its pair set. For example, if leftfront is slightly stronger than rightback, there will be some rotation if they continue to receive the same offset. Is there an algorithm to programmatically calculate their strength difference while in flight?

My next algorithm I need verification on is the following. If I am controlling the device, I will be able to send it the following factors: thrust, yaw, roll, and pitch (from a radio or through a script). I would be sending the following to the motors:

leftfront = thrust + pitch - yaw
rightfront = thrust - roll + yaw
leftback = thrust + roll + yaw
rightback = thrust - pitch - yaw

Now, I would like to integrate my kalman estimates. I can't seem to wrap my head around this. Should I be applying my kalman estimates while the motors are being actuated by the radio/script? Or should I wait to apply my offsets after the actuation is complete? For example, if the motors are to be actuated for 30deg of roll, it takes X amount of time to complete that motion to get to 30deg. In that amount of time and after completing the motion to get to 30deg, my controller is calculation kalman estimates at 60Hz. At any calculated moment, I have an offset of DESIREDANGLE - KALMANESTIMATE. At these moments, I can send an additional offset to the motors to get it their quicker.

One last question (for now). How do I scale my angles to actual motor timing? I can do it programmatically with the use of my sensors, and continue to increase actuation values until achieving my angles. But is there a way to know/calculate some sort of constant so that if I wanted to move 10deg roll, it would be equal to X amount of servo timing?

thanks

ps - the device lifts, hovers, however jittery it may be. I am now working for jitter removal and overall control with radio and scripting.

 #2 saturnine Dec 13, 2007 01:41 PM

Not sure how much if any I can help at this point, but I would love to see pictures, etc. As you can see, I am an avid quadrotor pilot, but I would also be interested at some point in tackling this exact same task. I will help in any way that I can along the way. Good luck on your new endeavor!

Damon

Quote:
 Originally Posted by haobuhao I have the gizmo basically built - 4 rotors, carbon fiber and aluminum frame. Electronics consist of 3 single axis gyros and 1 triple axis accelerometer hooked up to an atmega168 controller. I've written my kalman filter code so that from the gyro and accel I can get a roll and pitch estimate. For the yaw estimate, I basically integrate the angle seen over time. I've read a lot of interesting papers from all over the world that discuss the flight control of the quadrotor. I will try to summarize what I want to do below. If the motor is configured like so: leftfront rightfront leftback rightback leftfront and rightback share rotational direction, and leftback and rightfront share the opposite direction. I can see how to easily use the kalman estimates to send offsets to the pair of motors to balance them out. But, I have yet to wrap my head around how to balance each motor individually within its pair set. For example, if leftfront is slightly stronger than rightback, there will be some rotation if they continue to receive the same offset. Is there an algorithm to programmatically calculate their strength difference while in flight? My next algorithm I need verification on is the following. If I am controlling the device, I will be able to send it the following factors: thrust, yaw, roll, and pitch (from a radio or through a script). I would be sending the following to the motors: leftfront = thrust + pitch - yaw rightfront = thrust - roll + yaw leftback = thrust + roll + yaw rightback = thrust - pitch - yaw Now, I would like to integrate my kalman estimates. I can't seem to wrap my head around this. Should I be applying my kalman estimates while the motors are being actuated by the radio/script? Or should I wait to apply my offsets after the actuation is complete? For example, if the motors are to be actuated for 30deg of roll, it takes X amount of time to complete that motion to get to 30deg. In that amount of time and after completing the motion to get to 30deg, my controller is calculation kalman estimates at 60Hz. At any calculated moment, I have an offset of DESIREDANGLE - KALMANESTIMATE. At these moments, I can send an additional offset to the motors to get it their quicker. One last question (for now). How do I scale my angles to actual motor timing? I can do it programmatically with the use of my sensors, and continue to increase actuation values until achieving my angles. But is there a way to know/calculate some sort of constant so that if I wanted to move 10deg roll, it would be equal to X amount of servo timing? Comments? Suggestions? Corrections? thanks ps - the device lifts, hovers, however jittery it may be. I am now working for jitter removal and overall control with radio and scripting.

 #3 haobuhao Dec 13, 2007 03:44 PM

some pics

3 Attachment(s)
some pics attached

 #4 Arthur P. Dec 13, 2007 04:47 PM

Very impressive !! Have you had a look at the source code for the Mikrokopter (http://www.mikrokopter.de/) ? It also uses a ATMega processor (644 or 644P), which means much should be identical accross your platform and the MK. At least if you abstracted your code from the specific sensors. They have worked out a lot of the jitter and wobble. More and more of the site is also available in English. And the sourcecode is open. You can find the code here: http://mikrocontroller.cco-ev.de/mik...ightCtrl/tags/ Last version is 0.67g. In addition if you go up one level and then follow the branches subdir you can find a version 0.67 with integration of 3 axis magnetometer and GPS.

Although written for a different processor (PIC) the code for the UAVP (http://www.uavp.de/) is also worth looking at as it has some other interesting solutions (e.g. choice of flying in + or x mode; choice of using PWM or TWI/I2C for motor control). As most of it is in C it should be reasonably transferable as well.

One question: why 4 batteries? Isn't it a lot easier to just use one or two larger batteries? That would also reduce the risk of one bad battery bringing the device down due to drop in power output on a single motor.

Next step up the ladder seems to be either Arm7 or PowerPC chips. There are several prototypes out there (including one with a diagram) but none with source code yet.

L

 #5 haobuhao Dec 13, 2007 05:10 PM

yep

I've been using the mikrocopter and uavpe sites for information. I studied German for 4 years in school and it helps, but I haven't dug deep enough to determine the answers to my mechanical questions. I originally thought using the kalman filters would be the answer to all questions, but having two physically distinct motors operating as one directional element does not seem to fit the kalman model. If the motors were equivalent in output, my code works fine as is. I'm still studying. Some papers have recently come out of France and I'm trying to broken-understand that language and add to the functionality of my flyer.

I have not looked at the mikrocopter code yet. I will download today and see how/if it builds in my world.

My processor is atmega168 piggybacked on the orangutan controller from Pololu. All my coding is done with avr-gcc. My kalman is based on Trammel Hudson's kalman code that is all over the net. My sensors are from sparkfun, adxrs300 gyros, adxl330 accelerometer. I also have a barometric pressure sensure and gps that I will integrate into the system once I am comfortable with my basic flying. I will probably by the 3axis magnetometer for more exact flying at some point in the future.

4 batteries because I want very long flight times. I need to parallelize the battery setup instead of powering each motor with one - that's this weekend's work. My initial thrust tests indicate that at 38% of max power, I can lift 880g (weight of the flyer and batteries). Potential exists to lift an addition 1400g. I want a camera on here at some point.

When I'm done with this model, I am going to build one that is much larger, MUCH LARGER!

 #6 jesolins Dec 13, 2007 09:30 PM

Very interesting Q-Copter project! Where do you get your props and where do you think you will get the larger counter-rotating props when you go for your much larger version? What ESC's and motors are you currently using? Please make sure that you read through this thread started by Arthur P. to when you get the chance:) http://www.rcgroups.com/forums/showthread.php?t=716870
Cheers,
Jim

 #7 haobuhao Dec 14, 2007 12:52 PM

My esc's and motors are from unitedhobbies. The 10a towerpro esc, and kv-1800 motors. all small. The lipos from them as well. I wanted to clarify, I went for 4 batteries instead of 1 because it is more cost effective to replace one smaller one in case things go bad. I will eventually run in parallel, in essence, the same as one large battery.

As I work on finishing this model up, I am designing a larger version. I hope to expand my skillset by attempting to do the larger props on my own - and goals of doing the large props and frame in carbon fiber.

My code captures data from gyros/accels and computes kalman estimates at 57hz on my little atmega168. I also drive my 4 escs at 50hz with servo PWM code. As I was reading through that super long thread (and not done yet), I see that rate could be disadvantageous. I am also working on a fixed point library for my math routines, so possible will get a large improvement in performance once that is completed.

For my larger model, I am looking at those gumstix as a platform. So, as long as I can have somewhat stable dependable flying with current model, it should scale up nicely for the larger flyer and more powerful computing system.

I'm taking some time off from work from now til the end of the year and hope to have some videos of untethered flight posted by then. I don't have a radio yet. I am working strictly on stable hover with a hardlined analog throttle and the flyer tethered to prevent horrible accidents. Once I remove the jitter, I'll untether and test. After those straightforward hover tests, I will try to script in some flight paths - like straight lines, figure eights, etc.

I'm looking at radios on unitedhobbies, but don't know if I want to go there. My whole goal is autonomous pre-scripted flights. But, if you can recommend a fairly inexpensive radio to start with, I'll look into getting one.

 #8 saturnine Dec 14, 2007 01:02 PM

Nice, yet cheap 6-channel radio with various types of mixing in case that's necessary. Hard to go wrong here:

http://www.servocity.com/html/optic_6_systems.html

Hope that helps.

May I ask what got you interested in this? Also, where did you get the code you're starting with, or are you mostly recreating the wheel as a challenge to yourself?

Damon

Quote:
 Originally Posted by haobuhao My esc's and motors are from unitedhobbies. The 10a towerpro esc, and kv-1800 motors. all small. The lipos from them as well. I wanted to clarify, I went for 4 batteries instead of 1 because it is more cost effective to replace one smaller one in case things go bad. I will eventually run in parallel, in essence, the same as one large battery. As I work on finishing this model up, I am designing a larger version. I hope to expand my skillset by attempting to do the larger props on my own - and goals of doing the large props and frame in carbon fiber. My code captures data from gyros/accels and computes kalman estimates at 57hz on my little atmega168. I also drive my 4 escs at 50hz with servo PWM code. As I was reading through that super long thread (and not done yet), I see that rate could be disadvantageous. I am also working on a fixed point library for my math routines, so possible will get a large improvement in performance once that is completed. For my larger model, I am looking at those gumstix as a platform. So, as long as I can have somewhat stable dependable flying with current model, it should scale up nicely for the larger flyer and more powerful computing system. I'm taking some time off from work from now til the end of the year and hope to have some videos of untethered flight posted by then. I don't have a radio yet. I am working strictly on stable hover with a hardlined analog throttle and the flyer tethered to prevent horrible accidents. Once I remove the jitter, I'll untether and test. After those straightforward hover tests, I will try to script in some flight paths - like straight lines, figure eights, etc. I'm looking at radios on unitedhobbies, but don't know if I want to go there. My whole goal is autonomous pre-scripted flights. But, if you can recommend a fairly inexpensive radio to start with, I'll look into getting one.

 #9 haobuhao Dec 14, 2007 01:23 PM

cool

thanks for the link. I'm checking them out.

My degree is math. My work is computers. My hobby past few years has been robots.

Outside of the software libraries for the orangutan/atmega, all the code is mine - the kalman comes from my previously mentioned source, but its been heavily modified to fit my model - but he deserves credit - I think his is the root of all robotic kalman code for balancers. Now, I'm adapting all the math to code for my flyer.

I like photography. I saw all these quads from Germany a while back and decided I wanted one - but I am not interested in being a pilot. I have photographic targets that aren't reachable by sight-piloting these flyers.

I'm somewhat motivated by the grand challenges and the teams spending millions to get their autonomous vehicles to work. I've spent less than \$500, and I will have an autonomous flyer when I'm done - and I'll be able to get pictures of those targets I've been wanting for a few years now.

My next model will be much more expensive, hoping for 10x size, 10x flight time, 10x functionality - with redundancy, obstacle avoidance, possibly long distance real-time data transmission from photo/video/data sensors. And I will probably invest 10x money I have for current project.

 #10 jesolins Dec 14, 2007 01:29 PM

I use an Optic 6 and it is quite good for the price!
Cheers,
Jim

 #11 haobuhao Feb 22, 2008 12:48 PM

I've been busy with other stuff, back to working on quad. I had to replace a bunch of stuff as well. All my new parts are in. I would like to get the optic 6, but I'm unclear of all the additional components I need. I am on http://www.servocity.com/html/optic_6_systems.html. Can someone list all the components I need to buy from these guys to have a complete working radio system?

 #12 jesolins Feb 22, 2008 01:46 PM

Get the Optic 6 and the Spectra module. That way you won't have to worry about crystals for the TX. Just make sure you have the Spectra module set for the receiver crystal freq before you power up. Most of us are modifying the Berg 4L to get the combined PPM signal for the boards we use with the quads, i.e. X-UFO, X-base, Draganflyer, Mikrokopter, UVAP. I got a 2500mah 3s 15c Lipo when my NiMH tha came with the Optic 6 gave out. It was a great update as the battery lasts about 15 hours straight in the TX.
Cheers,
Jim
Quote:
 Originally Posted by haobuhao I've been busy with other stuff, back to working on quad. I had to replace a bunch of stuff as well. All my new parts are in. I would like to get the optic 6, but I'm unclear of all the additional components I need. I am on http://www.servocity.com/html/optic_6_systems.html. Can someone list all the components I need to buy from these guys to have a complete working radio system?

 #13 haobuhao Feb 24, 2008 11:51 AM

and is it any 6 channel receiver that will be compatible with the optic 6 and spectra?

Sorry I just don't know the RC stuff, and want to make sure I buy the correct components to integrate into my existing quad.

I'm looking on the same website and the following 6 channel receivers are listed:

hitec mini6s fm
hitec electron6 fm
futaba R606FS 2.4ghz

Also, more confusion comes to me with the listings that say FM, 2.4ghz, and PCM. How does that tie into the transmitter?

 #14 haobuhao Feb 24, 2008 12:11 PM

latest pics

3 Attachment(s)
these are pics from this morning as I've finished a bunch of other projects and have time to get back on this project. Next is acquiring the RC setup, and I have more work to do on my PIDs.

I think I'm going to try and change the ESCs or buy premodified ESCs for the better response.

I also need to get magnetometer into the mix. Lots of exciting (and at the same time frustrating work) ahead for me.

 #15 Graiskye Feb 24, 2008 01:54 PM

Hey Haobuhoa(curious what that means btw), I see you have listed FM and 2.4ghz recievers listed these are two very different frequencues. 2,4Ghz is new stuff, it runs on the same bands or frequencies(dont really know the technicals of it) as the cordeless phones weve been using for years. Im not sure if you want to mess with the extra learning involved in the 2.4ghz systems. The other receivers listed are FM's on I assume the 72mhz band(Europe is 35mhz, N.A. is 72mhz). So you need to make sure if you are looking at the Optic 6 that is a FM radio, you dont want to by a 2.4ghz reciever.
Myself I would buy the package that comes with Receiver, Charger, and Transmitter, not sure you want any servos, but if you do, HI-Tec sells many different configurations of the Optic 6.
Good luck, Im impressed with the theory and all that goes into one of these x fliers.
-Grais.

All times are GMT -5. The time now is 11:04 AM.