I got a lot of requests for the matlab source code of my tracking algorithm. (If you wonder what I am talking about, watch this video of the tracking process via Matlab: http://vimeo.com/6347100 )
As you will see, it is not that complicated. I did not upload the complete source code, because that doesn't make too much sense. My GUI for example, contains a lot of code and it is most likely irrelevant to most of you. I left out the calculations of the different parameters for my PID control loop too, they will make things appear more complicated than they really are.
Here comes the code: download here:
Finally, it's done... My tricopter flies along a three-dimensional path without me doing anything. The waypoints are recorded by some sort of "teach in" (basically taking snapshots of different positions in space, the flightpath is hence calculated as the cubic interpolation between these snapshots). Principle: A web cam (mounted to the ceiling) tracks 4 IR-leds that are installed on the copter. My computer then calculates height, yaw, x & y shift of the copter, as well as velocities and accelerations in all directions. Commands are subsequently sent via a wireless serial link to the tricopter. I want to thank watterott.comvery much for donating two XBee radio modules for the wireless RS232 link!
Watch these videos for more infos on the LED tracking procedure:
Check my blog for things related to the tricopter:
(updated with the source code of the matlab tool)
My tricopter tracking process uses several functions: There is one function (StartCam.m) that sets up everything, starts a GUI and another function (independentTrack_timer.m). The latter is the main function, which grabs the images from the camera and executes a tracking algorithm. A GUI is used to enable "on the fly" parameter editing. I will not include the code of the GUI because it is quite a lot of code and in essence, it doesn't do anything important. It simply makes PID parameter optimization more comfortable. Another function (figureclosingTrack.m) is used as the close request function of the GUI. It will be executed when the user wants to stop tracking. This function closes all connections (camera, serialport, timer function).
I tried to comment everything in the source code. Comments are always on top of the commands that they describe.
If you have questions, I would suggest that you put them into the comments for this post. Doing so, more people might benefit from it.
0 comments:
Post a Comment