<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-4136375076360613625</id><updated>2012-02-16T02:20:00.478-08:00</updated><category term='linux'/><category term='control'/><category term='birthday'/><category term='programming'/><category term='robot'/><category term='robo-one'/><category term='comic'/><category term='battery'/><category term='fall'/><category term='servo'/><category term='girlfriend'/><category term='mechanical'/><category term='robobob'/><category term='intelligence'/><category term='hexapod'/><category term='software'/><category term='electronic'/><category term='family'/><category term='internet'/><category term='repair'/><category term='interrupt'/><category term='robobuilder'/><category term='dance'/><category term='balance'/><category term='biped'/><title type='text'>Build The Robot</title><subtitle type='html'>A site dedicated to humanoid robotics</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://buildtherobot.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://buildtherobot.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Alex Jarkey</name><uri>http://www.blogger.com/profile/02033809613943284663</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_PZjyemYqS8E/S0uqTx1jdrI/AAAAAAAAAFM/EVGW1FeCizY/S220/peas.bmp'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>42</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-4136375076360613625.post-266499802812695889</id><published>2011-02-08T02:20:00.001-08:00</published><updated>2011-02-08T02:35:37.138-08:00</updated><title type='text'>Now 80% more Handy!</title><content type='html'>I had a birthday not long ago. I've always valued practical gifts over expensive ones, and this year I made a special request to friends and family for things which would make working at my new job just a little bit easier. &lt;br/&gt;  &lt;br/&gt; When it comes to gadgets, there is a thin line between practical and gimmicky, but I am pleased to report that I couldn't be happier with everyone's choices. &lt;br/&gt;  &lt;br/&gt; Topping the list are the leatherman multitools. One might expect that two would be one too many, but they complement each other nicely. The first one is a full sized tool which finds use primarily as a bit driver (I am forever absent mindedly putting down screwdrivers and then not having the right size), but which also has pliers, wire cutters, and absurdly sharp knife. I believe it has wire strippers too, but years of incomplete toolkits from university labs have taught me that there is no substitute for teeth. &lt;br/&gt;  &lt;br/&gt; The other multitool is a keychain sized leatherman which (in addition to another set of smaller screwdrivers) I mainly use as scissors. "What?" You exclaim, "Are scissors at such a premium that you need to carry a pair with you all the time?" Sort of. Next time you are opening a package - food, electronics, shrink wrap - stop and think about what your options are. You can: &lt;br/&gt; a) walk to the kitchen/study and hope whoever used the scissors last has remembered to put the back, &lt;br/&gt; b) use a knife/pen/teeth to bludgeon you way in (god help you if you want to repeal it again), or &lt;br/&gt; c) assault the packaging like an enraged gorilla. &lt;br/&gt;  &lt;br/&gt; I've put my keys on the keychain one, and I carry the full sized one with me whenever possible. Combined with my other two "tools" which I have on me at all times (a smartphone and a 16gb USB stick), I find that there is almost no problem I lack the equipment to handle. The other day I was able to field strip my ps3 (along with the warranty) in less than an hour. &lt;br/&gt;  &lt;br/&gt; Obviously my technical experience as a hobbyist plays a large part in making good use of the tools at hand, but I didn't realise how much of a difference it makes having good equipment at you fingertips. Obviously, having a workshop and a full toolbox would be a further improvement, but as a hobbyist living in an apartment these tools have really boosted my productivity. &lt;br/&gt;  &lt;br/&gt; As a side benefit, I'd say that my zombie apocalypse survival rate has at least doubled.&lt;div style='clear: both; text-align: center; font-size: xx-small;'&gt;Published with Blogger-droid v1.6.5&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4136375076360613625-266499802812695889?l=buildtherobot.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://buildtherobot.blogspot.com/feeds/266499802812695889/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://buildtherobot.blogspot.com/2011/02/now-80-more-handy.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/266499802812695889'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/266499802812695889'/><link rel='alternate' type='text/html' href='http://buildtherobot.blogspot.com/2011/02/now-80-more-handy.html' title='Now 80% more Handy!'/><author><name>Alex Jarkey</name><uri>http://www.blogger.com/profile/02033809613943284663</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_PZjyemYqS8E/S0uqTx1jdrI/AAAAAAAAAFM/EVGW1FeCizY/S220/peas.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4136375076360613625.post-3261536185473954556</id><published>2010-12-15T16:36:00.000-08:00</published><updated>2010-12-15T16:41:20.536-08:00</updated><title type='text'>Artificial Intelligence for Fun and Profit!</title><content type='html'>AI is one of those buzzwords which get's thrown around without people really understanding what it means.&lt;br /&gt;&lt;br /&gt;Before I continue, I would like to mention that "Cloud" is by far my least&amp;nbsp;favorite&amp;nbsp;word du jour. There is no such thing as the Cloud!&amp;nbsp;Just because you can't see it doesn't mean it is some kind of panacea!&amp;nbsp;Everything still happens SOMEWHERE on SOME COMPUTER, and that computer can still fail!&lt;br /&gt;&lt;br /&gt;Sorry, side-rant over. Where was I?&lt;br /&gt;&lt;br /&gt;One of the biggest hurdles is defining "Intelligence". Even &lt;a href="http://en.wikipedia.org/wiki/Intelligence"&gt;wikipedia&lt;/a&gt; doesn't have a simple answer. whenever I'm asked the question though, I usually go with:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;"Intelligence is the ability to solve a wide variety of problems with a limited set of tools"&lt;/blockquote&gt;&lt;br /&gt;Which applies very nicely to robots.&lt;br /&gt;&lt;br /&gt;Robots need to be more than just state-machines. Generally, robots have tasks or missions, and they are given a set of tools to complete the task. An intelligent robot needs to have the capacity to alter it's&amp;nbsp;behavior&amp;nbsp;to complete it's mission even if the environment changes. This is where artificial intelligence and machine learning play a role.&lt;br /&gt;&lt;br /&gt;Many AI techniques can be thought of simply as optimizing techniques. There is a feedback loop (which may be supervised or unsupervised) and an algorithm which is capable of altering itself&amp;nbsp;to satisfy some condition of the feedback.&lt;br /&gt;&lt;br /&gt;In a previous post, I mentioned using Genetic Algorithms as a method of creating "intelligent" (per the definition above) robots. Every individual in a population is a "pilot", which takes turns to "drive" the robot. The pilots who are most succesful at the mission get to "train" the next generation of pilots.&lt;br /&gt;&lt;br /&gt;Conceptually, this is not a bad way to get a basic&amp;nbsp;adaptable&amp;nbsp;AI working for a robot. Every individual's genetic code is represented as a decision making algorithm which decides what action the robot should take given the input (if any) from the sensors.&lt;br /&gt;&lt;br /&gt;My somewhat clumsy implementation involved a 2DOF robot "inchy the inchbot", which learned to crawl forwards using a distance sensor mounted at the back. Every&amp;nbsp;individual&amp;nbsp;had 100 actions in which to move the furthest possible distance - after a few hundred generations, this is what happened:&lt;br /&gt;&lt;br /&gt;&lt;insert video=""&gt;&lt;/insert&gt;&lt;br /&gt;&lt;br /&gt;My sincere apologies for the horrible webcam video. This was a good proof of concept for me, but there were a few things which need improvement:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;All individuals get a chance to "drive", even if they suck at "driving" particularly in the early generations, this meant that the robot was just as&amp;nbsp;likely&amp;nbsp;to go backwards as it was to go forwards. On a real mission, this would be unacceptable, since a bad driver might put the whole robot in harms way.&lt;/li&gt;&lt;li&gt;The method of encoding the pilots in the GA was too prone to sudden changes. I used a heuristic function which evolved by swapping and switching operators in a tree format (more on this later), and this meant that even in later generations there was no shortage of evolutionary throwbacks.&lt;/li&gt;&lt;li&gt;The combination of 1 and 2 meant that even though the population as a whole did get fitter, the robot would sometimes spaz out or just stall for apparently no reason.&lt;/li&gt;&lt;li&gt;Another huge drawback was that each individual was very selfish. The individual had to regard for the (sometimes awkward or precarious) position it would leave the robot in for the next individual who drove the robot. The next individual would then have to waste some its "actions" to extricate the robot from a weird configuration - this mean that sometimes even the best individuals would&amp;nbsp;under perform&amp;nbsp;unnecessarily.&lt;/li&gt;&lt;li&gt;In this particular application, the&amp;nbsp;tendency&amp;nbsp;for genetic algorithms to "Cheat" was very apparent. The sensor was mounted on the back, and early tests resulted in the robot simply pointing the distance sensor at the ceiling to&amp;nbsp;maximize&amp;nbsp;the "distance&amp;nbsp;traveled" =)&lt;/li&gt;&lt;/ol&gt;&lt;div&gt;This was a good proof of concept test, but I might need to re-examine some of the details. I don't know of many applications of GAs to do this kind of robot decision making, but if someone has some references I would love to hear about them.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4136375076360613625-3261536185473954556?l=buildtherobot.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://buildtherobot.blogspot.com/feeds/3261536185473954556/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://buildtherobot.blogspot.com/2010/12/artificial-intelligence-for-fun-and.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/3261536185473954556'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/3261536185473954556'/><link rel='alternate' type='text/html' href='http://buildtherobot.blogspot.com/2010/12/artificial-intelligence-for-fun-and.html' title='Artificial Intelligence for Fun and Profit!'/><author><name>Alex Jarkey</name><uri>http://www.blogger.com/profile/02033809613943284663</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_PZjyemYqS8E/S0uqTx1jdrI/AAAAAAAAAFM/EVGW1FeCizY/S220/peas.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4136375076360613625.post-728326415959006202</id><published>2010-11-27T15:54:00.000-08:00</published><updated>2010-11-27T15:54:30.224-08:00</updated><title type='text'>Where I've been</title><content type='html'>It's been a very long time since I posted anything, hasn't it. In case you were wondering if I had a good excuse or not, here is a list of things that have happened since my last update:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Got a part time job,&lt;/li&gt;&lt;li&gt;Got a full time job,&lt;/li&gt;&lt;li&gt;Learned lambda calculus and LISP,&lt;/li&gt;&lt;li&gt;Wrote a programming language and a compiler,&lt;/li&gt;&lt;li&gt;Learned to sing,&lt;/li&gt;&lt;li&gt;Sang on stage,&lt;/li&gt;&lt;li&gt;Held some more Robot Wars&amp;nbsp;competitions,&lt;/li&gt;&lt;li&gt;Handed over the society to next year's president,&lt;/li&gt;&lt;li&gt;Put together a tender bid for work,&lt;/li&gt;&lt;li&gt;Won the contract,&lt;/li&gt;&lt;li&gt;Bought and built a new computer,&lt;/li&gt;&lt;li&gt;Set up a home file server and uPnP media server,&lt;/li&gt;&lt;li&gt;Accidentally erased my MFT and boot sector,&lt;/li&gt;&lt;li&gt;Managed to restore them,&lt;/li&gt;&lt;li&gt;Built and programmed a robot for the New Inventors TV Show,&lt;/li&gt;&lt;li&gt;Appeared on TV,&lt;/li&gt;&lt;li&gt;Studied for exams,&lt;/li&gt;&lt;li&gt;Finished university&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;So yeah. I've been busy.&amp;nbsp;Fortunately, each of these is an excellent story which I hopefully will be able to recount here in the future.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;But now that that's out of the way, we can get back to talking about robots.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I've been following the Google AI challenge (&lt;a href="http://ai-contest.com/"&gt;http://ai-contest.com/&lt;/a&gt;) and I highly suggest you check out the forums. Were it not for the aforementioned points, I would have loved to put an entry in, but as I write this there are only 6 hours left to go for submissions. Ooohhh.... now there's a challenge....&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I also wanted to bring your attention to &lt;a href="http://lbrandy.com/blog/2010/11/using-genetic-algorithms-to-find-starcraft-2-build-orders/"&gt;this amazing post&lt;/a&gt;. Give it a read while I go beat my head against the wall for even considering giving myself MORE things to do.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4136375076360613625-728326415959006202?l=buildtherobot.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://buildtherobot.blogspot.com/feeds/728326415959006202/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://buildtherobot.blogspot.com/2010/11/where-ive-been.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/728326415959006202'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/728326415959006202'/><link rel='alternate' type='text/html' href='http://buildtherobot.blogspot.com/2010/11/where-ive-been.html' title='Where I&apos;ve been'/><author><name>Alex Jarkey</name><uri>http://www.blogger.com/profile/02033809613943284663</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_PZjyemYqS8E/S0uqTx1jdrI/AAAAAAAAAFM/EVGW1FeCizY/S220/peas.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4136375076360613625.post-8645700182145130385</id><published>2010-07-05T21:07:00.000-07:00</published><updated>2010-07-06T02:47:17.812-07:00</updated><title type='text'>Hungry Hungry Robos!</title><content type='html'>Hungry Hungry Robos was an event for the 2010 Sydney University Robot Wars teams to get a chance to test their robots before sending them into battle. It was the first chance teams had to try out their robots and it was also heaps of fun.&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The rules are very simple: The robot with the most marbles in their corner (taped off squares) when time runs out is the winner!&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;object height="385" width="480"&gt;&lt;param name="movie" value="http://www.youtube.com/v/TcM8qcBaBDE&amp;amp;hl=en_US&amp;amp;fs=1"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/TcM8qcBaBDE&amp;amp;hl=en_US&amp;amp;fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Below is the poster I designed to promote the event. As you can see from the dates, this actually happened ages ago, but I've been to busy to cut everything together until now. The next event will be some time in August.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/_PZjyemYqS8E/TDKmSSRX9lI/AAAAAAAAAHk/3hWWAXTKEGw/s1600/HHRbw.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="640" src="http://1.bp.blogspot.com/_PZjyemYqS8E/TDKmSSRX9lI/AAAAAAAAAHk/3hWWAXTKEGw/s640/HHRbw.png" width="452" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;Edit: Fixed the broken encoding on the video. Fun fact: This video took longer to encode than the entire event took to&amp;nbsp;organize! Peas out.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4136375076360613625-8645700182145130385?l=buildtherobot.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://buildtherobot.blogspot.com/feeds/8645700182145130385/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://buildtherobot.blogspot.com/2010/07/hungry-hungry-robos.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/8645700182145130385'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/8645700182145130385'/><link rel='alternate' type='text/html' href='http://buildtherobot.blogspot.com/2010/07/hungry-hungry-robos.html' title='Hungry Hungry Robos!'/><author><name>Alex Jarkey</name><uri>http://www.blogger.com/profile/02033809613943284663</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_PZjyemYqS8E/S0uqTx1jdrI/AAAAAAAAAFM/EVGW1FeCizY/S220/peas.bmp'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_PZjyemYqS8E/TDKmSSRX9lI/AAAAAAAAAHk/3hWWAXTKEGw/s72-c/HHRbw.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4136375076360613625.post-3771671327104830329</id><published>2010-05-29T16:18:00.000-07:00</published><updated>2010-05-29T16:18:06.566-07:00</updated><title type='text'>Sweet Zombie Jesus!</title><content type='html'>This was too cool not to post.&lt;br /&gt;&lt;br /&gt;&lt;object height="385" width="640"&gt;&lt;param name="movie" value="http://www.youtube.com/v/MvRTALJp8DM&amp;hl=en_US&amp;fs=1&amp;"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/MvRTALJp8DM&amp;hl=en_US&amp;fs=1&amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="385"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;br /&gt;&lt;br /&gt;I was also reminded of this single bladed UAV.&amp;nbsp;Unfortunately, this design is pretty useless, since any efficiency gain you get from the one large blade to provide lift is overwhelmed by the tiny, multibladed&amp;nbsp;propeller&amp;nbsp;doing all the work. Still, it looks cool.&lt;br /&gt;&lt;br /&gt;&lt;object width="640" height="505"&gt;&lt;param name="movie" value="http://www.youtube.com/v/sbuGCgc-JCM&amp;hl=en_US&amp;fs=1&amp;"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/sbuGCgc-JCM&amp;hl=en_US&amp;fs=1&amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="505"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;br /&gt;&lt;br /&gt;Coming up next: Sydney University Robot Wars videos!!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4136375076360613625-3771671327104830329?l=buildtherobot.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://buildtherobot.blogspot.com/feeds/3771671327104830329/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://buildtherobot.blogspot.com/2010/05/sweet-zombie-jesus.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/3771671327104830329'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/3771671327104830329'/><link rel='alternate' type='text/html' href='http://buildtherobot.blogspot.com/2010/05/sweet-zombie-jesus.html' title='Sweet Zombie Jesus!'/><author><name>Alex Jarkey</name><uri>http://www.blogger.com/profile/02033809613943284663</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_PZjyemYqS8E/S0uqTx1jdrI/AAAAAAAAAFM/EVGW1FeCizY/S220/peas.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4136375076360613625.post-6302614487127152048</id><published>2010-05-07T00:01:00.000-07:00</published><updated>2010-05-07T00:34:58.994-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='hexapod'/><category scheme='http://www.blogger.com/atom/ns#' term='robot'/><category scheme='http://www.blogger.com/atom/ns#' term='control'/><category scheme='http://www.blogger.com/atom/ns#' term='balance'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><category scheme='http://www.blogger.com/atom/ns#' term='robobob'/><category scheme='http://www.blogger.com/atom/ns#' term='robobuilder'/><category scheme='http://www.blogger.com/atom/ns#' term='intelligence'/><title type='text'>Bayesian Classifier Answers the Question: "Is it art?"</title><content type='html'>&lt;span class="Apple-style-span"&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br class="Apple-interchange-newline" /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span"&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;The&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;a href="http://books.google.com.au/books?id=bOv9foa3KA4C&amp;amp;printsec=frontcover&amp;amp;dq=but+is+it+art%3F&amp;amp;source=bl&amp;amp;ots=XoXj8_lxMB&amp;amp;sig=bKaI5w2FyX3KJCfH7rvc9ig_LO0&amp;amp;hl=en&amp;amp;ei=_K7jS-mNJJLq7AO1wP38BA&amp;amp;sa=X&amp;amp;oi=book_result&amp;amp;ct=result&amp;amp;resnum=2&amp;amp;ved=0CBwQ6AEwAQ#v=onepage&amp;amp;q&amp;amp;f=false"&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;title&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;is a joke, by the way. Although I would be interested to see what the results of such an exercise would be. "Statue of David... *beep*: ART!", "Justin Beiber's Music... *beep*&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;a href="http://graphjam.com/2010/04/26/funny-graphs-content-pop-song/"&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;NOT_ART!&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;".&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Almost as exciting as my&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;a href="http://en.wikipedia.org/wiki/Association_rule_learning#Zero-attribute-rule"&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;0-R&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;Spam filter. Catches 100% of spam with a &lt;/span&gt;&lt;/span&gt;&lt;a href="http://en.wikipedia.org/wiki/E-mail_spam#As_a_percentage_of_the_total_volume_of_e-mail"&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;97%&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; accuracy rate! Oh mercy.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;The reason that I mention &lt;/span&gt;&lt;/span&gt;&lt;a href="http://en.wikipedia.org/wiki/Bayes'_theorem#Simple_statement_of_theorem"&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Bayesian Classifiers&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; is because I wanted to talk about machine learning. This is the other branch of &lt;/span&gt;&lt;/span&gt;&lt;a href="http://buildtherobot.blogspot.com/2010/04/algorithm-eats-sandvitch-in-omnomnomnom.html"&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;artificial intelligence&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; and what most people think of when the topic of&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;a href="http://tvtropes.org/pmwiki/pmwiki.php/Main/SentientAIWarningSigns"&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Skynet&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;is brought up.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Fear not though. Bayes rule, decision trees and rule based learning are actually pretty mild. They are simply statistical methods of attempting to classify data by using the results of previous observations. Mostly harmless.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;However, today I'm going to talk about genetic algorithms.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;A genetic algorithm is an abstract representation of a mathematical function. They can take many forms, such as a string of bits which might indicate the presence/absence of a set of inputs, or a literal mathematical function "y = cos(x) - 2*z". The range of variables which is represented by the function is called a genome.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;This can get a bit hard to&amp;nbsp;visualize, so I often just settle for imagining genomes as Taylor polynomials. Therefore, a single genome consists of "x = A*input1^a + B*input2^b ..." where the values of A and a can take any real number. If some of the inputs are simply a higher&amp;nbsp;derivatives of other inputs, then any arbitrary function can be represented in this way. There is also a rather nice representation involving&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;a href="http://en.wikipedia.org/wiki/File:Genetic_Program_Tree.png"&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;trees&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;If we start off with a population of individuals with random valued variables in their genomes, then we can evaluate each function to see how well it 'fits' a set of training data. The individuals which produce the minimum mean squared error for the training data are declared the 'fittest', and are allowed to&amp;nbsp;survive&amp;nbsp;into the next generation.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;This is where the 'genetic' part comes in. There are many ways of 'evolving', 'mutating' and 'breeding' individuals, but the easiest to understand is the asexual method. This means that all&amp;nbsp;individuals except the best performer are killed off (ie, deleted) and then their places are taken by the offspring of the remaining individual. However, tiny random 'mutations' are introduced to each of the new individuals variables - such as doubling/halving the values of A or B, or&amp;nbsp;incrementing/decrementing a or b.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Anyway, thats the 30 second version of genetic&amp;nbsp;algorithms. They can be used to find a semi-optimal solution to many problems, provided you can throw enough generations at them. I have been working with a C++ implementation called&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;a href="http://lancet.mit.edu/ga/"&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;GAlib&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;. If you are interested, I highly recommend going through the&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;a href="http://lancet.mit.edu/ga/dist/"&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;examples&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Now, some of you may be wondering what all this has to do with robots (actually, most of you are probably already filling in the blanks and peeing your pants in terror).&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;I've spoken on several occasions about using &lt;/span&gt;&lt;/span&gt;&lt;a href="http://buildtherobot.blogspot.com/2010/02/robobob-life-of-party.html"&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Robobob&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; as a platform to investigate dynamic balance and movement.&amp;nbsp;I plan to represent the control state of the robot as a &lt;/span&gt;&lt;/span&gt;&lt;a href="http://buildtherobot.blogspot.com/2010/04/algorithm-eats-sandvitch-in-omnomnomnom.html"&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;search tree&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;, with the robot beginning at a starting node/state and attempting to plan a path of control actions to reach a goal node/state. To navigate the tree, I want to implement a greedy search heuristic which will choose which control actions are most likely to lead to the goal state.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span"&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Now here's the tricky part - I intend to implement the heuristic as an evolutionary algorithm which can then be rewarded or punished depending on the outcome of executing the control path on the real robot. ie, if the heuristic gets stuck or can't find the goal state, it will be&amp;nbsp;disfavored&amp;nbsp;whereas successfully reaching the goal will be&amp;nbsp;favored. After a series of generations, I will be able to study the path planning method which has evolved from this process.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Cool? I hope so.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Terrifying?&amp;nbsp;Definitely.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;object height="385" width="480"&gt;&lt;param name="movie" value="http://www.youtube.com/v/ehno85yI-sA&amp;hl=en_US&amp;fs=1&amp;"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/ehno85yI-sA&amp;hl=en_US&amp;fs=1&amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4136375076360613625-6302614487127152048?l=buildtherobot.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://buildtherobot.blogspot.com/feeds/6302614487127152048/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://buildtherobot.blogspot.com/2010/05/bayesian-classifier-answers-question-is.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/6302614487127152048'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/6302614487127152048'/><link rel='alternate' type='text/html' href='http://buildtherobot.blogspot.com/2010/05/bayesian-classifier-answers-question-is.html' title='Bayesian Classifier Answers the Question: &quot;Is it art?&quot;'/><author><name>Alex Jarkey</name><uri>http://www.blogger.com/profile/02033809613943284663</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_PZjyemYqS8E/S0uqTx1jdrI/AAAAAAAAAFM/EVGW1FeCizY/S220/peas.bmp'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4136375076360613625.post-81086928502991508</id><published>2010-04-18T01:22:00.000-07:00</published><updated>2010-04-18T01:24:09.858-07:00</updated><title type='text'>Algorithm eats sandvitch in O(mn)O(mn)O(mn)O(m) time</title><content type='html'>&lt;span class="Apple-style-span" style="font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;I've been doing a lot of research on artificial intelligence recently. I'm toying with the idea of using it to help solve the inverse kinematics problem of a humanoid robot. I've already started work on extending robobob's firmware with some AI functions, which I'll share in a few updates. I don't know how well this will work out, but since future topics will probably include a fair bit of artificial intelligence talk, I thought I would put up a&amp;nbsp;brief&amp;nbsp;intro to AI and some common search strategies.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Many people are underwhelmed when they start learning about AI. Sci Fi has delivered promises of robotic servants, androids, and positronic brains - but even state of the art AI still struggles with simple real-world problems that humans find trivial. However, AI still as much potential if you are able to&amp;nbsp;appropriately&amp;nbsp;abstract&amp;nbsp;the problem into a form that an AI strategy can handle.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;One of the most basic methods of problem solving is searching. If you break the problem down into a starting state, a goal state, and a set of operations allowing traversal between states, then you simply search the tree until a goal is found will provide a method of solving the problem.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;This is why AI excels at games but fails at life. Games are easily distilled into a set of rules with clear conditions for victory. Using a searching strategy, possible configurations can be tested until one set of moves leads to a win. However, attempting to&amp;nbsp;distill&amp;nbsp;real world problems into a 'game tree' is even more complicated than it sounds since there are far too many options at each planning stage.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Below are some commonly used searching&amp;nbsp;strategies. This is just a quick summary of each one, but it is important to know a little about how searching works in order to appreciate the more intricate levels of AI.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;h2 class="western"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Breadth First Search&lt;/span&gt;&lt;/h2&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;In a Breadth First Search, children of the most recently expanded node are added to the end of the fringe. Since nodes are explored one by one in the order they are placed in the fringe, nodes closer to the root of the tree will always be expanded first.&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/_PZjyemYqS8E/S8q69A8lR1I/AAAAAAAAAG8/cWfvqcowXGQ/s1600/BFS.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;img border="0" height="320" src="http://2.bp.blogspot.com/_PZjyemYqS8E/S8q69A8lR1I/AAAAAAAAAG8/cWfvqcowXGQ/s320/BFS.png" width="192" /&gt;&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt; &lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Since nodes closer to the root are expanded first, the algorithm will terminate when it finds the goal which requires the fewest operations to reach. In cases such as pathfinding, where the cost of traversing from one square to the next is constant, the solution closest to the root is the optimal (shortest) solution. However, every node which is closer to the root than the goal will be expanded before the goal is found, and this can lead to breath first search can opening an excessive number of nodes.&lt;/span&gt;&lt;br /&gt;&lt;h2 class="western"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Depth First Search&lt;/span&gt;&lt;/h2&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Algorithmically, this search strategy is identical to Breadth First Search, except for the order in which the children of expanded nodes are added to the fringe. When a child node is discovered, it is added to the front of the fringe instead of the back. This means that the next node to be expanded will be one of the children of the open node and hence nodes which are further away from the root are explored before closer ones.&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/_PZjyemYqS8E/S8q7G0jyyOI/AAAAAAAAAHE/hFGE-7qYRzU/s1600/DFS.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;img border="0" src="http://2.bp.blogspot.com/_PZjyemYqS8E/S8q7G0jyyOI/AAAAAAAAAHE/hFGE-7qYRzU/s320/DFS.png" /&gt;&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Depth First Search will keep traversing down the tree until it finds a terminal or a goal node. If multiple goals a present (eg, all terminal nodes are goals), then this strategy may find a solution much faster than Breath First Search, but it may not be the best solution. However, if the tree is particularly complex or has a very high branching factor, finding any goal quickly might be a better outcome than finding the best goal too late. On the other hand, some paths may have an infinite depth which will cause Depth First Search to never find a goal.&lt;/span&gt;&lt;/div&gt;&lt;h2 class="western"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Greedy Search&lt;/span&gt;&lt;/h2&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Unlike BFS or DFS, where the ordering of nodes remains unchanged as the algorithm discovers new nodes, the greedy search method maintains a continuously sorted fringe of unopened nodes. The metric used to determine the order is known as the heuristic function, which is used to estimate the best node to open next. It doesn't matter how far away a node is in the tree or when it was discovered – the node opened by a greedy algorithm is governed only by the heuristic value of that node.&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_PZjyemYqS8E/S8q7Sfo65cI/AAAAAAAAAHM/0akEFiZkxHE/s1600/greedy.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;img border="0" src="http://4.bp.blogspot.com/_PZjyemYqS8E/S8q7Sfo65cI/AAAAAAAAAHM/0akEFiZkxHE/s320/greedy.png" /&gt;&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;The effectiveness of greedy search lies in the strength of the heuristic function used. A good heuristic function should estimate the cost of reaching the goal from the node. Every time a new node is opened, it will be the 'best choice' to find the goal according the heuristic. Of course, if the heuristic is poor then there is no guarantee that the path will be optimal or that a goal will even be found at all.&lt;/span&gt;&lt;br /&gt;&lt;h2 class="western"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;A* Search&lt;/span&gt;&lt;/h2&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Like greedy, A* maintains a sorted fringe using a heuristic function to estimate the value of each node. In addition to using the heuristic to determine the order of the sorted fringe, A* also includes  the cost of reaching the node from the root of the tree. Therefore, if two nodes are evaluated equally using the heuristic function, the node which is closer to the root will be opened first.&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt; &lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/_PZjyemYqS8E/S8q7ZswQ_CI/AAAAAAAAAHU/3q4_19Khimo/s1600/Astar.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;img border="0" src="http://3.bp.blogspot.com/_PZjyemYqS8E/S8q7ZswQ_CI/AAAAAAAAAHU/3q4_19Khimo/s320/Astar.png" /&gt;&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;A* combines the predicted (heuristic) cost of reaching the goal from a node with the true cost of reaching that node from the root. This means that the nodes are explored in terms of their overall path cost, unlike greedy which sorts the nodes only according to their distance from the goal. If the heuristic used by A* never overestimates the distance from the node to the goal, then A* is guaranteed to find the optimal solution by opening fewer nodes than any other optimal strategy.&lt;/span&gt;&lt;br /&gt;&lt;h2 class="western"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Hill Climber&lt;/span&gt;&lt;/h2&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Hill Climber searching is slightly different to all the other algorithms presented here due to the fact that it doesn't maintain a persistent fringe. The next node opened is simply the child of the open node with the best heuristic cost. Hill Climber differs from greedy because it 'forgets' about nodes which have already been discovered (regardless of how good they were), and focuses only on the immediate children of the open node.&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_PZjyemYqS8E/S8q7e4MgKDI/AAAAAAAAAHc/Bncs7bCHlvw/s1600/hillclimber.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;img border="0" src="http://4.bp.blogspot.com/_PZjyemYqS8E/S8q7e4MgKDI/AAAAAAAAAHc/Bncs7bCHlvw/s320/hillclimber.png" /&gt;&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt; &lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Sometimes, the tree which needs to be searched is simply too large or too complex to be handled by an optimal searching strategy. In this case, using Hill Climber to find the 'local minimum' of the tree  is often the best way to handle such situations. The algorithm is very easy to implement, since there is no need to maintain and sort a fringe of all the nodes discovered so far. However, the algorithm  may completely miss the goal node if the heuristic leads it into a 'local minimum' where every node in the fringe is valued to be 'worse' than the current node.&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4136375076360613625-81086928502991508?l=buildtherobot.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://buildtherobot.blogspot.com/feeds/81086928502991508/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://buildtherobot.blogspot.com/2010/04/algorithm-eats-sandvitch-in-omnomnomnom.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/81086928502991508'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/81086928502991508'/><link rel='alternate' type='text/html' href='http://buildtherobot.blogspot.com/2010/04/algorithm-eats-sandvitch-in-omnomnomnom.html' title='Algorithm eats sandvitch in O(mn)O(mn)O(mn)O(m) time'/><author><name>Alex Jarkey</name><uri>http://www.blogger.com/profile/02033809613943284663</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_PZjyemYqS8E/S0uqTx1jdrI/AAAAAAAAAFM/EVGW1FeCizY/S220/peas.bmp'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_PZjyemYqS8E/S8q69A8lR1I/AAAAAAAAAG8/cWfvqcowXGQ/s72-c/BFS.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4136375076360613625.post-3707935669109698711</id><published>2010-04-03T16:38:00.000-07:00</published><updated>2010-04-03T16:38:46.312-07:00</updated><title type='text'>Hark! An update!</title><content type='html'>About time too. I have recently been busy organizing a &lt;a href="http://buildtherobot.blogspot.com/2010/01/come-with-me-if-you-want-to-live.html"&gt;Robot Wars&lt;/a&gt; competition for Sydney University, and haven't had a lot of time to work on &lt;a href="http://buildtherobot.blogspot.com/2010/02/robobob.html"&gt;Robobob&lt;/a&gt;. However, this will ensure that there will be plenty of &lt;a href="http://buildtherobot.blogspot.com/2010/02/robobob-life-of-party.html"&gt;cool&lt;/a&gt; &lt;a href="http://buildtherobot.blogspot.com/2010/01/one-step-at-time.html"&gt;material&lt;/a&gt; for future updates, so I hope you are all looking forward to it as much as I am!&lt;br /&gt;&lt;br /&gt;Things are still in the concept phase at the moment, so it will be a while before I can post something tangible. In the meantime, here are a few videos to get everyone motivated:&lt;br /&gt;&lt;br /&gt;&lt;object height="385" width="480"&gt;&lt;param name="movie" value="http://www.youtube.com/v/hT5M5C-jTuQ&amp;hl=en_US&amp;fs=1&amp;"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/hT5M5C-jTuQ&amp;hl=en_US&amp;fs=1&amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;br /&gt;&lt;br /&gt;&lt;object height="385" width="480"&gt;&lt;param name="movie" value="http://www.youtube.com/v/NhTVBHerQ-0&amp;hl=en_US&amp;fs=1&amp;"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/NhTVBHerQ-0&amp;hl=en_US&amp;fs=1&amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;object height="385" width="640"&gt;&lt;param name="movie" value="http://www.youtube.com/v/FX5fQBrfObM&amp;hl=en_US&amp;fs=1&amp;"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/FX5fQBrfObM&amp;hl=en_US&amp;fs=1&amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="385"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;br /&gt;&lt;br /&gt;Also, if you would like to contribute to making this Robot Wars competition as exciting as possible, click on an Ad! All proceeds from this blog will go towards the&amp;nbsp;construction&amp;nbsp;costs!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4136375076360613625-3707935669109698711?l=buildtherobot.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://buildtherobot.blogspot.com/feeds/3707935669109698711/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://buildtherobot.blogspot.com/2010/04/hark-update.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/3707935669109698711'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/3707935669109698711'/><link rel='alternate' type='text/html' href='http://buildtherobot.blogspot.com/2010/04/hark-update.html' title='Hark! An update!'/><author><name>Alex Jarkey</name><uri>http://www.blogger.com/profile/02033809613943284663</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_PZjyemYqS8E/S0uqTx1jdrI/AAAAAAAAAFM/EVGW1FeCizY/S220/peas.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4136375076360613625.post-545426342860057170</id><published>2010-03-07T14:48:00.000-08:00</published><updated>2010-03-07T14:48:10.897-08:00</updated><title type='text'>Honour thy compiler and thy linker</title><content type='html'>Remember how when you were learning to program, your tutor/teacher/zen programming master always told you turn on all compiler output and to make sure that you dealt with all the warnings?&lt;br /&gt;&lt;br /&gt;It's vaguely possible that they knew what they were talking about.&lt;br /&gt;&lt;br /&gt;In the most &lt;a href="http://buildtherobot.blogspot.com/2010/02/computers-102.html"&gt;recent version&lt;/a&gt; of the code, I wrote a wrapper function to streamline the procedure for executing a &lt;a href="http://buildtherobot.blogspot.com/2010/01/puzzle.html"&gt;set of actions&lt;/a&gt;. As I explained in &lt;a href="http://buildtherobot.blogspot.com/2010/01/byte-by-byte.html"&gt;this post&lt;/a&gt;, the tables for robobuilder's actions consist of Nx16 unsigned char multidimensional arrays which are in the PROGMEM area of the chip.&lt;br /&gt;&lt;br /&gt;A multidimensional array can be expressed in two ways. Interestingly, most of the time the two types are functionally and syntactically equivalent - they only differ by the method by which they are stored in memory. However, these subtleties can make all the difference when you are performing low level operations.&lt;br /&gt;&lt;br /&gt;The first way is as an &lt;b&gt;indexed array&lt;/b&gt;, which stores all the data in a sequential memory block. A matrix of data declared:&lt;br /&gt;&lt;br /&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;int matrix[3][2]; &lt;/div&gt;&lt;br /&gt;&lt;br /&gt;You address the elements of the matrix by row, then by column:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;matrix[2][1] = 6;&lt;/div&gt;&lt;br /&gt;Assigns the value 6 to the last element in your matrix. Because the compiler knows that the array is supposed to be 3 rows by 2 columns, this statement is equivalent to:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;((int*)matrix)[(2*COLUMNS)+1] = 6;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;(Given that COLUMNS = 2. Don't forget that C arrays start at 0.)&lt;br /&gt;&lt;br /&gt;The second way of defining a multidimensional array is as an &lt;b&gt;array of pointers&lt;/b&gt; or an &lt;b&gt;array of arrays&lt;/b&gt;. In this case, the blocks of memory are &lt;i&gt;not necessarily&lt;/i&gt; arranged sequentially in memory. The following declaration:&lt;br /&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;int r0[2], r1[2], r2[2];&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;int* matrix[3] = {r1,r2,r3};&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;will create an array of three pointers, which point to the start of the row arrays. However, r0-2 may &lt;i&gt;not be in sequential memory&lt;/i&gt;. Some compilers will make an effort to put them together, but there are no guarantees.&lt;br /&gt;&lt;br /&gt;Elements can be referenced exactly the same way as before:&lt;br /&gt;&lt;br /&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;matrix[2][1] = -6;&lt;/div&gt;&lt;br /&gt;Assigns a -6 to the last element of the array. This works because of the order of evaluation: you dereference the third pointer in the array 'matrix' first, and then address the second element of THAT array. No matter how you define your array, you can use the same syntax to manipulate it.&lt;br /&gt;&lt;br /&gt;So far so good, but here comes the tricky part.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;When you pass arrays as an argument to a function, you always do so by reference. For one dimensional arrays, it doesn't matter if you use:&lt;br /&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;void func(int * array);&lt;/div&gt;&lt;br /&gt;or&lt;br /&gt;&lt;br /&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;void func(int array[]);&lt;/div&gt;&lt;br /&gt;in either case, what is being passed to the function is a pointer to the start of the data block.&lt;br /&gt;&lt;br /&gt;People are also introduced to the concept of a "string as an array of characters", so an array of strings has the type "pointer to a pointer of chars" (char **). Because C uses null terminated strings, this will work fine and you shouldn't receive any warnings.&lt;br /&gt;&lt;br /&gt;All this leads to the mentality that arrays and pointers are interchangeable - but this is only sometimes true. This is exactly the trap that I fell into when I declared this function:&lt;br /&gt;&lt;br /&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;void runAction(unsigned char ** flashpos, ...);&lt;/div&gt;&lt;br /&gt;Officially, this is not a problem as long as I dereference the variable flashpos correctly - after all, it &lt;b&gt;is &lt;/b&gt;pointing to the start of an array somewhere. It points the start of a sequential Nx16 table of chars. As long as I use the correct number of dereference operators in the right order, I should be able to access it's delicious chocolatey elements.&lt;br /&gt;&lt;br /&gt;Hence, there was no compiler error.&lt;br /&gt;&lt;br /&gt;What I got instead was the warning: "Incompatible data types in arg 1 of blah blah blah."&lt;br /&gt;&lt;br /&gt;Warnings are usually thrown when the compiler is letting you know that you might be doing something you didn't intend, but it's not something illegal so it figures you know what you're doing.&lt;br /&gt;&lt;br /&gt;Foolishly, I assumed that the error was being thrown due to a signed vs unsigned conflict and went ahead and &lt;i&gt;cast the argument being passed into an (unsigned char**)&lt;/i&gt;.&lt;br /&gt;&lt;br /&gt;Then, I proceeded to access the data like the multidimensional array that it was:&lt;br /&gt;&lt;br /&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;x = pgm_read_byte(flashpos[i][j]);&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Robobob went haywire. Can anyone see what went wrong?&lt;br /&gt;&lt;br /&gt;The problem was that the compiler didn't know how many columns the table had. It's the equivalent of me giving you a book and asking for the 4th page in the 10th column. It doesn't make any sense unless you know how to arrange the pages!&lt;br /&gt;&lt;br /&gt;You see, it would have worked fine if I had just used the form:&lt;br /&gt;&lt;br /&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;x = pgm_read_byte(*(flashpos+(i*16+j)));&lt;/div&gt;&lt;br /&gt;But in the absence of the necessary metadata, the compiler had attempted to use the second form of referencing described above - i.e., the jth integer pointed to by the ith pointer in the variable flashpos. Which of course sent it searching for arbitrary values all over the place.&lt;br /&gt;&lt;br /&gt;After I realised what was going on, all I had to do was simply change the declaration to:&lt;br /&gt;&lt;br /&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;void runAction(unsigned char flashpos[][MOTORS], ...);&lt;/div&gt;&lt;br /&gt;Which informed the compiler of the &lt;i&gt;subtype&lt;/i&gt; and dimensions of multidimensional array being referenced.&lt;br /&gt;&lt;br /&gt;Always remember that warnings are there for a reason! Maybe you &lt;i&gt;do&lt;/i&gt; know best, but the compiler is letting you know that you've done something ambiguous or potentially dangerous.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4136375076360613625-545426342860057170?l=buildtherobot.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://buildtherobot.blogspot.com/feeds/545426342860057170/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://buildtherobot.blogspot.com/2010/03/honour-thy-compiler-and-thy-linker.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/545426342860057170'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/545426342860057170'/><link rel='alternate' type='text/html' href='http://buildtherobot.blogspot.com/2010/03/honour-thy-compiler-and-thy-linker.html' title='Honour thy compiler and thy linker'/><author><name>Alex Jarkey</name><uri>http://www.blogger.com/profile/02033809613943284663</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_PZjyemYqS8E/S0uqTx1jdrI/AAAAAAAAAFM/EVGW1FeCizY/S220/peas.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4136375076360613625.post-8582047638758919983</id><published>2010-03-02T19:25:00.000-08:00</published><updated>2010-03-02T19:26:37.354-08:00</updated><title type='text'>Robot destroys car, house, you</title><content type='html'>I think it's supposed to be a bomb disposal robot, but I think the bomb might do less damage.&lt;br /&gt;&lt;br /&gt;&lt;object width="480" height="295"&gt;&lt;param name="movie" value="http://www.youtube.com/v/3lUz5Gkg2G8&amp;hl=en_US&amp;fs=1&amp;"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/3lUz5Gkg2G8&amp;hl=en_US&amp;fs=1&amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="295"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4136375076360613625-8582047638758919983?l=buildtherobot.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://buildtherobot.blogspot.com/feeds/8582047638758919983/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://buildtherobot.blogspot.com/2010/03/robot-destroys-car-house-you.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/8582047638758919983'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/8582047638758919983'/><link rel='alternate' type='text/html' href='http://buildtherobot.blogspot.com/2010/03/robot-destroys-car-house-you.html' title='Robot destroys car, house, you'/><author><name>Alex Jarkey</name><uri>http://www.blogger.com/profile/02033809613943284663</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_PZjyemYqS8E/S0uqTx1jdrI/AAAAAAAAAFM/EVGW1FeCizY/S220/peas.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4136375076360613625.post-8197537966127129412</id><published>2010-03-01T04:39:00.000-08:00</published><updated>2010-03-01T04:55:52.831-08:00</updated><title type='text'>Congratulations! You're our 2000th visitor!</title><content type='html'>&lt;script src="http://www.google.com/friendconnect/script/friendconnect.js" type="text/javascript"&gt;&lt;/script&gt;Thats right, today marks the day that over 2000 people have visited this blog! I would like to thank you all for your interest in my work, and I hope I can look forward to many more visitors over the coming year. I've added a variety of social media links to the right sidebar, so please share this with your friends!&lt;br /&gt;&lt;br /&gt;To&amp;nbsp;commemorate&amp;nbsp;this occasion, I present to you &lt;a href="http://www.robosavvy.com/Builders/badcommandorfilename/buildtherobot_v0.4.zip"&gt;version 0.4&lt;/a&gt; of the custom robobuilder software. This version includes &lt;a href="http://buildtherobot.blogspot.com/2010/01/bear-necessities.html"&gt;timer-based&lt;/a&gt; scheduling of &lt;a href="http://buildtherobot.blogspot.com/2010/01/puzzle.html"&gt;movement&lt;/a&gt;, battery &lt;a href="http://buildtherobot.blogspot.com/2009/12/son-of-voltron.html"&gt;recharging capabilities&lt;/a&gt;, microphone operation and the ability to change state based upon button presses. A few small &lt;a href="http://buildtherobot.blogspot.com/2010/01/its-not-bug-its-feature.html"&gt;bugs&lt;/a&gt; have been fixed since last time, but as usual this is still a beta release - don't expect flawless operation just yet. Compiling instructions are &lt;a href="http://buildtherobot.blogspot.com/2010/01/byte-by-byte.html"&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Unfortunately, this release does not contain the FFT or &lt;a href="http://buildtherobot.blogspot.com/2010/02/robobob-life-of-party.html"&gt;leet dancing skillz&lt;/a&gt;. I've decided that I'm going to put a bit more work into improving them before I make them&amp;nbsp;available for download. I'm sure you are all eager to get your groove on, so check back soon for updates.&lt;br /&gt;&lt;br /&gt;In related news, this guy has given me many ideas for how to expand &lt;a href="http://buildtherobot.blogspot.com/2010/02/robobob.html"&gt;robobob&lt;/a&gt;'s repertoire of dance moves.&lt;br /&gt;&lt;br /&gt;&lt;object height="344" width="425"&gt;&lt;param name="movie" value="http://www.youtube.com/v/nYMSXV8eT0w&amp;hl=en_US&amp;fs=1&amp;"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/nYMSXV8eT0w&amp;hl=en_US&amp;fs=1&amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;br /&gt;&lt;br /&gt;And he's not even in time with the music! Of course, that's just the &lt;a href="http://www.youtube.com/watch?v=ZYv1o9k71S0"&gt;beginning&lt;/a&gt;...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4136375076360613625-8197537966127129412?l=buildtherobot.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://buildtherobot.blogspot.com/feeds/8197537966127129412/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://buildtherobot.blogspot.com/2010/03/congratulations-youre-our-2000th.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/8197537966127129412'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/8197537966127129412'/><link rel='alternate' type='text/html' href='http://buildtherobot.blogspot.com/2010/03/congratulations-youre-our-2000th.html' title='Congratulations! You&apos;re our 2000th visitor!'/><author><name>Alex Jarkey</name><uri>http://www.blogger.com/profile/02033809613943284663</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_PZjyemYqS8E/S0uqTx1jdrI/AAAAAAAAAFM/EVGW1FeCizY/S220/peas.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4136375076360613625.post-3035410210482412003</id><published>2010-02-23T23:21:00.000-08:00</published><updated>2010-02-23T23:22:36.603-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='robot'/><category scheme='http://www.blogger.com/atom/ns#' term='dance'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><title type='text'>Robobob: Life of the party</title><content type='html'>&lt;a href="http://www.youtube.com/watch?v=XJ32ER7qJsk"&gt;Dancing&lt;/a&gt; &lt;a href="http://www.youtube.com/watch?v=ZhwTYzUhPm8"&gt;robots&lt;/a&gt; have been around for some time now, I'll give you that. Generally they are simply scripted lists of moves which are&amp;nbsp;&lt;a href="http://www.youtube.com/watch?v=l882xbFywho"&gt;synchronized&lt;/a&gt;&amp;nbsp;(&lt;a href="http://www.youtube.com/watch?v=9XD_csNQ9l4"&gt;or not&lt;/a&gt;) to a particular song. It took some hard work, but I've managed to take a different approach:&lt;br /&gt;&lt;br /&gt;&lt;object height="344" width="425"&gt;&lt;param name="movie" value="http://www.youtube.com/v/SZzCdi2LUtI&amp;hl=en_US&amp;fs=1&amp;"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/SZzCdi2LUtI&amp;hl=en_US&amp;fs=1&amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;br /&gt;&lt;br /&gt;This dance isn't scripted! It's being generated based on the music being played, which means that Robobob will dance in time with any music you care to play to him!&lt;br /&gt;&lt;br /&gt;Well, most music. The tempo is detected using a Fast &lt;a href="http://en.wikipedia.org/wiki/Fourier_transform"&gt;Fourier Transform&lt;/a&gt;, which can separate beats and&amp;nbsp;bass-lines&amp;nbsp;from the rest of the music. This works great for songs with a strong bass component, but doesn't work so well on music composed of higher frequencies or vocals.&lt;br /&gt;&lt;br /&gt;Simply place your robobuilder on the nearest&amp;nbsp;&lt;a href="http://en.wikipedia.org/wiki/Sub_Woofer"&gt;sub woofer&lt;/a&gt;&amp;nbsp;though, and you should be in&amp;nbsp;business!&lt;br /&gt;&lt;br /&gt;Watch in amazement as your robotic buddy dances along (almost) in time to the beat!&lt;br /&gt;&lt;br /&gt;Impress your friends with his funky dancing styles consisting of over TWO distinct moves!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4136375076360613625-3035410210482412003?l=buildtherobot.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://buildtherobot.blogspot.com/feeds/3035410210482412003/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://buildtherobot.blogspot.com/2010/02/robobob-life-of-party.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/3035410210482412003'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/3035410210482412003'/><link rel='alternate' type='text/html' href='http://buildtherobot.blogspot.com/2010/02/robobob-life-of-party.html' title='Robobob: Life of the party'/><author><name>Alex Jarkey</name><uri>http://www.blogger.com/profile/02033809613943284663</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_PZjyemYqS8E/S0uqTx1jdrI/AAAAAAAAAFM/EVGW1FeCizY/S220/peas.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4136375076360613625.post-7441893300592441933</id><published>2010-02-13T23:58:00.000-08:00</published><updated>2010-02-14T03:58:36.538-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><category scheme='http://www.blogger.com/atom/ns#' term='comic'/><title type='text'>Computers 103</title><content type='html'>The &lt;a href="http://buildtherobot.blogspot.com/2010/02/computers-102.html"&gt;gnome&lt;/a&gt; is &lt;a href="http://buildtherobot.blogspot.com/2010/02/computers-101.html"&gt;back&lt;/a&gt;! This time, he has a very important message for you about registers. Please give him your undivided attention, or there may be consequences. 0_o&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_PZjyemYqS8E/S3flWktsz4I/AAAAAAAAAG0/Ko-SXBYHRoI/s1600-h/gnome3.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="393" src="http://4.bp.blogspot.com/_PZjyemYqS8E/S3flWktsz4I/AAAAAAAAAG0/Ko-SXBYHRoI/s400/gnome3.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;I hope you are enjoying these comics. I will be making more of them, but I am also working on upgrading &lt;a href="http://buildtherobot.blogspot.com/2010/02/robobob.html"&gt;Robobob&lt;/a&gt;. I think you will be pleasantly surprised, so check back soon!&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4136375076360613625-7441893300592441933?l=buildtherobot.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://buildtherobot.blogspot.com/feeds/7441893300592441933/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://buildtherobot.blogspot.com/2010/02/computers-103.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/7441893300592441933'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/7441893300592441933'/><link rel='alternate' type='text/html' href='http://buildtherobot.blogspot.com/2010/02/computers-103.html' title='Computers 103'/><author><name>Alex Jarkey</name><uri>http://www.blogger.com/profile/02033809613943284663</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_PZjyemYqS8E/S0uqTx1jdrI/AAAAAAAAAFM/EVGW1FeCizY/S220/peas.bmp'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_PZjyemYqS8E/S3flWktsz4I/AAAAAAAAAG0/Ko-SXBYHRoI/s72-c/gnome3.png' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4136375076360613625.post-7347701050858699584</id><published>2010-02-10T15:12:00.000-08:00</published><updated>2010-02-10T15:12:10.965-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='software'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><category scheme='http://www.blogger.com/atom/ns#' term='comic'/><title type='text'>Computers 102</title><content type='html'>For your amenity, the next installment of "inside your CPU" is avaliable below. If your screen is big enough, you shouldn't even need to scroll. The &lt;a href="http://buildtherobot.blogspot.com/2010/02/computers-101.html"&gt;previous issue&lt;/a&gt; can be even be found &lt;a href="http://buildtherobot.blogspot.com/2010/02/computers-101.html"&gt;here&lt;/a&gt;. Convenience!!&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_PZjyemYqS8E/S3M5pNr6wnI/AAAAAAAAAGk/m383efSr7rk/s1600-h/gnome2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="393" src="http://4.bp.blogspot.com/_PZjyemYqS8E/S3M5pNr6wnI/AAAAAAAAAGk/m383efSr7rk/s400/gnome2.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;(If you don't get the joke in the last panel, it is because the "take one down" action will eventually set the zero flag in the status register, but the "pass it around" line will never set the zero flag. The branch instruction can only know about the results of the operation &lt;i&gt;immediately&lt;/i&gt; before it, so the gnome will eventually die of alcohol poisoning. THINK OF THE GNOMES!)&lt;br /&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;In other exciting news, the source code I used to make &lt;a href="http://buildtherobot.blogspot.com/2010/02/robobob.html"&gt;this video&lt;/a&gt; is now avaliable. You can find it &lt;a href="http://robosavvy.com/Builders/badcommandorfilename/buildtherobot_v0.3.zip"&gt;here&lt;/a&gt;. There are a few improvements and bug fixes.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4136375076360613625-7347701050858699584?l=buildtherobot.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://buildtherobot.blogspot.com/feeds/7347701050858699584/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://buildtherobot.blogspot.com/2010/02/computers-102.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/7347701050858699584'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/7347701050858699584'/><link rel='alternate' type='text/html' href='http://buildtherobot.blogspot.com/2010/02/computers-102.html' title='Computers 102'/><author><name>Alex Jarkey</name><uri>http://www.blogger.com/profile/02033809613943284663</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_PZjyemYqS8E/S0uqTx1jdrI/AAAAAAAAAFM/EVGW1FeCizY/S220/peas.bmp'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_PZjyemYqS8E/S3M5pNr6wnI/AAAAAAAAAGk/m383efSr7rk/s72-c/gnome2.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4136375076360613625.post-5824191264415577606</id><published>2010-02-09T19:24:00.000-08:00</published><updated>2010-02-10T14:54:19.914-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><category scheme='http://www.blogger.com/atom/ns#' term='comic'/><title type='text'>Computers 101</title><content type='html'>I'm taking a little hiatus from the epic how to build your &lt;a href="http://buildtherobot.blogspot.com/2010/02/build-your-own-humanoid-part-1.html"&gt;own&lt;/a&gt; &lt;a href="http://buildtherobot.blogspot.com/2010/02/build-your-own-humanoid-part-2.html"&gt;robot&lt;/a&gt; series for a few reasons.&lt;br /&gt;&lt;br /&gt;Firstly, there is a LOT to cover. I'm writing this as a sort of trial run for how I might explain it to first year university students, and as we all know - firsties are only marginally more intelligent than the rats they &lt;a href="http://www.machall.com/view.php?date=2005-06-02"&gt;experiment on&lt;/a&gt;. With so many topics to cover, I'm faced with either giving 10 second "just take my word for it" style advice, or deviating from the topic every paragraph to explain the reasoning behind the statements I've just made.&lt;br /&gt;&lt;br /&gt;The other problem is that it isn't &lt;a href="http://buildtherobot.blogspot.com/2009/12/i-was-just-reading-over-some-of-my.html"&gt;fun to read&lt;/a&gt;. It's very technically dense and wordy, and I feel that if I can't hold the reader's interest then there isn't much point in me spending all this time  explaining it. After writing the how to choose servos article, I really felt that I should have introduced it with an earlier article about exactly how they worked and what they were used for.&lt;br /&gt;&lt;br /&gt;So to remedy this, I've decided to take a different approach to the rest of the series. Before I start spouting off about &lt;a href="http://buildtherobot.blogspot.com/2010/01/its-not-bug-its-feature.html"&gt;software&lt;/a&gt; and &lt;a href="http://buildtherobot.blogspot.com/2010/01/puzzle.html"&gt;microcontrollers&lt;/a&gt; and &lt;a href="http://buildtherobot.blogspot.com/2010/01/bear-necessities.html"&gt;interrupts&lt;/a&gt;, I'm going to give you some background on the subject in general – just so that everyone is up to speed when I use terms like instruction set, word size or stack overflow.&lt;br /&gt;&lt;br /&gt;What's more, to keep things interesting the lessons will take place in funky 8-bit comic style! Enjoy!&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_PZjyemYqS8E/S3M5BKqKDzI/AAAAAAAAAGc/cqb4SJ0PY-g/s1600-h/gnome1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="393" src="http://4.bp.blogspot.com/_PZjyemYqS8E/S3M5BKqKDzI/AAAAAAAAAGc/cqb4SJ0PY-g/s400/gnome1.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4136375076360613625-5824191264415577606?l=buildtherobot.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://buildtherobot.blogspot.com/feeds/5824191264415577606/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://buildtherobot.blogspot.com/2010/02/computers-101.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/5824191264415577606'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/5824191264415577606'/><link rel='alternate' type='text/html' href='http://buildtherobot.blogspot.com/2010/02/computers-101.html' title='Computers 101'/><author><name>Alex Jarkey</name><uri>http://www.blogger.com/profile/02033809613943284663</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_PZjyemYqS8E/S0uqTx1jdrI/AAAAAAAAAFM/EVGW1FeCizY/S220/peas.bmp'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_PZjyemYqS8E/S3M5BKqKDzI/AAAAAAAAAGc/cqb4SJ0PY-g/s72-c/gnome1.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4136375076360613625.post-7897569769788391920</id><published>2010-02-09T14:55:00.000-08:00</published><updated>2010-02-09T15:54:49.156-08:00</updated><title type='text'>Build your own humanoid - Part 2</title><content type='html'>&lt;a href="http://buildtherobot.blogspot.com/2010/02/build-your-own-humanoid-part-1.html"&gt;Last time&lt;/a&gt;, I started going over a basic outline of how you might go about designing your own humanoid robot.&lt;br /&gt;&lt;br /&gt;After I finished writing part 1, I realized that there is a lot more to cover on each topic than I am able to explain in a single post. All I am covering here is a design methodology - one of many possible procedures. This means that if I skim over a topic or don't go into sufficient detail, you will need to do a bit of research on your own to fill in the blanks.&lt;br /&gt;&lt;br /&gt;After deciding upon the number of degrees of articulation you intend to build into your robot, I suggested that the next step should be to draft up some approximate measurements for the arms, legs and body.&lt;br /&gt;&lt;br /&gt;Some people find this difficult. Coming up with a number for a length or a weight almost without any input information seems pointless and arbitrary, since there are so many variables which affect and are affected by your decision. This is why I emphasize the inexact nature of these dimensions at this stage. We will come back and refine them once we have more details.&lt;br /&gt;&lt;br /&gt;If you have the time, the tools and the expertise required to draw up an exact model of all the designable variables and how they correlate to each other, then this is a perfectly acceptable method. I personally find the &lt;a href="http://en.wikipedia.org/wiki/Iterative_and_incremental_development"&gt;iterative method&lt;/a&gt; is easier and less prone to mistakes.&lt;br /&gt;&lt;br /&gt;At this stage, you would do well to open up a spreadsheet and enter all the values you have chosen so far. You can quickly sum up all the masses and lengths (warning: &lt;a href="http://en.wikipedia.org/wiki/Trigonometric_functions"&gt;trigonometry&lt;/a&gt;), and it will help you quickly calculate your servo requirements.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;b&gt;Servos&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Servos are not the only type of actuators you can use, but they are certainly the most commonly used. I'm going to assume most people will choose to use servo or stepper motors, but don't feel limited by this. You might want to use a combination.&lt;br /&gt;&lt;br /&gt;There are two main alternatives to electric motors. The first is pneumatic actuators, like the ones used here:&lt;br /&gt;&lt;br /&gt;&lt;object height="344" width="425"&gt;&lt;param name="movie" value="http://www.youtube.com/v/FUihpG15ZRc&amp;hl=en_US&amp;fs=1&amp;"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/FUihpG15ZRc&amp;hl=en_US&amp;fs=1&amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;br /&gt;&lt;br /&gt;The other option is shape-memory alloy, known as muscle-wire or nitinol:&lt;br /&gt;&lt;br /&gt;&lt;object height="344" width="425"&gt;&lt;param name="movie" value="http://www.youtube.com/v/znPM2Ssb920&amp;hl=en_US&amp;fs=1&amp;"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/znPM2Ssb920&amp;hl=en_US&amp;fs=1&amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;br /&gt;&lt;br /&gt;Both of these have niche uses, but you will find that servo motors are more general purpose.&lt;br /&gt;&lt;br /&gt;Unlike normal DC motors, servos are motors which can be commanded to move to a specific rotational angle. To achieve this, they contain a feedback loop which will keep turning the motor in the right direction until it reaches it's destination.&lt;br /&gt;&lt;br /&gt;I could go on for pages about the specific inner workings of a servo (and I probably will someday), but right now we need to concentrate on three technical specifications:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Torque.&lt;/b&gt; When searching for servos, they should all report a stall torque in kilogram-centimeters or ounce-inches. These numbers represent how much weight they will be able to lift (on planet earth) at a distance of one centimeter or one inch away from the axis of rotation. More is generally better, but will come at a higher price.&lt;br /&gt;&lt;br /&gt;How much do you need? This is why it is so important to have a rough idea of the proportions of your robot. I forgot to mention it before, but now would be a good time to also estimate the weight of your batteries and other heavy components. &lt;br /&gt;&lt;br /&gt;Lets assume you want to choose an appropriate servo for your knee. The knee servo will be required to lift the entire weight of the robot from a crouched position to standing.&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/_PZjyemYqS8E/S3D0AkUgZWI/AAAAAAAAAF0/HeTqTRLFOyA/s1600-h/knee.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="300" src="http://1.bp.blogspot.com/_PZjyemYqS8E/S3D0AkUgZWI/AAAAAAAAAF0/HeTqTRLFOyA/s400/knee.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;To calculate the torque, you multiply the weight by the horizontal distance between the axis and the center of mass.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&amp;nbsp;T = Fxd&lt;/div&gt;&lt;br /&gt;In the above example, the robot's body weight is centered over it's hips, which is 5cm from the knee. His upper body is about 750g, so 0.75kg*5.0cm = 3.75kgcm is required to get the robot stand up.&lt;br /&gt;&lt;br /&gt;He also has two knees which can work together, so really each servo only needs to have 1.9kgcm to stand up. However, when he walks we can assume each leg will need to work independently, so we should stick with the original value.&lt;br /&gt;&lt;br /&gt;So use your estimated lengths and masses to come up with some numbers for the torque on each joint. You will have to imagine the &lt;i&gt;most difficult&lt;/i&gt; movement your robot will be required to perform in order to find the necessary values.&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;If you aren't sure how much your robot will weigh, remember that we are trying to build an under 1kg robot. If you know it can move 1kg, it will be enough.&lt;/li&gt;&lt;li&gt;Similarly, the time your robot will be required to deliver the most torque is when it has fallen over. If you are unsure, use half of the robot's height as the distance, since this is representative of the single servo being used to stand up.&lt;/li&gt;&lt;/ul&gt;There are much more complex methods of calculating the required torque, but there isn't much point in going to the trouble since you mostly just estimated values anyway. If you're having trouble, &lt;a href="http://www.lightandmatter.com/html_books/2cl/ch05/ch05.html"&gt;here&lt;/a&gt; is everything you ever needed to know about &lt;a href="http://www.wikipedia.org/"&gt;everything&lt;/a&gt;. &lt;br /&gt;&lt;br /&gt;Now you should have an estimate for the value of each joint. This is the minimum torque you will need to move the joint. Since your estimates were pretty sketchy to begin with, you should add a &lt;a href="http://en.wikipedia.org/wiki/Factor_of_safety#Design_factor_and_safety_factor"&gt;factor of safety&lt;/a&gt; to ensure you've got enough. I would suggest increasing all your estimates by 50%, or even more if you don't feel confident about your calculations.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Mass.&lt;/b&gt; Servos which deliver more torque are generally larger due to the fact that they contain more gears and heavy duty parts to withstand the extra forces.&lt;br /&gt;&lt;br /&gt;Heavier servos will increase your requirements for torque. Sometimes, this will be unavoidable, but it's effects can be alleviated by making your robot shorter.&lt;br /&gt;&lt;br /&gt;You can also reposition heavier parts so that they are closer to the axis you are rotating around. This will reduce the power of the servos you need and make your robot lighter overall.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Speed.&lt;/b&gt; The price of a servo is usually determined by it's torque and it's speed. Fast, strong servos will be particularly expensive, so it's important to only get what you need.&lt;br /&gt;&lt;br /&gt;Rotational speeds are measured in seconds per 60 degrees. This is the time it takes to complete one sixth of a full revolution - lower means faster.&lt;br /&gt;&lt;br /&gt;Not all of your servos will need to be lightning fast - only walking and balancing will require a lot of agility. The proportions of your robot will multiply how fast the limb will move. If you've designed longer legs, you won't need such speedy servos to walk at a reasonable pace.&lt;br /&gt;&lt;br /&gt;In particular, the ankle joints usually only need to move through about 10 degrees in a step, which means they can be much slower than the rest of the servos in the legs without impacting the performance.&lt;br /&gt;&lt;br /&gt;Now that you know what properties each servo needs, you will have to search around to find one which matches.&lt;br /&gt;&lt;b&gt; &lt;/b&gt;&lt;br /&gt;It's pretty unlikely you will find exactly what you are looking for, but thats fine. Near enough is good enough - up until now everything has been pretty approximate, so no reason to stop here. Remember that the point of this exercise is not optimization - just getting a robot with two legs on the ground is all we want for now. Here are a few more things to consider when choosing servos:&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Metal gears will save you a &lt;a href="http://buildtherobot.blogspot.com/2009/12/saftey-first.html"&gt;lot&lt;/a&gt; &lt;a href="http://buildtherobot.blogspot.com/2009/12/two-steps-forward.html"&gt;of&lt;/a&gt; &lt;a href="http://buildtherobot.blogspot.com/2009/11/it-was-only-matter-of-time.html"&gt;trouble&lt;/a&gt;.&lt;/li&gt;&lt;li&gt;A lot of robots simply get one type of servo for every joint. The advantage of this is that it's easier to repair and easier to build since you only use one set of parts. However, your robot will be heavier and more expensive than it needs to be.&lt;/li&gt;&lt;li&gt;There is more than one way to control a servo. Digital and analog servos require 50Hz PWM control, but some robotics servos use RS232 or &lt;a href="http://buildtherobot.blogspot.com/2009/12/saftey-first.html"&gt;RS485&lt;/a&gt; protocols. Right now it doesn't matter which you choose, but make sure all of them use the same method.&lt;/li&gt;&lt;li&gt;Many servos offer extra features like adjustable PID parameters, overload protection and position feedback. These are valuable additions, and you would be wise to take advantage of them.&lt;/li&gt;&lt;li&gt;Most servos have a limited range of rotation. Often, this is around 270 degrees, but can be as little as 90. For most joints, 270 will give you a sufficient amount of freedom, but check you have enough.&lt;/li&gt;&lt;/ul&gt;Here comes the important bit. Having chosen a servo for every joint on your robot, &lt;b&gt;go back and do the torque calculations again&lt;/b&gt;. This shouldn't be hard if you've put everything in a spreadsheet - just use the new torque and mass of every servo you've chosen, and make sure that your requirements are still met.&lt;br /&gt;&lt;br /&gt;Chances are, you will find that most of your initial estimates were reasonable. If you find that one servo doesn't have enough power to move the robot anymore, you will either have to upgrade that one, downgrade one of your heavier ones, or adjust the dimensions of your robot. This may cause a cascade of other things to change, but that's just the catch 22 of design. Keep adjusting and recalculating until everything fits.&lt;br /&gt;&lt;br /&gt;Wasn't that fun? No, it wasn't really. But at least now you know that the money you are spending on parts won't be wasted. &lt;br /&gt;&lt;ul&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4136375076360613625-7897569769788391920?l=buildtherobot.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://buildtherobot.blogspot.com/feeds/7897569769788391920/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://buildtherobot.blogspot.com/2010/02/build-your-own-humanoid-part-2.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/7897569769788391920'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/7897569769788391920'/><link rel='alternate' type='text/html' href='http://buildtherobot.blogspot.com/2010/02/build-your-own-humanoid-part-2.html' title='Build your own humanoid - Part 2'/><author><name>Alex Jarkey</name><uri>http://www.blogger.com/profile/02033809613943284663</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_PZjyemYqS8E/S0uqTx1jdrI/AAAAAAAAAFM/EVGW1FeCizY/S220/peas.bmp'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_PZjyemYqS8E/S3D0AkUgZWI/AAAAAAAAAF0/HeTqTRLFOyA/s72-c/knee.png' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4136375076360613625.post-4105911750428617732</id><published>2010-02-04T19:25:00.000-08:00</published><updated>2010-02-04T19:25:54.397-08:00</updated><title type='text'>Build your own humanoid - Part 1</title><content type='html'>Not &lt;a href="http://buildtherobot.blogspot.com/2010/01/come-with-me-if-you-want-to-live.html"&gt;long ago&lt;/a&gt;, I spoke about the advantages of humanoid robo-one style combat over battlebots/robot wars matches.&lt;br /&gt;&lt;br /&gt;I started thinking about how difficult it might be to start up a competition at my university. Would people be interested? Would it be too expensive? Too complex? Perhaps I would be wrong about people appreciating the tactics and design over brute force destruction. &lt;br /&gt;&lt;br /&gt;So I thought I'd walk myself through the process of designing and building a small (under 1kg) humanoid robot, to see how it might play out. Keep in mind that while I do know a lot about humanoid robots, and I also own one; I have never build one from scratch before. I do have experience building other robots, but not walking ones.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;b&gt;Design &lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;First of all, lets have a look at how other people have gone about it. This is often a very good first step when you are uncertain about a project.&lt;br /&gt;&lt;br /&gt;&lt;embed allowfullscreen="true" allowscriptaccess="always" id="VideoPlayback" src="http://video.google.com/googleplayer.swf?docid=4564803622267434918&amp;amp;hl=en&amp;amp;fs=true" style="height: 326px; width: 400px;" type="application/x-shockwave-flash"&gt;&lt;/embed&gt; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;object height="344" width="425"&gt;&lt;param name="movie" value="http://www.youtube.com/v/1mehxBh7rsA&amp;hl=en_GB&amp;fs=1&amp;"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/1mehxBh7rsA&amp;hl=en_GB&amp;fs=1&amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;br /&gt;&lt;br /&gt;One of the first things I notice about these robots is that they are humanoid, &lt;a href="http://buildtherobot.blogspot.com/2010/02/tremble-before-dishzor.html"&gt;not human&lt;/a&gt;. When it comes to designing robots, people often get very caught up in biomimicry, without stopping to think about why they are imitating nature's design. In the case of both these robots, the proportions have been modified to make it easier for the robot to &lt;a href="http://buildtherobot.blogspot.com/2010/01/one-step-at-time.html"&gt;balance&lt;/a&gt; and &lt;a href="http://buildtherobot.blogspot.com/2009/12/two-steps-forward.html"&gt;walk&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;As a general rule, shorter and squatter will make your life easier later on down the track. Keeping the robot's center of mass low will also make him harder to knock &lt;a href="http://buildtherobot.blogspot.com/2010/02/robobob.html"&gt;over&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;At this stage, you will also need to decide how many degrees of freedom you want your robot to have. To robotologists, a degree of freedom is a controllable aspect of the robot. In this case, it refers to the number of joints your robot will have and therefore how complex his actions can be.&lt;br /&gt;&lt;br /&gt;Bottom line is, more degrees of freedom means more versatile actions, but at the additional cost of more servos/actuators.&lt;br /&gt;&lt;br /&gt;Now, since we are trying to build a humanoid robot, the most attention needs to go to the legs. &lt;a href="http://buildtherobot.blogspot.com/2010/02/robobob.html"&gt;Robobob&lt;/a&gt; has 5 degrees of freedom in each leg. He has two ankle servos, one knee servo, one thigh servo and one hip servo.&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/_PZjyemYqS8E/S2uC3P4NkDI/AAAAAAAAAFs/4N_sqopp-sc/s1600-h/rightleg.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="333" src="http://3.bp.blogspot.com/_PZjyemYqS8E/S2uC3P4NkDI/AAAAAAAAAFs/4N_sqopp-sc/s400/rightleg.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;I would consider this a pretty good number, but you could get away with removing either the hip or one of the ankle servos and manage.&lt;br /&gt;&lt;br /&gt;So that's 10 controllable degrees of freedom just for the legs.&lt;br /&gt;&lt;br /&gt;The torso doesn't need to move at all, but giving it the ability to rotate will help allow your robot to shift it's weight quickly to maintain it's balance. Adding one additional servo won't break the bank, and it will contribute a lot to the moves you can perform.&lt;br /&gt;&lt;br /&gt;Arms can be as simple or as complex as you like. They do contribute to balance and walking a little, but far less than the torso or the legs. If you are building a robot to fight or wrestle, you will need arms to achieve this. However, if you have a torso which can rotate, all you will need to do with the arms is to raise and lower them in a flapping motion and rotate. If you take this approach, you can get away with as little as 13 servos.&lt;br /&gt;&lt;br /&gt;Of course, the exact implementation is up to you. It will depend on your budget and your requirements.&lt;br /&gt;&lt;br /&gt;Robobob has 16 degrees of freedom. 5 for each leg and 3 on each arm. This has worked out so far for me, and 16 is actually on the low end of kits available.&lt;br /&gt;&lt;br /&gt;If you want to have more than this, I would definiately consider adding them to the legs. A lot of robo-one robots use the double-knee joint, which allows them to stand up and walk twice as fast. The ankles also have a very big impact on how your robot will be able to walk, so if you can get x, y and z rotation on the ankles you will appreciate the advantages.&lt;br /&gt;&lt;br /&gt;The next stage is figuring out the approximate dimensions of your robot. I say approximate, because there is every chance that a design decision you make a little further on down the track will will require you to rethink his shape (eg, servo, battery size and weight).&lt;br /&gt;&lt;br /&gt;Draw up a skeletal model of your robot and come up with some trial values for the distances between joints. Here are a few things to consider:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Taller Robots are easier to knock down because of their higher center of gravity&lt;/li&gt;&lt;li&gt;Longer legs mean faster movement.&lt;/li&gt;&lt;li&gt;Shorter distances between joints will require less powerful servos.&lt;/li&gt;&lt;li&gt;Longer distances between joints will move the limb much more quickly.&lt;/li&gt;&lt;li&gt;Leave room for your batteries and circuitry.&lt;/li&gt;&lt;li&gt;Make it look cool! It's not all about optimizing numbers. &lt;/li&gt;&lt;/ul&gt;At this stage, keep it simple. These dimensions will help you select appropriate servos for your needs. If you aren't sure, have a look at existing humanoids and see what works. I will go over a more detailed design in the future.&lt;br /&gt;&lt;br /&gt;Next time, I'll talk about choosing the right servos. As you can tell, there is a bit of a catch-22 about design, since your choice of servos depends on your dimensions, which in turn will depend on your servo choice.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4136375076360613625-4105911750428617732?l=buildtherobot.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://buildtherobot.blogspot.com/feeds/4105911750428617732/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://buildtherobot.blogspot.com/2010/02/build-your-own-humanoid-part-1.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/4105911750428617732'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/4105911750428617732'/><link rel='alternate' type='text/html' href='http://buildtherobot.blogspot.com/2010/02/build-your-own-humanoid-part-1.html' title='Build your own humanoid - Part 1'/><author><name>Alex Jarkey</name><uri>http://www.blogger.com/profile/02033809613943284663</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_PZjyemYqS8E/S0uqTx1jdrI/AAAAAAAAAFM/EVGW1FeCizY/S220/peas.bmp'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_PZjyemYqS8E/S2uC3P4NkDI/AAAAAAAAAFs/4N_sqopp-sc/s72-c/rightleg.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4136375076360613625.post-5081683435742415896</id><published>2010-02-02T03:15:00.000-08:00</published><updated>2010-02-02T03:15:10.167-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='robot'/><category scheme='http://www.blogger.com/atom/ns#' term='control'/><category scheme='http://www.blogger.com/atom/ns#' term='balance'/><category scheme='http://www.blogger.com/atom/ns#' term='robobob'/><category scheme='http://www.blogger.com/atom/ns#' term='robobuilder'/><title type='text'>Robobob</title><content type='html'>Ladies and gentlemen, I give you: Robobob!&lt;br /&gt;&lt;br /&gt;&lt;object height="344" width="425"&gt;&lt;param name="movie" value="http://www.youtube.com/v/zXIRJMkWMCc&amp;hl=en_US&amp;fs=1&amp;"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/zXIRJMkWMCc&amp;hl=en_US&amp;fs=1&amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;br /&gt;&lt;br /&gt;You may recall that &lt;a href="http://buildtherobot.blogspot.com/2010/01/robot-by-any-other-name.html"&gt;awhile back&lt;/a&gt; I opened my inbox to email suggestions for a good name. I actually intended to draw the name randomly or put up a poll, but once I started calling him Robobob the name sort of just stuck.&lt;br /&gt;&lt;br /&gt;So here he is, in all his &lt;a href="http://buildtherobot.blogspot.com/2009/11/its-alive.html"&gt;16DOF&lt;/a&gt; glory standing up to a withering barrage of socks from all directions.&lt;br /&gt;&lt;br /&gt;Once again, he has no gyroscope or accelerometer - he is simply using kinematic feedback from his servos to keep himself stable. The algorithm is almost identical to the one I used way back in &lt;a href="http://buildtherobot.blogspot.com/2010/01/one-step-at-time.html"&gt;this post&lt;/a&gt; - but he can now withstand attacks from all directions.&lt;br /&gt;&lt;br /&gt;You may notice that he always moves with the force that he is being subjected to. This is the same way that humans usually react - recoiling from a blow or a source of pain. I think it gives him a bit of a &lt;a href="http://buildtherobot.blogspot.com/2010/02/tremble-before-dishzor.html"&gt;personality&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4136375076360613625-5081683435742415896?l=buildtherobot.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://buildtherobot.blogspot.com/feeds/5081683435742415896/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://buildtherobot.blogspot.com/2010/02/robobob.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/5081683435742415896'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/5081683435742415896'/><link rel='alternate' type='text/html' href='http://buildtherobot.blogspot.com/2010/02/robobob.html' title='Robobob'/><author><name>Alex Jarkey</name><uri>http://www.blogger.com/profile/02033809613943284663</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_PZjyemYqS8E/S0uqTx1jdrI/AAAAAAAAAFM/EVGW1FeCizY/S220/peas.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4136375076360613625.post-5298557918446986499</id><published>2010-02-01T01:51:00.000-08:00</published><updated>2010-02-01T01:51:11.001-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='mechanical'/><category scheme='http://www.blogger.com/atom/ns#' term='hexapod'/><category scheme='http://www.blogger.com/atom/ns#' term='biped'/><title type='text'>Tremble before DISHZOR!</title><content type='html'>People are often surprised them when I tell them that my favourite robot is the dishwasher. Not &lt;a href="http://www.youtube.com/watch?v=8E5s5cDQepk"&gt;Megatron&lt;/a&gt; or &lt;a href="http://www.youtube.com/watch?v=YPoANTKo5kA"&gt;ASIMO&lt;/a&gt; or the &lt;a href="http://www.youtube.com/watch?v=LQ-jv8g1YVI"&gt;roomba&lt;/a&gt; - just your ordinary, garden variety dishwasher.&lt;br /&gt;&lt;br /&gt;You see, there isn't much of a consensus regarding what defines a &lt;a href="http://buildtherobot.blogspot.com/2010/01/come-with-me-if-you-want-to-live.html"&gt;robot&lt;/a&gt; as a &lt;a href="http://buildtherobot.blogspot.com/2010/01/robots-are-our-friends.html"&gt;robot&lt;/a&gt;. Some people think they need to be &lt;a href="http://buildtherobot.blogspot.com/2010/01/one-step-at-time.html"&gt;humanoid&lt;/a&gt;. Others feel that robots should include &lt;a href="http://buildtherobot.blogspot.com/2009/12/son-of-voltron.html"&gt;sensors&lt;/a&gt; and &lt;a href="http://buildtherobot.blogspot.com/2009/11/it-was-only-matter-of-time.html"&gt;actuators&lt;/a&gt;. &lt;a href="http://buildtherobot.blogspot.com/2010/01/bear-necessities.html"&gt;Computers&lt;/a&gt; and &lt;a href="http://buildtherobot.blogspot.com/2010/01/puzzle.html"&gt;software &lt;/a&gt;are often mentioned.&lt;br /&gt;&lt;br /&gt;One of the broader, but generally well received definitions is that a robot is a machine of some sort, capable of performing tasks on it's own. Begrudgingly, most people will admit that this would include dishwashers. And washing machines, printers and even modern cooking appliances.&lt;br /&gt;&lt;br /&gt;Thats right - robots have already invaded your home and you didn't even realise! &lt;a href="http://www.youtube.com/watch?v=rwcDY4Zzm_o"&gt;Insidious&lt;/a&gt;!&lt;br /&gt;&lt;br /&gt;I think one of the reasons that these everyday robots have slipped under our radar is that we don't have such high expectations of them. We assume robots should be smart, since they are capable of performing the same tasks which humans can - but we tend to assume that tasks which are difficult for us are difficult for everyone.&lt;br /&gt;&lt;br /&gt;Sci-Fi has led us to bestow a level of expectation on a robot which is based on their appearance. For example, &lt;a href="http://en.wikipedia.org/wiki/List_of_robotic_dogs#In_fiction"&gt;dog shaped robots&lt;/a&gt; tend to be about as smart as &lt;a href="http://www.youtube.com/watch?v=MowYR1wcA8o&amp;amp;feature=related"&gt;actual dogs&lt;/a&gt;, despite the fact that their &lt;a href="http://en.wikipedia.org/wiki/Positronic_brain"&gt;positronic brains&lt;/a&gt; could make them just as smart as a human. Robotic &lt;a href="http://www.youtube.com/watch?v=LULVxYTdx3g&amp;amp;feature=related"&gt;bugs&lt;/a&gt; will behave exactly like real bugs would, even though they have no reason to seek dark places or put on threatening displays.&lt;br /&gt;&lt;br /&gt;In the case of dishwashers, we tend to assume that machines shaped like large bricks will have an equivalent IQ. That's probably why I find this so much less impressive than it actually is.&lt;br /&gt;&lt;br /&gt;&lt;object height="344" width="425"&gt;&lt;param name="movie" value="http://www.youtube.com/v/lFEX5zNvP9M&amp;hl=en_GB&amp;fs=1&amp;"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/lFEX5zNvP9M&amp;hl=en_GB&amp;fs=1&amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;br /&gt;&lt;br /&gt;It's no small feat, but it just seems that a multi robot system like that should be capable of so much &lt;b&gt;more&lt;/b&gt;.&lt;br /&gt;&lt;br /&gt;This phenomenon also means that as soon as you give your robot a humanoid form, people suddenly have much higher expectations. I think this is why modern &lt;a href="http://world.honda.com/ASIMO/history/"&gt;demonstration&lt;/a&gt; robots are given infant-like designs - if the robot reminds people of a five year old, then they will be that much more impressed when it walks without falling over or grasping objects.&lt;br /&gt;&lt;br /&gt;&lt;object height="344" width="425"&gt;&lt;param name="movie" value="http://www.youtube.com/v/q11LSccMPFo&amp;hl=en_GB&amp;fs=1&amp;"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/q11LSccMPFo&amp;hl=en_GB&amp;fs=1&amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;br /&gt;&lt;br /&gt;So if you are ever trying to demonstrate how smart your robot artificial intelligence is, remember to make it look stupid so that people will be extra impressed. It also helps to &lt;a href="http://www.youtube.com/watch?v=WbFFs4DHWys"&gt;avoid&lt;/a&gt; the &lt;a href="http://en.wikipedia.org/wiki/Uncanny_valley"&gt;uncanny valley&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4136375076360613625-5298557918446986499?l=buildtherobot.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://buildtherobot.blogspot.com/feeds/5298557918446986499/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://buildtherobot.blogspot.com/2010/02/tremble-before-dishzor.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/5298557918446986499'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/5298557918446986499'/><link rel='alternate' type='text/html' href='http://buildtherobot.blogspot.com/2010/02/tremble-before-dishzor.html' title='Tremble before DISHZOR!'/><author><name>Alex Jarkey</name><uri>http://www.blogger.com/profile/02033809613943284663</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_PZjyemYqS8E/S0uqTx1jdrI/AAAAAAAAAFM/EVGW1FeCizY/S220/peas.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4136375076360613625.post-4583228809900296917</id><published>2010-01-29T15:49:00.000-08:00</published><updated>2010-01-31T01:14:16.983-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='mechanical'/><category scheme='http://www.blogger.com/atom/ns#' term='robo-one'/><category scheme='http://www.blogger.com/atom/ns#' term='biped'/><title type='text'>Come with me - if you want to live.</title><content type='html'>I finally watched Terminator Salvation the other night.&lt;br /&gt;&lt;br /&gt;I couldn't work out if the machines actually knew who Kyle Reese was or why they wanted to capture him - and also why they didn't just kill him &lt;a href="http://tvtropes.org/pmwiki/pmwiki.php/Main/EvilOverlordList"&gt;when they had the chance!&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;There was also the matter of how lightly guarded skynet central was (despite apparently producing about 1 T800 per second), and how those motorcycle robots were supposed to get up if someone knocked them over.&lt;br /&gt;&lt;br /&gt;What I really wanted to talk about though, was the &lt;a href="http://buildtherobot.blogspot.com/2010/01/robots-are-our-friends.html"&gt;Robopocalypse&lt;/a&gt;. Not so much the idea that robots will eventually &lt;a href="http://odeo.com/episodes/6613-Professor-Frink-Chaos-Theory"&gt;rise up&lt;/a&gt; against their human masters, but just about how robots (or any machine) can be &lt;a href="http://en.wikipedia.org/wiki/Kenji_Urada"&gt;dangerous &lt;/a&gt;if people are careless around them.&lt;br /&gt;&lt;br /&gt;I used to be vice-president of the Sydney University Mechatronics Organization, which held a yearly robot wars competition. Now, as you can imagine, robots designed to tear each other to bits would be equally (more?) effective at maiming pathetic squishy humans, so it was hard to disregard OH&amp;amp;S.&lt;br /&gt;&lt;br /&gt;Despite a strong emphasis on safety, the university was in a difficult position when it came to allowing students to use their facilities. If we were injured in one of the workshops or laboratories, then the uni was liable - even if we were being properly supervised or if it was due to our own negligence. However, if we attempted to work on the robot outside of the university, we were without the appropriate tools and safety equipment and were significantly &lt;i&gt;more likely&lt;/i&gt; to injure ourselves. This created many headaches and administrative woes, which ultimatley turned what should have been a fun and simple activity for students into a legislative nightmare.&lt;br /&gt;&lt;br /&gt;This is why I am so much in favor of the smaller and safer &lt;a href="http://buildtherobot.blogspot.com/2009/12/i-was-just-reading-over-some-of-my.html"&gt;robo-one&lt;/a&gt; &lt;a href="http://buildtherobot.blogspot.com/2009/12/two-steps-forward.html"&gt;style&lt;/a&gt; competition. I think it is a more elegant form of robot combat, for a more &lt;a href="http://xkcd.com/297/"&gt;civilized&lt;/a&gt; age.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;object height="344" width="425"&gt;&lt;param name="movie" value="http://www.youtube.com/v/j1rBVSdWwTA&amp;hl=en_US&amp;fs=1&amp;"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/j1rBVSdWwTA&amp;hl=en_US&amp;fs=1&amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;br /&gt;&lt;br /&gt;This video is from a new humanoid competition called RT Corp under 1kg Robot Fight. Like robo-one, it emphasizes lightweight robots which wrestle each other in a ring.&lt;br /&gt;&lt;br /&gt;I think that this is a better direction for schools and universities who want to encourage students to learn about robots and mechatronics while having a bit of fun.&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Robot wars robots are glorified remote control cars. There, I said it. Many designs, like wedges or saws don't need any additional circuitry to control their weapons. The design is primarily in the mechanical field, and students will learn very little about the electrical or software side.&lt;/li&gt;&lt;li&gt;It's so much safer. There are no dangerous weapons, and the weight limit is also much lower (unless you're &lt;a href="http://www.youtube.com/watch?v=NlZWQO6T1LI"&gt;these guys&lt;/a&gt;). The machining process is also much simpler (use tin-snips instead of table saws, solder instead of welding, etc).&lt;/li&gt;&lt;li&gt;You get to keep your robot at the end. One of the most annoying things about robot wars is that if you lost, your robot was toast. Nothing gets damaged or destroyed in a wrestling match, so you are free to upgrade and modify parts for next time.&lt;/li&gt;&lt;li&gt;The emphasis is on design and technique, not raw power. Software, real-time control, electrical systems and weight distribution are just as important as how strong your motors are.&lt;/li&gt;&lt;li&gt;It's just as exciting. Robots can take their inspiration from boxing, tae-kwon do, ju-jitsu, MMA, akido, pancrase or any other type of martial art.&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;&lt;ol&gt;&lt;/ol&gt;The biggest drawback is that it can be quite expensive to build these little guys, but probably not by a huge margin. Our 13kg Robot wars Robots cost $300-500 (excluding the remote controls, which were borrowed), but I can see a under 1kg robot being build for a similar amount.&lt;br /&gt;&lt;br /&gt;If that doesn' convince you, just look at how much fun these guys are having!&lt;br /&gt;&lt;br /&gt;&lt;object height="344" width="425"&gt;&lt;param name="movie" value="http://www.youtube.com/v/LBdVNV02tmA&amp;hl=en_US&amp;fs=1&amp;"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/LBdVNV02tmA&amp;hl=en_US&amp;fs=1&amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;br /&gt;&lt;br /&gt;&lt;object height="344" width="425"&gt;&lt;param name="movie" value="http://www.youtube.com/v/M08VTM9D_HQ&amp;hl=en_US&amp;fs=1&amp;"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/M08VTM9D_HQ&amp;hl=en_US&amp;fs=1&amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4136375076360613625-4583228809900296917?l=buildtherobot.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://buildtherobot.blogspot.com/feeds/4583228809900296917/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://buildtherobot.blogspot.com/2010/01/come-with-me-if-you-want-to-live.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/4583228809900296917'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/4583228809900296917'/><link rel='alternate' type='text/html' href='http://buildtherobot.blogspot.com/2010/01/come-with-me-if-you-want-to-live.html' title='Come with me - if you want to live.'/><author><name>Alex Jarkey</name><uri>http://www.blogger.com/profile/02033809613943284663</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_PZjyemYqS8E/S0uqTx1jdrI/AAAAAAAAAFM/EVGW1FeCizY/S220/peas.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4136375076360613625.post-8954095277404324699</id><published>2010-01-27T17:14:00.000-08:00</published><updated>2010-01-28T14:59:09.289-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='internet'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><category scheme='http://www.blogger.com/atom/ns#' term='interrupt'/><title type='text'>It's not a bug, it's a feature</title><content type='html'>&lt;a href="http://buildtherobot.blogspot.com/2010/01/puzzle.html"&gt;Mystery&lt;/a&gt; solved!&lt;br /&gt;&lt;br /&gt;Here is a quote from the avrlibc documentation (which I probably should have looked at &lt;a href="http://buildtherobot.blogspot.com/2010/01/byte-by-byte.html"&gt;earlier&lt;/a&gt;):&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;In order for these functions to work as intended, compiler optimizations &lt;i&gt;must&lt;/i&gt; be enabled, and the delay time &lt;i&gt;must&lt;/i&gt; be an expression that is a known constant at compile-time. If these requirements are not met, the resulting delay will be much longer (and basically unpredictable), and applications that otherwise do not use floating-point calculations will experience severe code bloat by the floating-point library routines linked into the application.&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;This describes exactly the symptoms I was experiencing - if the function was passed a constant, it worked flawlessly. If I was using a value fetched from program &lt;a href="http://buildtherobot.blogspot.com/2010/01/byte-by-byte.html"&gt;memory&lt;/a&gt;, then the compiler was unable to determine how many &lt;a href="http://en.wikipedia.org/wiki/Nop"&gt;NOP&lt;/a&gt;s should be performed and the delay was unpredictable.&lt;br /&gt;&lt;br /&gt;I don't really know why the library function requires prior knowledge of how long a delay should last. All a &lt;a href="http://en.wikipedia.org/wiki/Spinlock"&gt;spin&lt;/a&gt; loop does is keep the processor &lt;a href="http://en.wikipedia.org/wiki/Busy_waiting"&gt;busy&lt;/a&gt; for a set number of cycles. If you need longer, you can simply put another loop around the first loop to multiply it's effects. Sure, without careful calculations you can lose your nanosecond accuracy, but when you are working in the millisecond range it is usually unimportant if you are off by a few clock cycles.&lt;br /&gt;&lt;br /&gt;If you want the best accuracy, you should be using a timer or counter &lt;a href="http://buildtherobot.blogspot.com/2010/01/bear-necessities.html"&gt;interrupt &lt;/a&gt;anyway...&lt;br /&gt;&lt;br /&gt;..but that's a story for another night. I don't intend to be using spin loops for future &lt;a href="http://buildtherobot.blogspot.com/2010/01/bear-necessities.html"&gt;versions&lt;/a&gt; anyway.&lt;br /&gt;&lt;br /&gt;Thanks to the people who emailed me and suggested that I might be accidentally passing the &lt;a href="http://en.wikipedia.org/wiki/Data_type"&gt;value&lt;/a&gt; of the pointer to the function, instead of the &lt;a href="http://en.wikipedia.org/wiki/Dereference"&gt;dereferenced&lt;/a&gt; value. That would also explain the strange behaviour, but it would also have shown up in the compiler &lt;a href="http://en.wikipedia.org/wiki/Type_system#Type_checking"&gt;output&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;In other news - what's up with the &lt;a href="http://www.internetblackout.com.au/"&gt;horrible popup&lt;/a&gt;?&lt;br /&gt;&lt;br /&gt;If you don't live in Australia (or perhaps even if you do) you might be unaware that the Australian government is considering introducing &lt;a href="http://www.abc.net.au/news/stories/2009/12/15/2772467.htm"&gt;mandatory&lt;/a&gt; &lt;a href="http://www.smh.com.au/opinion/society-and-culture/internet-filter-laws-need-urgent-public-debate-20091216-kwdk.html"&gt;filtering&lt;/a&gt; of internet sites.&lt;br /&gt;&lt;br /&gt;Much like &lt;a href="http://gothamist.com/2010/01/14/8-year-old_boy_cant_get_name_off_ai.php"&gt;draconian&lt;/a&gt; &lt;a href="http://www.boingboing.net/2005/05/12/tsa_doesnt_allow_zip.html"&gt;airport&lt;/a&gt; &lt;a href="http://xkcd.com/651/"&gt;security&lt;/a&gt;, national &lt;a href="http://blog.onghome.com/2003/12/problems-with-biometrics.htm"&gt;identity&lt;/a&gt; &lt;a href="http://www.actnow.com.au/Issues/National_identity_cards.aspx"&gt;cards&lt;/a&gt; and &lt;a href="http://www.alternet.org/rights/75208"&gt;racial&lt;/a&gt; &lt;a href="http://arstechnica.com/science/news/2009/02/study-racial-profiling-no-more-effective-than-random-screen.ars"&gt;profiling&lt;/a&gt;, this filter is supposed to be being put in place for our "protection". Because apparently Australians can't be trusted with unregulated free speech and freedom of information.&lt;br /&gt;&lt;br /&gt;I understand that &lt;a href="http://www.youtube.com/watch?v=Qh2sWSVRrmo"&gt;some people&lt;/a&gt; are willing to sacrifice their personal liberties for the comforting feeling of saftey, but the problem is not with the filter as it exists now, but what it &lt;b&gt;&lt;a href="http://news.bbc.co.uk/2/hi/programmes/click_online/4587622.stm"&gt;could&lt;/a&gt; &lt;a href="http://en.wikipedia.org/wiki/Internet_censorship_in_the_People%27s_Republic_of_China"&gt;become&lt;/a&gt;.&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;First they came for the communists, and I did not speak out—because I was not a communist;&lt;br /&gt;Then they came for the trade unionists, and I did not speak out—because I was not a trade unionist;&lt;br /&gt;Then they came for the Jews, and I did not speak out—because I was not a Jew;&lt;br /&gt;Then they came for me—and there was no one left to speak out.&lt;br /&gt;&lt;/blockquote&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4136375076360613625-8954095277404324699?l=buildtherobot.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://buildtherobot.blogspot.com/feeds/8954095277404324699/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://buildtherobot.blogspot.com/2010/01/its-not-bug-its-feature.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/8954095277404324699'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/8954095277404324699'/><link rel='alternate' type='text/html' href='http://buildtherobot.blogspot.com/2010/01/its-not-bug-its-feature.html' title='It&apos;s not a bug, it&apos;s a feature'/><author><name>Alex Jarkey</name><uri>http://www.blogger.com/profile/02033809613943284663</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_PZjyemYqS8E/S0uqTx1jdrI/AAAAAAAAAFM/EVGW1FeCizY/S220/peas.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4136375076360613625.post-5659935710146670194</id><published>2010-01-25T17:34:00.000-08:00</published><updated>2010-01-25T17:34:31.142-08:00</updated><title type='text'>Byte by byte</title><content type='html'>Here are a few things which might aid you in your &lt;a href="http://buildtherobot.blogspot.com/2010/01/puzzle.html"&gt;detective work&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;First of all, I am still using &lt;a href="http://winavr.sourceforge.net/"&gt;avr-gcc&lt;/a&gt; and &lt;a href="http://www.nongnu.org/avr-libc/"&gt;avrlibc&lt;/a&gt; to build the code. To achieve this, you first need to:&lt;br /&gt;&lt;br /&gt;compile,&lt;br /&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;avr-gcc -mmcu=atmega128 -I. -g -Wall -Os -c *.c&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;link,&lt;br /&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;avr-gcc -o main.elf -mmcu=atmega128 *.o&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;and then pack&lt;br /&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;avr-objcopy -j .text -O ihex main.elf main.hex&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Then download the resulting .hex file using the RBCUpgradeTool. Note that you can simply switch the RBC block off and on, rather than messing around with the reset pin.&lt;br /&gt;&lt;br /&gt;This should help anyone who is trying to get to the bottom of the &lt;a href="http://buildtherobot.blogspot.com/2010/01/puzzle.html"&gt;mystery&lt;/a&gt; I spoke about earlier. I also promised to talk a little about transferring data from the program space into working memory.&lt;br /&gt;&lt;br /&gt;Unlike desktop computers, embedded systems are built according to the Harvard Architecture which keeps the program instructions separate from the working memory. They even have separate buses, which means that an opcode and an operand can be fetched on a single clock cycle. In normal operation, there is no need to exchange data between the two areas of memory, since self modifying code has been all but banished to the history books.&lt;br /&gt;&lt;br /&gt;Sometimes, you find yourself running out of working memory especially if you are storing large tables or arrays which will eat up the free addresses very quickly. Also beware of memory leaks. Unlike a desktop with an operating system, your program won't segfault or blue-screen to let you know something is wrong - it will probably just start suddenly spewing garbage.&lt;br /&gt;&lt;br /&gt;However, if you absolutley must use giant arrays or matricies in your program, you can keep your RAM free by storing them in the&lt;i&gt; program memory&lt;/i&gt; and then copy it out only when you need to use it. This is done by using the LMP (LoadProgramMemory) instruction, which enables a special register which shifts the data from the program bus onto the data bus.&lt;br /&gt;&lt;br /&gt;Unfortunatley, because the data bus is still only 8 bits wide, memory has to be loaded one byte at a time - so ints (which are 16 bits) need special routines to make sure that the high and low bytes are stored in adjacent locations. Also, reading a byte from flash memory (where the program is stored) takes more than a few clock cycles, during which execution needs to halt. Reading a large table could take up to a second.&lt;br /&gt;&lt;br /&gt;Most of the details and heavy lifting are handled by special hardware and instructions on the microcontroller, and core data types like floats have library functions in avrlibc. It is still the responsibility of the programmer to know when to load a table, and particularly to make sure that any memory loaded goes out of scope or is free()d when the operation is complete.&lt;br /&gt;&lt;br /&gt;The canned actions which are made using the robobuilder software suite can be exported as 16xN tables, where N is the number of poses (there are 16 servos for the basic robobuilder). For a complicated action, this could be many, many bytes - so the tables are necessarily stored in the flash memory. And of course, since only one action can be performed at a time, you can store dozens of actions in the 128kB of flash and simply swap them out when one needs to be performed.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4136375076360613625-5659935710146670194?l=buildtherobot.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://buildtherobot.blogspot.com/feeds/5659935710146670194/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://buildtherobot.blogspot.com/2010/01/byte-by-byte.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/5659935710146670194'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/5659935710146670194'/><link rel='alternate' type='text/html' href='http://buildtherobot.blogspot.com/2010/01/byte-by-byte.html' title='Byte by byte'/><author><name>Alex Jarkey</name><uri>http://www.blogger.com/profile/02033809613943284663</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_PZjyemYqS8E/S0uqTx1jdrI/AAAAAAAAAFM/EVGW1FeCizY/S220/peas.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4136375076360613625.post-8597623171437743960</id><published>2010-01-22T18:49:00.000-08:00</published><updated>2010-01-25T18:01:22.582-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='robot'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='software'/><category scheme='http://www.blogger.com/atom/ns#' term='robobuilder'/><title type='text'>A puzzle</title><content type='html'>Boy do I have a good one for you today!&lt;br /&gt;&lt;br /&gt;First off, version 0.2 pre-pre-alpha-alpha-etc is &lt;a href="http://robosavvy.com/Builders/badcommandorfilename/buildtherobot_v0.2.zip"&gt;available&lt;/a&gt;. Please download it and try it out - report any bugs or suggestions in the comments.&lt;br /&gt;&lt;br /&gt;The improvements in this update focus on enabling the execution of pre-generated actions, such as those from the robobuilder site. A few are included in the Hunobasic.h header for demonstration purposes. I have also written a few useful functions to transfer data from program memory to working memory (which will probably be the subject of the next update).&lt;br /&gt;&lt;br /&gt;In keeping with the &lt;a href="http://buildtherobot.blogspot.com/2010/01/bear-necessities.html"&gt;philosophy&lt;/a&gt; of not trying to rewrite the default firmware, I've broken the procedure for executing an action (which is a series of poses) into much smaller steps, which makes it much more intuitive.&lt;br /&gt;&lt;br /&gt;Here is the method of making the robot walk forwards:&lt;br /&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; getPGMWordArray((int*)HunoBasic_WalkForward_TrTime, (int*)delay, HUNOBASIC_WALKFORWARD_NUM_ACTION);&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;b&gt;//Load transition times&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; for(i = 0; i &amp;lt;= HUNOBASIC_WALKFORWARD_NUM_ACTION; i++)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;b&gt;//For every pose in the action,&lt;/b&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; getPGMByteArray((char*)HunoBasic_WalkForward_Position[i],(char*)position,16);&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;b&gt;//Load the angle for each of the servos&lt;/b&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; setPose(position,torque,16);&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;b&gt;//Tell each servo to move&lt;/b&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; if(i &amp;lt; (HUNOBASIC_WALKFORWARD_NUM_ACTION))&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;b&gt;//After each frame, except the last,&lt;/b&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; j = delay[i];&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; while(j &amp;gt; 0){_delay_ms(1);j--;}&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;b&gt;//Pause for the required transition time....&amp;nbsp;&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;b&gt;//&lt;/b&gt;&lt;i&gt;&lt;b&gt;wait...&amp;nbsp;&lt;/b&gt;&lt;/i&gt;&lt;br /&gt;&lt;/div&gt;&lt;b&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;//&lt;/span&gt;&lt;/b&gt;&lt;i&gt;&lt;b&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;..WTF??&lt;/span&gt;&lt;/b&gt;&lt;/i&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;What's up with that last part? Why would you loop ten times and each time delay for 1ms, when you could just delay for 10ms in one go?&lt;br /&gt;&lt;br /&gt;Well, here's why - &lt;b&gt;it doesn't work&lt;/b&gt;!&lt;br /&gt;&lt;br /&gt;Substituting the line with:&lt;br /&gt;&lt;br /&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;_delay_ms(delay[i]);&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;will pause for a much longer time than it should. If you have a AVR, please test this out for me and confirm it. However, passing a constant value to _delay_ms() works exactly as intended. I've tried it many ways, but this is the only method which works so far.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;_delay_ms(25);&lt;/span&gt;&lt;br /&gt;works, but&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;delay[i] = 25;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;_delay_ms(delay[i]);&lt;/span&gt;&lt;br /&gt;does not. &lt;br /&gt;&lt;br /&gt;Mysterious.&lt;br /&gt;&lt;br /&gt;As I've mentioned before, this solution is &lt;a href="http://buildtherobot.blogspot.com/2010/01/bear-necessities.html"&gt;hacky and unattractive&lt;/a&gt;. But I thought I might upload the code (the rest of which is working fine) and see if anyone has any suggestions as to why this might be.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4136375076360613625-8597623171437743960?l=buildtherobot.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://buildtherobot.blogspot.com/feeds/8597623171437743960/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://buildtherobot.blogspot.com/2010/01/puzzle.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/8597623171437743960'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/8597623171437743960'/><link rel='alternate' type='text/html' href='http://buildtherobot.blogspot.com/2010/01/puzzle.html' title='A puzzle'/><author><name>Alex Jarkey</name><uri>http://www.blogger.com/profile/02033809613943284663</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_PZjyemYqS8E/S0uqTx1jdrI/AAAAAAAAAFM/EVGW1FeCizY/S220/peas.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4136375076360613625.post-4824858147949578836</id><published>2010-01-15T20:27:00.000-08:00</published><updated>2010-01-25T18:01:06.929-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='robot'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='software'/><category scheme='http://www.blogger.com/atom/ns#' term='robobuilder'/><title type='text'>One step back</title><content type='html'>&lt;a href="http://buildtherobot.blogspot.com/2010/01/bear-necessities.html"&gt;That wasn't so hard.&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;I think that this code will be more useful to anyone who is trying to use the robobuilder for educational purposes. My goal is not to rewrite the official firmware, but to let programmers have access to the functionality of the RBC and the wCKs.&lt;br /&gt;&lt;br /&gt;Code can be found &lt;a href="http://robosavvy.com/Builders/badcommandorfilename/buildtherobot_v0.1.zip"&gt;here&lt;/a&gt;. It is in pre-pre-alpha mode at the moment, so use it at your own risk. You might want to read &lt;a href="http://buildtherobot.blogspot.com/2009/12/saftey-first.html"&gt;this&lt;/a&gt; before you test it out.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4136375076360613625-4824858147949578836?l=buildtherobot.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://buildtherobot.blogspot.com/feeds/4824858147949578836/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://buildtherobot.blogspot.com/2010/01/one-step-back.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/4824858147949578836'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/4824858147949578836'/><link rel='alternate' type='text/html' href='http://buildtherobot.blogspot.com/2010/01/one-step-back.html' title='One step back'/><author><name>Alex Jarkey</name><uri>http://www.blogger.com/profile/02033809613943284663</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_PZjyemYqS8E/S0uqTx1jdrI/AAAAAAAAAFM/EVGW1FeCizY/S220/peas.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4136375076360613625.post-9023784778839276257</id><published>2010-01-15T01:10:00.000-08:00</published><updated>2010-01-15T03:30:20.024-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><category scheme='http://www.blogger.com/atom/ns#' term='interrupt'/><title type='text'>Bear necessities</title><content type='html'>I was recently &lt;a href="http://www.stumbleupon.com/url/www.buildtherobot.blogspot.com/"&gt;stumbl'dupon&lt;/a&gt; - which was appreciated. I'm glad to know that people out there are finding my work useful.&lt;br /&gt;&lt;br /&gt;Along with the increased traffic came several requests for the source code for some of my more &lt;a href="http://buildtherobot.blogspot.com/2010/01/one-step-at-time.html"&gt;interesting&lt;/a&gt; &lt;a href="http://buildtherobot.blogspot.com/2009/12/mirror-mirror.html"&gt;achievements&lt;/a&gt;. &lt;br /&gt;&lt;br /&gt;I am, of course, more than happy to provide it - you may have noticed that source code is one of those things which I &lt;a href="http://buildtherobot.blogspot.com/2010/01/one-step-at-time.html"&gt;often promise&lt;/a&gt; but &lt;a href="http://buildtherobot.blogspot.com/2009/12/son-of-voltron.html"&gt;seldom deliver&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;However, there is a good reason for my apparent reluctance to upload my work as of late, and it can be fairly accurately summarised in two words: self confidence.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.natpryce.com/articles/000756.html"&gt;For some reason&lt;/a&gt;, programmers have an ingrained tendency to look at any code written by &lt;a href="http://onsmalltalk.com/my-personal-pet-peeves-i-see-in-other-peoples-code"&gt;someone&lt;/a&gt; &lt;a href="http://exodusdev.com/blog/mike/hell-is-other-peoples-code"&gt;other&lt;/a&gt; &lt;a href="http://www.joelonsoftware.com/articles/fog0000000069.html"&gt;than&lt;/a&gt; &lt;a href="http://designbygravity.wordpress.com/2009/10/23/how-to-read-other-peoples-code-and-why/"&gt;themselves&lt;/a&gt; and immediately write it off as &lt;a href="http://www.dailywtf.com/"&gt;garbage&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;In some cases, this is probably just good old fashioned &lt;a href="http://en.wikipedia.org/wiki/Hubris"&gt;hubris&lt;/a&gt;. But my current working theory is that in programming there are so many levels of mastery and so many potential solutions to any problem. Code using &lt;a href="http://en.wikipedia.org/wiki/Anti-pattern"&gt;paradigms&lt;/a&gt; which are advanced and unfamiliar seem needlessly complicated, while basic (but probably equally effective) methods of performing a task are often written off as trivial and inelegant.&lt;br /&gt;&lt;br /&gt;So I tried to be understanding. Sure, I might not have done it that &lt;i&gt;particular&lt;/i&gt; way myself, but with a positive mindset I could see the logic behind most of the design decisions.&lt;br /&gt;&lt;br /&gt;But try as I might, I kept having to resort to ugly hacks to get the code to do what I wanted while still maintaining it's original functionality. After awhile, I had to sacrifice the default behaviour altogether. Eventually, I found myself rewriting huge sections of code in order to make even the most basic functions work reliably. But I figured that I had come this far with the official code, and it would just take me too long to find an alternative.&lt;br /&gt;&lt;br /&gt;Until I saw this:&lt;br /&gt;&lt;div style="border: 1px solid black; display: block; height: 400px; overflow-y: scroll; width: 400px;"&gt;&lt;br /&gt;&lt;blockquote&gt;ISR(TIMER1_OVF_vect)&amp;nbsp; &lt;br /&gt;{ &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if( gFrameIdx == gNumOfFrame ) &lt;br /&gt;{&amp;nbsp;&amp;nbsp; // are we at the end of the scene ? &lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; gFrameIdx = 0; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; RUN_LED1_OFF; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; F_PLAYING=0;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; // clear F_PLAYING state &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; TIMSK &amp;amp;= 0xfb;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; // Timer1 Overflow Interrupt disable &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; TCCR1B=0x00; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; return; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TCNT1=TxInterval; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TIFR |= 0x04;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; // restart timer &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TIMSK |= 0x04;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; // Timer1 Overflow Interrupt enable &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; MakeFrame();&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; // build the wCK frame &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SendFrame();&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; // send the wCK frame &lt;br /&gt;}&lt;br /&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;br /&gt;void MakeFrame(void) &lt;br /&gt;{ &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; while(gTx0Cnt);&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; // wait until the transmit buffer is empty &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; gFrameIdx++;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; // next frame &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SyncPosSend();&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; // build new frame &lt;br /&gt;} &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;//------------------------------------------------------------------------------ &lt;br /&gt;// Start sending the frame &lt;br /&gt;//------------------------------------------------------------------------------ &lt;br /&gt;void SendFrame(void) &lt;br /&gt;{ &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(gTx0Cnt==0)&amp;nbsp;&amp;nbsp;&amp;nbsp; return;&amp;nbsp;&amp;nbsp;&amp;nbsp; // return if no frame to send &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; gTx0BufIdx++; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sciTx0Data(gTx0Buf[gTx0BufIdx-1]);&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; // send first byte to start frame send &lt;br /&gt;} &lt;br /&gt;&lt;br /&gt;&lt;/blockquote&gt;&lt;blockquote&gt;void SyncPosSend(void)&amp;nbsp; &lt;br /&gt;{ &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; int lwtmp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; BYTE CheckSum;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; BYTE i, tmp, Data; &lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Data = (Scene.wCK[0].Torq&amp;lt;&amp;lt;5) | 31; // get the torque for the scene &lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; gTx0Buf[gTx0Cnt]=HEADER; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; gTx0Cnt++;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; gTx0Buf[gTx0Cnt]=Data; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; gTx0Cnt++;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; gTx0Buf[gTx0Cnt]=16;&amp;nbsp; // This is the (last ID - 1) why is it hardcoded ? &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; gTx0Cnt++;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CheckSum = 0; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for(i=0;i&lt;max_wck;i++){&amp;nbsp;&amp;nbsp;&amp;nbsp; all="" for="" wck&amp;nbsp;=""&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; if(Scene.wCK[i].Exist){&amp;nbsp;&amp;nbsp;&amp;nbsp; // if wCK exists add the interpolation step &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; lwtmp = (int)Scene.wCK[i].SPos + (int)((float)gFrameIdx*gUnitD[i]); &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; if(lwtmp&amp;gt;254)&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; lwtmp = 254; // bound result 1 to 254 &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; else if(lwtmp&amp;lt;1)&amp;nbsp;&amp;nbsp;&amp;nbsp; lwtmp = 1; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; tmp = (BYTE)lwtmp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; gTx0Buf[gTx0Cnt] = tmp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; gTx0Cnt++;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; // put into transmit buffer &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; CheckSum = CheckSum^tmp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CheckSum = CheckSum &amp;amp; 0x7f; &lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; gTx0Buf[gTx0Cnt]=CheckSum; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; gTx0Cnt++;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; // put into transmit buffer &lt;br /&gt;}&amp;nbsp; &lt;br /&gt;&lt;/max_wck;i++){&amp;nbsp;&amp;nbsp;&amp;nbsp;&gt;&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;That was probably a bit on the long side. But here's a quick tip for programmers working on embedded systems - if it's too long to post on your blog, it's too long to put in AN INTERRUPT!&lt;br /&gt;&lt;br /&gt;&lt;a href="http://en.wikipedia.org/wiki/Interrupt"&gt;Interrupts&lt;/a&gt; need to be short. When an interrupt fires, everything else is put &lt;a href="http://www.nongnu.org/avr-libc/user-manual/group__avr__interrupts.html"&gt;on hold &lt;/a&gt;until the RETI (return from interrupt) instruction is performed. If your code spends too long in an interrupt, you risk missing other important events such as sending instructions to servos, receiving serial transmissions, or responding to any other interrupt.&lt;br /&gt;&lt;br /&gt;What's worse: since all these events have been put on hold when the RETI instruction actually is received, all these issues now have to be dealt with at once. It's not easy to predict what order they will be handled in either. This can lead to &lt;a href="http://en.wikipedia.org/wiki/Action_at_a_distance_%28computer_science%29"&gt;unpredictable&lt;/a&gt; behaviour which is very hard to debug.&lt;br /&gt;&lt;br /&gt;So to &lt;a href="http://www.sltf.com/articles/pein/pein9505.htm"&gt;summarise&lt;/a&gt;: bloated interrupts = bad.&lt;br /&gt;&lt;br /&gt;To return to my original point, I had been doing some very dodgy things in order to just get the darn thing to work. Things like arbitrary delays in the middle of functions (to make sure that whatever interrupt was expected had time to get itself sorted out), and lots of &lt;a href="http://en.wikipedia.org/wiki/Busy_spin"&gt;polling&lt;/a&gt; to ensure that the state of the program was predictable before I went and altered the global variables (of which there were many). Plus a not insignificant amount of &lt;a href="http://en.wikipedia.org/wiki/Black_magic_%28programming%29"&gt;arcane deep magic&lt;/a&gt;. &lt;br /&gt;&lt;br /&gt;Not the sort of work I wanted to put my name on.&lt;br /&gt;&lt;br /&gt;All that stuff I said about respecting other people's code remains valid, but only if it's actually doing what it is supposed to. So after a short &lt;a href="http://en.wikipedia.org/wiki/Guru_Meditation"&gt;meditation&lt;/a&gt;, I realised something very important: &lt;i&gt;I didn't need all this stuff.&amp;nbsp;&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;I had a very specific goal in mind, and 90% of the code I was having to circumvent was simply getting in the way. I only needed a few basic functions to achieve what I needed to do - and at this stage I was spending far too much time patching things up instead of fixing the problem at the source.&lt;br /&gt;&lt;br /&gt;With this in mind, I've begun working on a very simple library of functions which will deal with the simple, low level things that I am trying to achieve - without all the non-essential tasks getting in the way. With any luck, I will be able to make far more frequent source code updates now, since the releases will be far more minimalist and focused on a specific task - instead of trying to be a replacement for the default firmware.&lt;br /&gt;&lt;br /&gt;Until next time - &lt;a href="http://www.youtube.com/watch?v=aXwEBp3cKfM&amp;amp;feature=related"&gt;keep it simple&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4136375076360613625-9023784778839276257?l=buildtherobot.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://buildtherobot.blogspot.com/feeds/9023784778839276257/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://buildtherobot.blogspot.com/2010/01/bear-necessities.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/9023784778839276257'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/9023784778839276257'/><link rel='alternate' type='text/html' href='http://buildtherobot.blogspot.com/2010/01/bear-necessities.html' title='Bear necessities'/><author><name>Alex Jarkey</name><uri>http://www.blogger.com/profile/02033809613943284663</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_PZjyemYqS8E/S0uqTx1jdrI/AAAAAAAAAFM/EVGW1FeCizY/S220/peas.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4136375076360613625.post-7751905988910727687</id><published>2010-01-10T14:55:00.000-08:00</published><updated>2010-01-17T01:21:08.344-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='control'/><category scheme='http://www.blogger.com/atom/ns#' term='balance'/><title type='text'>A robot by any other name</title><content type='html'>I've been a &lt;a href="http://buildtherobot.blogspot.com/2010/01/form-vs-function.html"&gt;bit&lt;/a&gt; &lt;a href="http://buildtherobot.blogspot.com/2009/12/mirror-mirror.html"&gt;serious&lt;/a&gt; &lt;a href="http://buildtherobot.blogspot.com/2010/01/one-step-at-time.html"&gt;recently&lt;/a&gt;, so lets have some fun.&lt;br /&gt;&lt;br /&gt;First off, I've realised that &lt;a href="http://buildtherobot.blogspot.com/2009/11/its-alive.html"&gt;my robot&lt;/a&gt; is more than a month old now, but still has no name! I'm not good with names, so I thought I'd open it up to the floor and see if anyone had any suggestions.&lt;br /&gt;&lt;br /&gt;If possible, it should be a name which conveys his &lt;a href="http://buildtherobot.blogspot.com/2009/12/saftey-first.html"&gt;gentle&lt;/a&gt; nature, effervescent &lt;a href="http://buildtherobot.blogspot.com/2009/11/c-is-for-cookie.html"&gt;personality &lt;/a&gt;and love of &lt;a href="http://buildtherobot.blogspot.com/2009/11/it-was-only-matter-of-time.html"&gt;outdoor sports&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Next, it's time for the cool robot of the week!&lt;br /&gt;&lt;br /&gt;&lt;object height="344" width="425"&gt;&lt;param name="movie" value="http://www.youtube.com/v/Ci_y14y3DU4&amp;hl=en_GB&amp;fs=1&amp;"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/Ci_y14y3DU4&amp;hl=en_GB&amp;fs=1&amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;br /&gt;&lt;br /&gt;I've been talking about control theory quite a bit &lt;a href="http://buildtherobot.blogspot.com/2009/12/phase-1-collect-underpants.html"&gt;recently&lt;/a&gt;, and I've been doing some research into different methods which might be applicable to my &lt;a href="http://buildtherobot.blogspot.com/2010/01/one-step-at-time.html"&gt;dynamic balance&lt;/a&gt; problem. This video is of an inverted pendulum - the arm is free to rotate on the cart, and only the cart is free to move along the x-axis. The cart has a model of the system which it uses to swing the pendulum into a stable inverted state. This is a well studied area of control theory, and today's modern &lt;a href="http://www.youtube.com/watch?v=lwvTyC7m4LQ"&gt;robots&lt;/a&gt; (and &lt;a href="http://www.youtube.com/watch?v=ONC5UcGQHYg"&gt;humans&lt;/a&gt;) have been doing this for awhile. &lt;br /&gt;&lt;br /&gt;Not impressed? What about this:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;object height="344" width="425"&gt;&lt;param name="movie" value="http://www.youtube.com/v/7a-1DkJT004&amp;hl=en_GB&amp;fs=1&amp;"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/7a-1DkJT004&amp;hl=en_GB&amp;fs=1&amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;br /&gt;&lt;br /&gt;Same problem, but with an extra degree of freedom. Now there is a compound pendulum (one pendulum free to rotate off the first pendulum), but still only the one cart. This is a &lt;a href="http://en.wikipedia.org/wiki/Holonomic#Robotics"&gt;non-holonomic&lt;/a&gt; system, which is much harder to control using conventional control methods. &lt;br /&gt;&lt;br /&gt;Still not enough?&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;object height="344" width="425"&gt;&lt;param name="movie" value="http://www.youtube.com/v/lwJ2jzVexaI&amp;hl=en_GB&amp;fs=1&amp;"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/lwJ2jzVexaI&amp;hl=en_GB&amp;fs=1&amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;br /&gt;&lt;br /&gt;Here is the double pendulum problem again, but this time the cart has been replaced by an arm. Instead of being constrained to two dimensions, the control algorithm now has to cope with the non-linearity of moving the control arm in a 3D rotational space.&lt;br /&gt;&lt;br /&gt;I know it's not the cute little &lt;a href="http://buildtherobot.blogspot.com/2009/12/i-was-just-reading-over-some-of-my.html"&gt;humanoids&lt;/a&gt; you are &lt;a href="http://buildtherobot.blogspot.com/2009/12/two-steps-forward.html"&gt;used to&lt;/a&gt;, but from an engineering perspective this is significantly more impressive watching robots &lt;a href="http://buildtherobot.blogspot.com/2009/12/merry-christmas.html"&gt;dancing&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Ok, maybe &lt;a href="http://www.youtube.com/watch?v=9XD_csNQ9l4&amp;amp;feature=related"&gt;not&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4136375076360613625-7751905988910727687?l=buildtherobot.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://buildtherobot.blogspot.com/feeds/7751905988910727687/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://buildtherobot.blogspot.com/2010/01/robot-by-any-other-name.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/7751905988910727687'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/7751905988910727687'/><link rel='alternate' type='text/html' href='http://buildtherobot.blogspot.com/2010/01/robot-by-any-other-name.html' title='A robot by any other name'/><author><name>Alex Jarkey</name><uri>http://www.blogger.com/profile/02033809613943284663</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_PZjyemYqS8E/S0uqTx1jdrI/AAAAAAAAAFM/EVGW1FeCizY/S220/peas.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4136375076360613625.post-6566925923282530144</id><published>2010-01-08T16:36:00.000-08:00</published><updated>2010-01-08T16:43:19.443-08:00</updated><title type='text'>Robots are our friends</title><content type='html'>A while ago, I watched a news story about military robots. The tone was factual, but their "expert", so to speak, came off as a little bit alarmist (pro tip: remember to include more than one expert if you're trying to come off as unbiased).&lt;br /&gt;&lt;br /&gt;I can understand that to someone unfamiliar with computers and robots might see something like a &lt;a href="http://en.wikipedia.org/wiki/MQ-1_Predator"&gt;Predator&lt;/a&gt; and begin to feel uncomfortable. People always fear what they don't understand, so if a person believes that their &lt;a href="http://slashdot.org/article.pl?sid=04/10/05/1539203"&gt;car is trying to kill them&lt;/a&gt; or their &lt;a href="http://www.dansdata.com/magic.htm"&gt;computer is alive&lt;/a&gt; - surely anyone should be able to see that arming robots to the teeth is a bad thing (TM).&lt;br /&gt;&lt;br /&gt;The bottom line is though, that despite the layers of mechanical and digital abstraction that make up the robot, there is always a human at the other end who pulls the trigger.&lt;br /&gt;&lt;br /&gt;Today's &lt;a href="http://www.thenewatlantis.com/publications/military-robots-and-the-laws-of-war"&gt;military robots&lt;/a&gt; are really nothing more than glorified remote control cars with cameras attached. If only robots &lt;i&gt;were&lt;/i&gt; as advanced as movies and the media make them out to be. They have degrees of autonomy, such as navigating obstacles or maintaining a fixed altitude  flight path, but when it comes to the grizzly business of actually fighting, robots will always surrender control to an individual who is better suited to the task.&lt;br /&gt;&lt;br /&gt;The reason for this is simple - robot's can't interpret the world in the same way that people do. Sure - they can "see" with 5 megapixel camera, and "hear" with microphones, but all this data still needs to be interpereted in order for the robot to understand what the images and waveforms mean. The science of interpreting data into meaningful information is known as perception.&lt;br /&gt;&lt;br /&gt;Perception remains one of the hardest and least solved &lt;a href="http://www.sciencedaily.com/releases/2009/11/091111120724.htm"&gt;problems&lt;/a&gt; in robotics. There are videos of prototype robots like &lt;a href="http://www.youtube.com/watch?v=QfPkHU_36Cs"&gt;ASIMO&lt;/a&gt; who can see an object and remember what it is, but the robot is still only parroting what it has been told. Artificial intelligence still lacks the ability to process semantic information about it's environment.&lt;br /&gt;&lt;br /&gt;As humans, we have tens of years of experience which we can draw upon to derive the meaning of events going on around us. When confronted with an alien situation, we can look back into our vast database of knowledge and see if any of the information we have collected is relevant to understanding what is going on. Sometimes it's &lt;a href="http://www.youtube.com/watch?v=XJg_WMw56Hw"&gt;hard&lt;/a&gt;. Even humans make &lt;a href="http://en.wikipedia.org/wiki/Friendly_fire#Historical_examples"&gt;mistakes&lt;/a&gt;. And unless the robot has access to a human-like reservioir of knowledge about how to differentiate between a friendly and enemy soldier or a soldier who is surrendering or a &lt;a href="http://archive.gamespy.com/fargo/august03/autorpg/index.shtml"&gt;Sharnaff bull&lt;/a&gt;, the risks of friendly fire are simply too great. And the engineers who build robots &lt;a href="http://www.schneier.com/blog/archives/2009/03/history_and_eth.html"&gt;understand&lt;/a&gt; this.&lt;br /&gt;&lt;br /&gt;So if a robot can't correctly interpret the environment around it, it becomes no more useful than a &lt;a href="http://en.wikipedia.org/wiki/Land_mine"&gt;land mine&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;A very complicated, fragile and above all &lt;i&gt;expensive&lt;/i&gt; land mine.&lt;br /&gt;&lt;br /&gt;If an army wants to indiscriminately kill civilians, non-combat personnel and soliders from both sides, then there are much &lt;a href="http://en.wikipedia.org/wiki/Chemical_weapon"&gt;more&lt;/a&gt; &lt;a href="http://en.wikipedia.org/wiki/Biological_weapon"&gt;efficient&lt;/a&gt; &lt;a href="http://en.wikipedia.org/wiki/Carpet_bomb"&gt;methods&lt;/a&gt; of achieving it.&lt;br /&gt;&lt;br /&gt;But, in the hands of an intelligent operator, the robot becomes an effective battlefield participant who is far more expendable than your average squishy human - but just as much of a threat.&lt;br /&gt;&lt;br /&gt;From this perspective, you can see how military robots actually save lives. There are simply less humans exposed to danger. Nobody is going to get upset if a robot gets shot to pieces (except maybe the accountants).&lt;br /&gt;&lt;br /&gt;I think I should make it clear that I am not pro-war: just pro-robot. We've already tried the land mine thing, and it &lt;a href="http://en.wikipedia.org/wiki/International_Campaign_to_Ban_Landmines"&gt;failed&lt;/a&gt;. We don't need another generation of weapons which cannot discriminate between a soldier and a child. But if the robots are being used responsibly to keep humans out of dangerous situations, then it might be a step &lt;a href="http://www.albinoblacksheep.com/flash/robots"&gt;forward&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4136375076360613625-6566925923282530144?l=buildtherobot.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://buildtherobot.blogspot.com/feeds/6566925923282530144/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://buildtherobot.blogspot.com/2010/01/robots-are-our-friends.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/6566925923282530144'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/6566925923282530144'/><link rel='alternate' type='text/html' href='http://buildtherobot.blogspot.com/2010/01/robots-are-our-friends.html' title='Robots are our friends'/><author><name>Alex Jarkey</name><uri>http://www.blogger.com/profile/02033809613943284663</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_PZjyemYqS8E/S0uqTx1jdrI/AAAAAAAAAFM/EVGW1FeCizY/S220/peas.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4136375076360613625.post-6516850383143073609</id><published>2010-01-06T16:22:00.000-08:00</published><updated>2010-01-06T16:29:34.678-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='mechanical'/><category scheme='http://www.blogger.com/atom/ns#' term='balance'/><category scheme='http://www.blogger.com/atom/ns#' term='servo'/><category scheme='http://www.blogger.com/atom/ns#' term='fall'/><category scheme='http://www.blogger.com/atom/ns#' term='robobuilder'/><title type='text'>Form vs Function</title><content type='html'>I thought you might &lt;a href="http://en.wikipedia.org/wiki/Shadenfreude"&gt;appreciate&lt;/a&gt; this video of my robot falling over.&lt;br /&gt;&lt;br /&gt;&lt;object height="344" width="425"&gt;&lt;param name="movie" value="http://www.youtube.com/v/pnNEqGIJqYA&amp;hl=en_US&amp;fs=1&amp;"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/pnNEqGIJqYA&amp;hl=en_US&amp;fs=1&amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;br /&gt;&lt;br /&gt;At the end, you may notice that his legs get stuck together like an &lt;a href="http://www.youtube.com/watch?v=lavbyJJJIHE"&gt;imperial&lt;/a&gt; &lt;a href="http://www.youtube.com/watch?v=sjzd5k24m6E"&gt;walker&lt;/a&gt; during the &lt;a href="http://www.youtube.com/watch?v=yVgF07RK6qc"&gt;battle of Hoth&lt;/a&gt;! Ah, memories.&lt;br /&gt;&lt;br /&gt;The instructions in the &lt;a href="http://ro-botica.com/img/Robobuilder/Robobuilder_User_Guide_EN.pdf"&gt;manual&lt;/a&gt; indicate very clearly that the nuts should be placed on the inside of the leg - presumably for aesthetic reasons. However, the short section of bolt which sticks out of the inside has a nasty habit of getting hooked on the opposite foot.&lt;br /&gt;&lt;br /&gt;If you can tolerate your robot looking a bit road warrior themed, I suggest reversing the direction of the bolts to avoid having your robot flail about like a memermaid, and also the internal damage to the plastic casing:&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/_PZjyemYqS8E/S0UaTw1ir1I/AAAAAAAAAEc/dQ_ZfwDfWS0/s1600-h/100107_scratch.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://1.bp.blogspot.com/_PZjyemYqS8E/S0UaTw1ir1I/AAAAAAAAAEc/dQ_ZfwDfWS0/s320/100107_scratch.png" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;I do &lt;a href="http://buildtherobot.blogspot.com/2009/12/saftey-first.html"&gt;often&lt;/a&gt; &lt;a href="http://buildtherobot.blogspot.com/2009/11/its-alive.html"&gt;complain&lt;/a&gt; about the robobuilder design, but I think I should make it clear that I am by no means unhappy with it. These are small complaints which (I hope) will be addressed by the robobuilder community and also allow others to avoid my mistakes.&lt;br /&gt;&lt;br /&gt;The wCK servos are actually the best robotics servos I've used for their price. You can skip the durability issues I've &lt;a href="http://buildtherobot.blogspot.com/2009/12/two-steps-forward.html"&gt;been&lt;/a&gt; &lt;a href="http://buildtherobot.blogspot.com/2009/11/it-was-only-matter-of-time.html"&gt;having&lt;/a&gt;, simply by getting the wCK 1111 version, which has 3 metal gears and a higher torque! They have a suite of extra features, such as brake mode, 10bit positioning (360/1024 = 0.35 degree accuracy!), runtime adjustable PID settings, continuous rotation mode, and the ability to write &lt;a href="http://www.youtube.com/watch?v=-wfOdFWU5PY"&gt;simple programs&lt;/a&gt; to run on the servos themselves.&lt;br /&gt;&lt;br /&gt;I have yet to use these features, but I can already think of a thousand uses for them.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4136375076360613625-6516850383143073609?l=buildtherobot.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://buildtherobot.blogspot.com/feeds/6516850383143073609/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://buildtherobot.blogspot.com/2010/01/form-vs-function.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/6516850383143073609'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/6516850383143073609'/><link rel='alternate' type='text/html' href='http://buildtherobot.blogspot.com/2010/01/form-vs-function.html' title='Form vs Function'/><author><name>Alex Jarkey</name><uri>http://www.blogger.com/profile/02033809613943284663</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_PZjyemYqS8E/S0uqTx1jdrI/AAAAAAAAAFM/EVGW1FeCizY/S220/peas.bmp'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_PZjyemYqS8E/S0UaTw1ir1I/AAAAAAAAAEc/dQ_ZfwDfWS0/s72-c/100107_scratch.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4136375076360613625.post-4086476269608244246</id><published>2010-01-05T18:43:00.000-08:00</published><updated>2010-01-05T18:46:06.666-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='repair'/><category scheme='http://www.blogger.com/atom/ns#' term='robot'/><category scheme='http://www.blogger.com/atom/ns#' term='balance'/><category scheme='http://www.blogger.com/atom/ns#' term='servo'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><category scheme='http://www.blogger.com/atom/ns#' term='biped'/><title type='text'>One step at a time</title><content type='html'>Happy New Year Everyone!!&lt;br /&gt;&lt;br /&gt;I'm back from a short holiday down to the Melbourne Cricket Ground to watch the Boxing Day test. It was very relaxing, but now that I have returned I have lots of robot news to share!&lt;br /&gt;&lt;br /&gt;Firstly, despite being unable to find wCK gears anywhere in the southern hemisphere, I have sort of fixed the &lt;a href="http://buildtherobot.blogspot.com/2009/12/two-steps-forward.html"&gt;broken knee servo&lt;/a&gt;. Thanks to an emergency surgical field &lt;a href="http://www.youtube.com/watch?v=WTz8rKJk-Vw"&gt;graft&lt;/a&gt;, he can now walk fairly normally but has lost the use of his right arm. Apparently I'm not the only person who is &lt;a href="http://robosavvy.com/forum/viewtopic.php?t=5209"&gt;having&lt;/a&gt; &lt;a href="http://vision.eng.shu.ac.uk/mmvlwiki/index.php/Robobuilder"&gt;problems&lt;/a&gt; with the plastic gears. If you are concerned about damaging your own servos, I suggest you set them to the lowest torque setting. Note that 4 is the LOWEST torque setting, and 0 is the HIGHEST - the manual could probably be more forthcoming on this point.&lt;br /&gt;&lt;br /&gt;Now that he's up and mobile again, I've resumed work on getting him to &lt;a href="http://buildtherobot.blogspot.com/2009/12/phase-1-collect-underpants.html"&gt;keep his balance&lt;/a&gt; while standing.&lt;br /&gt;&lt;br /&gt;Whenever I start work on an ambitious project, I find that the only way to keep on track is set myself &lt;a href="http://buildtherobot.blogspot.com/2009/12/mirror-mirror.html"&gt;small targets&lt;/a&gt; along the way. I am always coming up with ideas that are easy enough to design, but take far longer to implement - and more than a few of them have fallen by the wayside because my eyes were bigger than my stomach.&lt;br /&gt;&lt;br /&gt;So having small, short term &lt;a href="http://www.somethingawful.com/d/video-game-article/team-fortress-achievements.php"&gt;achievements&lt;/a&gt; keeps me motivated to move on with the long term goal. A very simple method of controlling complex systems (particularly when computing power is limited) is called discrete &lt;a href="http://en.wikipedia.org/wiki/State_space_%28controls%29"&gt;state-space control&lt;/a&gt;. Rather than trying to model the system and predict how it will behave, the system is manually broken down into a &lt;a href="http://en.wikipedia.org/wiki/Discretization"&gt;discrete&lt;/a&gt; set of inputs and outputs. Then, using some very basic rules, the behaviour of the system can be described in very simple terms like: if A, then B.&lt;br /&gt;&lt;br /&gt;In the case of the robot trying to maintain it's upright position, you can simplify things by firstly holding most of the joints rigid. Using the feedback information from the ankle servos (04 and 00), you can predict if the robot is tilting too far to the left or right. Then, depending on which state the robot is in, it can take the appropriate action to regain it's balance. Simple, no?&lt;br /&gt;&lt;br /&gt;&lt;object height="344" width="425"&gt;&lt;param name="movie" value="http://www.youtube.com/v/VBuI63W-QJQ&amp;hl=en_US&amp;fs=1&amp;"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/VBuI63W-QJQ&amp;hl=en_US&amp;fs=1&amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;br /&gt;&lt;br /&gt;In the video, you can see the robot measuring the angular velocity of it's ankles, and detecting when it's balance is being compromised. It simply steps away from the force to maintain it's stability - just like a human would.&lt;br /&gt;&lt;br /&gt;Right now, it only work for left and right - simply because the canned robobuilder animations for forwards and backwards consist of several steps, meaning I will have to write my own motions.&lt;br /&gt;&lt;br /&gt;I should probably start putting together my own library of poses anyway, since I'm not too happy with the default ones. The walking and turning motions have a real problem on many surfaces - polished wooden floors are the best so far, but far from perfect.&lt;br /&gt;&lt;br /&gt;&lt;object height="344" width="425"&gt;&lt;param name="movie" value="http://www.youtube.com/v/U90c3YqK1iU&amp;hl=en_US&amp;fs=1&amp;"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/U90c3YqK1iU&amp;hl=en_US&amp;fs=1&amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;br /&gt;&lt;br /&gt;Here you can see that the robot is having problems moving in the right direction with the stock SidewalkRight/Left actions, to the extend that he goes the wrong way! Because he was off centre to begin with, one foot is carrying most of his weight, so he pushes against the ground and towards my hand.&lt;br /&gt;&lt;br /&gt;Code will be available soon, once I've cleaned it up a little and found a nice place to upload it. I think that robosavvy has personal file space for it's members, so I will see if I can make the files public.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4136375076360613625-4086476269608244246?l=buildtherobot.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://buildtherobot.blogspot.com/feeds/4086476269608244246/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://buildtherobot.blogspot.com/2010/01/one-step-at-time.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/4086476269608244246'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/4086476269608244246'/><link rel='alternate' type='text/html' href='http://buildtherobot.blogspot.com/2010/01/one-step-at-time.html' title='One step at a time'/><author><name>Alex Jarkey</name><uri>http://www.blogger.com/profile/02033809613943284663</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_PZjyemYqS8E/S0uqTx1jdrI/AAAAAAAAAFM/EVGW1FeCizY/S220/peas.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4136375076360613625.post-4204687138142692452</id><published>2009-12-24T17:28:00.000-08:00</published><updated>2009-12-24T17:28:38.277-08:00</updated><title type='text'>Merry Christmas</title><content type='html'>Have a safe and happy holiday everyone!&lt;br /&gt;&lt;br /&gt;&lt;object width="425" height="344"&gt;&lt;param name="movie" value="http://www.youtube.com/v/7LnKTErIsyE&amp;hl=en_GB&amp;fs=1&amp;"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/7LnKTErIsyE&amp;hl=en_GB&amp;fs=1&amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4136375076360613625-4204687138142692452?l=buildtherobot.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://buildtherobot.blogspot.com/feeds/4204687138142692452/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://buildtherobot.blogspot.com/2009/12/merry-christmas.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/4204687138142692452'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/4204687138142692452'/><link rel='alternate' type='text/html' href='http://buildtherobot.blogspot.com/2009/12/merry-christmas.html' title='Merry Christmas'/><author><name>Alex Jarkey</name><uri>http://www.blogger.com/profile/02033809613943284663</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_PZjyemYqS8E/S0uqTx1jdrI/AAAAAAAAAFM/EVGW1FeCizY/S220/peas.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4136375076360613625.post-4019180023707986462</id><published>2009-12-21T02:09:00.000-08:00</published><updated>2009-12-21T02:09:02.232-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='mechanical'/><category scheme='http://www.blogger.com/atom/ns#' term='software'/><category scheme='http://www.blogger.com/atom/ns#' term='servo'/><category scheme='http://www.blogger.com/atom/ns#' term='biped'/><title type='text'>Phase 1: Collect underpants.</title><content type='html'>In the absence of a robot capable of supporting it's &lt;a href="http://buildtherobot.blogspot.com/2009/12/two-steps-forward.html"&gt;own weight&lt;/a&gt;, I've started planning my next move.&lt;br /&gt;&lt;br /&gt;The purpose of writing my own firmware for this robot is purely academic. I don't have a specific goal in mind for this project, even though I'm sure we would all enjoy a robot which could clean our &lt;a href="http://www.youtube.com/watch?v=LQ-jv8g1YVI"&gt;house&lt;/a&gt;, bring you &lt;a href="http://www.youtube.com/watch?v=PWvoMnHIIqM"&gt;drinks&lt;/a&gt;, or make us &lt;a href="http://buildtherobot.blogspot.com/2009/12/i-was-just-reading-over-some-of-my.html"&gt;coffee&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;As I develop more and more features, I can share them as code snippets which will help other people with their projects. Of course, when I decide I want to revolutionize the &lt;a href="http://www.youtube.com/watch?v=HwcUnx-0X7g"&gt;coffee robot industry&lt;/a&gt;, I will be adequately prepared.&lt;br /&gt;&lt;br /&gt;Now that I have figured out how to use the servos as sensors to get feedback about the robot's position, I plan to implement an inverse kinodynamics engine to enable balance &lt;i&gt;without an accelerometer&lt;/i&gt;.&lt;br /&gt;&lt;br /&gt;For those who aren't down with the lingo, kinodynamics is a contraction of kinematics and dynamics.&lt;br /&gt;&lt;br /&gt;Kinematics is concerned with modelling the behaviour of a system given a physical and geometric configuration. In the case of the humanoid robot, this means calculating the relative location of the arms, legs, feet, etc, simply given the angular position of each of the 16 servos. This can be calculated (&lt;a href="http://www.youtube.com/watch?v=LQ-jv8g1YVI"&gt;relatively&lt;/a&gt;) simply using basic (again, not something you'd find next to the &lt;a href="http://en.wiktionary.org/wiki/funny_pages"&gt;funny pages&lt;/a&gt;) vector mathematics and trigonometry.&lt;br /&gt;&lt;br /&gt;Now, dynamics. Kinematics merely describes the geometry and structure of an object. It's velocity, mass, angular momentum and behaviour when subjected to a force are all in the domain of dynamics. When your robot falls down the stairs in a &lt;a href="http://www.engadget.com/2006/12/11/honda-asimo-takes-a-nasty-fall/"&gt;hilarious but tragic accident&lt;/a&gt;, his dynamic behaviour determines how long you will watch in abject horror.&lt;br /&gt;&lt;br /&gt;So, a kinodynamic model of a humanoid robot can be used to generate a fairly reliable prediction of the state of a robot at a future instant, given the current state and control space.&lt;br /&gt;&lt;br /&gt;Put more simply, this model can be used to calculate "safe" actions, which will result in the robot performing a motion while keeping it's centre of mass over it's feet - in other words, balancing.&lt;br /&gt;&lt;br /&gt;These are all quite lofty goals, and right now it looks complex, but I'll outline more details in future posts. &lt;br /&gt;&lt;br /&gt;Stay tuned for &lt;a href="http://www.youtube.com/watch?v=0WHB98m-ppw"&gt;Phase 2: "???"&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4136375076360613625-4019180023707986462?l=buildtherobot.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://buildtherobot.blogspot.com/feeds/4019180023707986462/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://buildtherobot.blogspot.com/2009/12/phase-1-collect-underpants.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/4019180023707986462'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/4019180023707986462'/><link rel='alternate' type='text/html' href='http://buildtherobot.blogspot.com/2009/12/phase-1-collect-underpants.html' title='Phase 1: Collect underpants.'/><author><name>Alex Jarkey</name><uri>http://www.blogger.com/profile/02033809613943284663</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_PZjyemYqS8E/S0uqTx1jdrI/AAAAAAAAAFM/EVGW1FeCizY/S220/peas.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4136375076360613625.post-6040631415056302309</id><published>2009-12-18T03:12:00.000-08:00</published><updated>2009-12-18T03:12:58.608-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='hexapod'/><category scheme='http://www.blogger.com/atom/ns#' term='robot'/><category scheme='http://www.blogger.com/atom/ns#' term='robo-one'/><title type='text'>Two steps forward...</title><content type='html'>I did a lot of work today, improving the robobuilder motion system and writing some custom functions to take advantage of the &lt;a href="http://buildtherobot.blogspot.com/2009/12/mirror-mirror.html"&gt;special features&lt;/a&gt; that the wCKs have to offer.&lt;br /&gt;&lt;br /&gt;Unfortunately, my efforts were met with &lt;a href="http://tvtropes.org/pmwiki/pmwiki.php/Main/OnlyAFleshWound"&gt;a minor setback&lt;/a&gt; when I managed to strip another gear - this time in the poor robot's knee. Unlike the &lt;a href="http://buildtherobot.blogspot.com/2009/11/it-was-only-matter-of-time.html"&gt;first time&lt;/a&gt;, or the &lt;a href="http://buildtherobot.blogspot.com/2009/12/saftey-first.html"&gt;time after that&lt;/a&gt;, the gear which needed replacing was the first gear in the set - the one which is driven directly by the motor.&lt;br /&gt;&lt;br /&gt;This leads me to believe that it broke simply due to regular &lt;a href="http://en.wikipedia.org/wiki/Fatigue_%28material%29"&gt;wear and tear&lt;/a&gt; - not because of any &lt;i&gt;specific&lt;/i&gt; negligence on my behalf.&lt;br /&gt;&lt;br /&gt;Gears tend to be under more &lt;a href="http://en.wikipedia.org/wiki/Stress_%28mechanics%29"&gt;stress&lt;/a&gt; the further away from the motor they are, because they rotate slower, but with more torque. This is why (I assume), I didn't receive any replacement #1 gears with my kit.&lt;br /&gt;&lt;br /&gt;Therefore my &lt;a href="http://tvtropes.org/pmwiki/pmwiki.php/Main/EvilPlan"&gt;plans&lt;/a&gt; have been put on hold until I can get my hands on a replacement. This should serve as another important &lt;a href="http://buildtherobot.blogspot.com/2009/12/mirror-mirror.html"&gt;selection criteria&lt;/a&gt; for servos - &lt;i&gt;metal gears are worth the extra money&lt;/i&gt;.&lt;br /&gt;&lt;br /&gt;So today's post will not, as I had intended, consist of more &lt;a href="http://buildtherobot.blogspot.com/2009/12/mirror-mirror.html"&gt;awesome videos&lt;/a&gt; of my robot doing awesome stuff.&lt;br /&gt;&lt;br /&gt;Instead, please enjoy a variety of other people's robot's doing other people's stuffs.&lt;br /&gt;&lt;br /&gt;&lt;object height="344" width="425"&gt;&lt;param name="movie" value="http://www.youtube.com/v/XhLFO13iee8&amp;hl=en_US&amp;fs=1&amp;"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/XhLFO13iee8&amp;hl=en_US&amp;fs=1&amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;br /&gt;&lt;br /&gt;Above is an earlier version of &lt;a href="http://buildtherobot.blogspot.com/2009/12/i-was-just-reading-over-some-of-my.html"&gt;HINA&lt;/a&gt;, doing demonstrations for the robo-one competition. I'm fairly sure that the bottle of water is full, which means that there is quite a lot of power in that little robot. As usual, &lt;a href="http://buildtherobot.blogspot.com/2009/12/i-was-just-reading-over-some-of-my.html"&gt;mujaki&lt;/a&gt; has put a lot of effort into the custom body parts and it looks absolutely stunning.&lt;br /&gt;&lt;br /&gt;In the &lt;a href="http://tvtropes.org/pmwiki/pmwiki.php/Main/TwentyMinutesIntoTheFuture"&gt;not too distant future&lt;/a&gt;, I'd like to have a go at customising my servos - particularly given the problems I'm having with these plastic gears.&lt;br /&gt;&lt;br /&gt;&lt;object height="344" width="425"&gt;&lt;param name="movie" value="http://www.youtube.com/v/NUMGpDTm59w&amp;hl=en_US&amp;fs=1&amp;"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/NUMGpDTm59w&amp;hl=en_US&amp;fs=1&amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;br /&gt;&lt;br /&gt;From cute to creepy.&lt;br /&gt;&lt;br /&gt;This is phoenix, a &lt;a href="http://tvtropes.org/pmwiki/pmwiki.php/Main/SpiderTank"&gt;hexapod&lt;/a&gt; with an amazingly lifelike gait and behaviour. It looks like a real insect, especially when it goes into attack mode!&lt;br /&gt;&lt;br /&gt;Phoenix is able to move so fluidly due to an &lt;a href="http://en.wikipedia.org/wiki/Inverse_kinematics"&gt;inverse kinematics&lt;/a&gt; engine (another interest of mine). This enables fine control over the body and individual limbs of the hexapod, without compromising the balance or posture of the rest of the robot.&lt;br /&gt;&lt;br /&gt;When I can get this servo fixed, I'll upload some more videos of my own - please bear with me. If anyone knows where I can get replacement wCK gears (preferably metal) in Australia - let me know.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4136375076360613625-6040631415056302309?l=buildtherobot.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://buildtherobot.blogspot.com/feeds/6040631415056302309/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://buildtherobot.blogspot.com/2009/12/two-steps-forward.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/6040631415056302309'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/6040631415056302309'/><link rel='alternate' type='text/html' href='http://buildtherobot.blogspot.com/2009/12/two-steps-forward.html' title='Two steps forward...'/><author><name>Alex Jarkey</name><uri>http://www.blogger.com/profile/02033809613943284663</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_PZjyemYqS8E/S0uqTx1jdrI/AAAAAAAAAFM/EVGW1FeCizY/S220/peas.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4136375076360613625.post-3943121744210604849</id><published>2009-12-17T00:35:00.000-08:00</published><updated>2009-12-17T00:43:08.771-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='robot'/><category scheme='http://www.blogger.com/atom/ns#' term='servo'/><title type='text'>Mirror Mirror</title><content type='html'>When I first got it into my head that I wanted to build a humanoid robot, I spent quite a lot of time researching various types of servos I could use. They needed to be high-torque, not too big and above all cheap - other features were just gravy.&lt;br /&gt;&lt;br /&gt;This led me to consider a number of things, such as using unbranded RC hobby servos, buying &lt;a href="http://www.dealextreme.com/details.dx/sku.20087"&gt;unbelievably cheap&lt;/a&gt; micro servos and upgrading the motors, and even building my own.&lt;br /&gt;&lt;br /&gt;These are not bad options, per se, but what I failed to consider were just how useful those extra features that high quality servos include can be.&lt;br /&gt;&lt;br /&gt;Fortunately, I was saved from myself by the timely arrival of my &lt;a href="http://buildtherobot.blogspot.com/2009/11/some-assembly-required.html"&gt;birthday&lt;/a&gt; (which I have written about previously).&lt;br /&gt;&lt;br /&gt;Though the wCK servos have many additional features, the one that I am finding particularly useful right now is the ability to query a specific servo for it's current position. Although it doesn't seem like much on it's own, it has enabled me to do cool little tricks like this:&lt;br /&gt;&lt;br /&gt;&lt;object height="344" width="425"&gt;&lt;param name="movie" value="http://www.youtube.com/v/Im9MR4VQqG0&amp;hl=en_US&amp;fs=1"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/Im9MR4VQqG0&amp;hl=en_US&amp;fs=1" type="application/x-shockwave-flash" width="425" height="344" allowscriptaccess="always" allowfullscreen="true"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The video simply shows me moving the robot's left arm, and having the program mirror the actions on the right arm.&lt;br /&gt;&lt;br /&gt;Non-robologists don't seem to find this very impressive, but hopefully the implications of this are apparent if you are in the robot game. Effectively (although crudely), the robot now has a sense of touch.&lt;br /&gt;&lt;br /&gt;Don't have a distance sensor? No problem - just set your robot into zombie posture and wait until one of his arms is bumped by a wall.&lt;br /&gt;&lt;br /&gt;Worried that you'll damage a servo? Just check to see if it's stuck and turn it off to avoid stripping a gear.&lt;br /&gt;&lt;br /&gt;Oh, and before you ask - yes, that is &lt;a href="http://en.wikipedia.org/wiki/Donatello_%28TMNT%29"&gt;Donatello&lt;/a&gt; in the background holding the power and serial plugs. &lt;br /&gt;&lt;br /&gt;Here's another video of him with his arms attached (the robot, &lt;a href="http://xkcd.com/197/"&gt;not the turtle&lt;/a&gt;).&lt;br /&gt;&lt;br /&gt;&lt;object height="344" width="425"&gt;&lt;param name="movie" value="http://www.youtube.com/v/SYHoOEht2VE&amp;hl=en_US&amp;fs=1&amp;"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/SYHoOEht2VE&amp;hl=en_US&amp;fs=1&amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;br /&gt;&lt;br /&gt;The servos are placed in passive mode, which is another special feature of the wCKs, which powers them up but turns off the PID control. Because the servos use an RS485 type bus, they can then be queried by the RBC and then take control of the bus to report their current position.&lt;br /&gt;&lt;br /&gt;Although it is a minor achievement, this is another important step on the road to my grand plan. What plan, you ask? You'll just have to wait and find out.&lt;br /&gt;&lt;br /&gt;The code is a bit sketchy at the moment, so give me a chance to clean it up before I upload it. Watch this space.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4136375076360613625-3943121744210604849?l=buildtherobot.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://buildtherobot.blogspot.com/feeds/3943121744210604849/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://buildtherobot.blogspot.com/2009/12/mirror-mirror.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/3943121744210604849'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/3943121744210604849'/><link rel='alternate' type='text/html' href='http://buildtherobot.blogspot.com/2009/12/mirror-mirror.html' title='Mirror Mirror'/><author><name>Alex Jarkey</name><uri>http://www.blogger.com/profile/02033809613943284663</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_PZjyemYqS8E/S0uqTx1jdrI/AAAAAAAAAFM/EVGW1FeCizY/S220/peas.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4136375076360613625.post-8845476463087577985</id><published>2009-12-15T14:41:00.000-08:00</published><updated>2009-12-16T20:55:33.266-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='mechanical'/><category scheme='http://www.blogger.com/atom/ns#' term='robot'/><category scheme='http://www.blogger.com/atom/ns#' term='software'/><category scheme='http://www.blogger.com/atom/ns#' term='servo'/><title type='text'>Saftey First</title><content type='html'>After what happened &lt;a href="http://buildtherobot.blogspot.com/2009/11/it-was-only-matter-of-time.html"&gt;last time&lt;/a&gt;, I've become significantly more &lt;a href="http://buildtherobot.blogspot.com/2009/12/son-of-voltron.html"&gt;paranoid&lt;/a&gt; about damaging my robot.&lt;br /&gt;&lt;br /&gt;Recently, while doing some &lt;a href="http://buildtherobot.blogspot.com/2009/12/if-i-only-had-brain.html"&gt;more hacking&lt;/a&gt; of the wCK motion timing system, I decided to simply remove the element of risk &lt;a href="http://www.agius.com/hew/resource/control.htm#elimin"&gt;altogether&lt;/a&gt;.&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_PZjyemYqS8E/Sym5K2dp4dI/AAAAAAAAADo/gk__5bM_s-M/s1600-h/091216_safe.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="240" src="http://4.bp.blogspot.com/_PZjyemYqS8E/Sym5K2dp4dI/AAAAAAAAADo/gk__5bM_s-M/s320/091216_safe.png" width="320" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;So far, separating the arms and legs from the body has been a good move (tm), and I encourage you to do the same if you start changing low level parts of the code.&lt;br /&gt;&lt;br /&gt;You see, I am rapidly running out of those spanner shaped connectors.&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_PZjyemYqS8E/Sym5nokeFeI/AAAAAAAAADw/EOZi66YPWuI/s1600-h/091216_broke.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://4.bp.blogspot.com/_PZjyemYqS8E/Sym5nokeFeI/AAAAAAAAADw/EOZi66YPWuI/s320/091216_broke.png" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;I mentioned in a previous &lt;a href="http://buildtherobot.blogspot.com/2009/11/c-is-for-cookie.html"&gt;post&lt;/a&gt; how careless control over pointers can cause your robot to flip out like a hyperactive kid tripping over a beehive. The wCK servos have just over 11 &lt;a href="http://en.wikipedia.org/wiki/Kilogram-force"&gt;kgFcm&lt;/a&gt; of &lt;a href="http://en.wikipedia.org/wiki/Torque"&gt;torque&lt;/a&gt;, which is more than adequate to cause your robot to tear itself to pieces when a rogue pointer starts issuing random commands. I speak from experience.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://en.wikipedia.org/wiki/USART"&gt;Serial transmission&lt;/a&gt; of commands to the servos can be performed in two ways. The most common method is to use the "Transmission Buffer Empty" interrupt, to send a new character whenever there is nothing waiting to be sent. A transmission is initiated simply by unmasking the interrupt, and the interrupt is set to disable itself when there is nothing left to send. This is the &lt;a href="http://embeddedfreak.wordpress.com/2008/10/01/avr-udrie-vs-txc-interrupt/"&gt;preferred&lt;/a&gt; way of sending &lt;a href="http://en.wikipedia.org/wiki/RS-232"&gt;RS232&lt;/a&gt; communications, as the interrupt will continually fire as long as as something remains to be sent.&lt;br /&gt;&lt;br /&gt;The second method of transmitting the message is to use the "Transmission Complete" interrupt. If enabled, this interrupt fires whenever a character has finished being sent. This requires a single character to be manually loaded to "prime the pump", but transmission simply stops when no more characters are available. Since the next character is sent immediately, &lt;a href="http://embeddedfreak.wordpress.com/2008/10/01/avr-udrie-vs-txc-interrupt/"&gt;tighter control&lt;/a&gt; over transmission states can be achieved, such as when using an &lt;a href="http://en.wikipedia.org/wiki/RS-485"&gt;RS485&lt;/a&gt; protocol.&lt;br /&gt;&lt;br /&gt;The wCK servos use an RS485 protocol.&lt;br /&gt;&lt;br /&gt;The reason that the robobuilder has a tendency to spaz out is due to two things. Firstly, the transmission buffer is &lt;a href="http://en.wikipedia.org/wiki/Circular_buffer"&gt;circular&lt;/a&gt;. This means that messages can be added to the buffer at the same time as they are being sent. When the pointer gets to the end of the buffer, it simply returns to the beginning and keeps sending until it reaches the end marker.&lt;br /&gt;&lt;br /&gt;Secondly, memory is never truly empty. A byte in memory simply contains the last thing that was stored in it. On reset, unallocated space usually contains junk data. Even if you set up your program to zero out your memory before you use it, it will still contain a zero. Therefore, even a small mistake which results in one of the transmission interrupts not being disabled correctly will cause a vast number of arbitrary commands being issued to the servos, causing the aforementioned spastic behavior.&lt;br /&gt;&lt;br /&gt;Aaaaanyway, now that you know why it happens, you know how to avoid it. I still recommend detaching your arms and legs while you're testing though.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4136375076360613625-8845476463087577985?l=buildtherobot.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://buildtherobot.blogspot.com/feeds/8845476463087577985/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://buildtherobot.blogspot.com/2009/12/saftey-first.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/8845476463087577985'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/8845476463087577985'/><link rel='alternate' type='text/html' href='http://buildtherobot.blogspot.com/2009/12/saftey-first.html' title='Saftey First'/><author><name>Alex Jarkey</name><uri>http://www.blogger.com/profile/02033809613943284663</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_PZjyemYqS8E/S0uqTx1jdrI/AAAAAAAAAFM/EVGW1FeCizY/S220/peas.bmp'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_PZjyemYqS8E/Sym5K2dp4dI/AAAAAAAAADo/gk__5bM_s-M/s72-c/091216_safe.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4136375076360613625.post-5372008902043006526</id><published>2009-12-14T14:29:00.000-08:00</published><updated>2009-12-14T23:00:31.174-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='robo-one'/><category scheme='http://www.blogger.com/atom/ns#' term='biped'/><title type='text'>All work and no play</title><content type='html'>I was just reading over some of &lt;a href="http://buildtherobot.blogspot.com/2009/12/son-of-voltron.html"&gt;my&lt;/a&gt; &lt;a href="http://buildtherobot.blogspot.com/2009/12/if-i-only-had-brain.html"&gt;previous&lt;/a&gt; &lt;a href="http://buildtherobot.blogspot.com/2009/11/it-was-only-matter-of-time.html"&gt;posts&lt;/a&gt;, when I suddenly realised:&lt;br /&gt;&lt;br /&gt;They are really boring.&lt;br /&gt;&lt;br /&gt;Useful - I hope - to those of you who are interested in building humanoid robots, but probably not that exciting to read.&lt;br /&gt;&lt;br /&gt;There were two reasons I decided to create this blog. Firstly, I wanted to have what I have just now decided should be called a "blogbook". This is a collection of my notes on the project of writing software for my humanoid robot, so that I can refer back to it when I forget something, or at least a space where I can get my thoughts to sit down and stay in one place. Making it avaliable online adds the important contribution of allowing other people to read about my mistakes, and how not to make them.&lt;br /&gt;&lt;br /&gt;The second reason for starting this blog is that I find humanoid robots completely fascinating. I find that enthusiasm is contagious - everyone has a favourite science/music/drama teacher who was so passionate and dedicated to their subject that they made learning something you &lt;i&gt;wanted&lt;/i&gt; to do. I hope that reading about my endeavours will encourage more people to learn about robots and the field of mechatronics. Perhaps you will start your own robotics project.&lt;br /&gt;&lt;br /&gt;Up until now, most of the posts have fallen very much into the former category, so the remainder of this post is dedicated to the latter. Lets look at some cool robots!&lt;br /&gt;&lt;br /&gt;&lt;object height="344" width="425"&gt;&lt;param name="movie" value="http://www.youtube.com/v/ejROvUC-gWU&amp;hl=en_US&amp;fs=1&amp;"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/ejROvUC-gWU&amp;hl=en_US&amp;fs=1&amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;br /&gt;&lt;br /&gt;First up, we have &lt;a href="http://www.youtube.com/watch?v=ejROvUC-gWU"&gt;HINA&lt;/a&gt; by &lt;a href="http://translate.google.com.au/translate?hl=en&amp;amp;sl=ja&amp;amp;u=http://mujaki.blog.shinobi.jp/&amp;amp;ei=yi4nS_vHOdCTkAWKmP2ADQ&amp;amp;sa=X&amp;amp;oi=translate&amp;amp;ct=result&amp;amp;resnum=2&amp;amp;ved=0CAwQ7gEwAQ&amp;amp;prev=/search%3Fq%3Dmujaki%2Bclockwork%26hl%3Den%26client%3Dfirefox-a%26rls%3Dorg.mozilla:en-US:official%26hs%3DaDm"&gt;mujaki&lt;/a&gt;. I personally love this video - when I first saw it, it set my imagination on fire. All of the servos and parts are completley &lt;a href="http://translate.googleusercontent.com/translate_c?hl=en&amp;amp;sl=ja&amp;amp;u=http://mujaki.blog.shinobi.jp/Entry/51/&amp;amp;prev=/search%3Fq%3Dmujaki%2Bclockwork%26hl%3Den%26client%3Dfirefox-a%26rls%3Dorg.mozilla:en-US:official%26hs%3DaDm&amp;amp;rurl=translate.google.com.au&amp;amp;usg=ALkJrhjozVGAWNtaCIYV5UK2dfjei_n7MQ"&gt;custom&lt;/a&gt; &lt;a href="http://translate.googleusercontent.com/translate_c?hl=en&amp;amp;sl=ja&amp;amp;u=http://mujaki.blog.shinobi.jp/Entry/50/&amp;amp;prev=/search%3Fq%3Dmujaki%2Bclockwork%26hl%3Den%26client%3Dfirefox-a%26rls%3Dorg.mozilla:en-US:official%26hs%3DaDm&amp;amp;rurl=translate.google.com.au&amp;amp;usg=ALkJrhiPwnOGEPNWGHQaLqzPbgEvImLGPw"&gt;made&lt;/a&gt;, and it reminds me of &lt;a href="http://www.absoluteanime.com/chobits/sumomo.htm"&gt;Plum&lt;/a&gt; and &lt;a href="http://www.absoluteanime.com/chobits/kotoko.htm"&gt;Kotoko&lt;/a&gt; from &lt;a href="http://www.absoluteanime.com/chobits/index.htm"&gt;Chobits&lt;/a&gt;. Not only does it bridge the &lt;a href="http://en.wikipedia.org/wiki/Uncanny_valley"&gt;uncanny valley&lt;/a&gt; most successfully, but the video demonstrates exactly why we all should want a tiny robotic servant within the next 10 years.&lt;br /&gt;&lt;br /&gt;&lt;object height="344" width="425"&gt;&lt;param name="movie" value="http://www.youtube.com/v/KrSSpoX-bcE&amp;hl=en_US&amp;fs=1&amp;"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/KrSSpoX-bcE&amp;hl=en_US&amp;fs=1&amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;br /&gt;&lt;br /&gt;The red robot is an early version of Omni Zero - before he put on &lt;a href="http://www.engadget.com/2009/09/28/video-takeshi-maedas-omnizero-9-robot-transforms-carries-crea/"&gt;all that weight&lt;/a&gt;. I find it interesting the way that he jogs in place, which I assume is a method of getting feedback for him to have dynamic balance. The best thing about Robo-one is that it tackle's the problem of bipdeal robots so casually - for decades, the problem of humanoid robotics seemed unsolvable, but now it's progressed to the level that robots can not only walk - they can wrestle.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4136375076360613625-5372008902043006526?l=buildtherobot.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://buildtherobot.blogspot.com/feeds/5372008902043006526/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://buildtherobot.blogspot.com/2009/12/i-was-just-reading-over-some-of-my.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/5372008902043006526'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/5372008902043006526'/><link rel='alternate' type='text/html' href='http://buildtherobot.blogspot.com/2009/12/i-was-just-reading-over-some-of-my.html' title='All work and no play'/><author><name>Alex Jarkey</name><uri>http://www.blogger.com/profile/02033809613943284663</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_PZjyemYqS8E/S0uqTx1jdrI/AAAAAAAAAFM/EVGW1FeCizY/S220/peas.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4136375076360613625.post-2765862706948690546</id><published>2009-12-10T19:30:00.000-08:00</published><updated>2009-12-15T17:08:58.235-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='battery'/><category scheme='http://www.blogger.com/atom/ns#' term='robot'/><category scheme='http://www.blogger.com/atom/ns#' term='electronic'/><category scheme='http://www.blogger.com/atom/ns#' term='software'/><title type='text'>Son of Voltron</title><content type='html'>Enabling the robot to recharge it's own batteries was something I wanted to get done sooner rather than later. One of the primary reasons for this is that it meant I needed to periodically switch back to the default firmware if I wanted to charge up the batteries. The second reason though, was that it was a very appropriate stepping-stone on the way to getting several other features working.&lt;br /&gt;&lt;br /&gt;You see, the atmel 128 &lt;a href="http://en.wikipedia.org/wiki/Analog-to-digital_converter"&gt;Analog to Digital Converter&lt;/a&gt; has a built in &lt;a href="http://en.wikipedia.org/wiki/Multiplexing"&gt;multiplexer &lt;/a&gt;which allows the single peripheral to measure up to eight different voltage nodes relative to ground potential or other nodes, at various levels of gain. Even better, these sources and configurations are software selectable by the use of a 5-bit multiplexer.&lt;br /&gt;&lt;br /&gt;If all that sounded like &lt;a href="http://tvtropes.org/pmwiki/pmwiki.php/Main/TechnoBabble"&gt;technobabble&lt;/a&gt; to you, the &lt;a href="http://tvtropes.org/pmwiki/pmwiki.php/Main/PhlebotinumAnalogy"&gt;long and the short of it&lt;/a&gt; is that the same basic code which measures the power left in the batteries can be used to get distance readings from the IR sensor, and sound input from the microphone!&lt;br /&gt;&lt;br /&gt;But back to the &lt;a href="http://tvtropes.org/pmwiki/pmwiki.php/Main/PowerLevels?from=Main.OverNineThousand"&gt;power level&lt;/a&gt; sensor. This version of the code uses the &lt;a href="http://buildtherobot.blogspot.com/2009/11/debugging-robots-for-fun-and-profit.html"&gt;debug info LED configuration&lt;/a&gt; to report the current level of the battery. If your robot is not plugged in, you can actually see the voltage drop when PF1/2 are pressed and the servos are moving. This is achieved by setting the multiplexer ADMUX to channel ADC1, and enabling the AD conversion complete interrupt in ADCSRA, which saves the voltage to the global location gA2D. It is only occasionally necessary to know the voltage, so conversion requests are triggered manually (as opposed to continuously) by setting the ADSC bit.&lt;br /&gt;&lt;br /&gt;Recharging is enabled by setting bit 4 on PORTB, which digitally connects the battery to the external power source. Pressing and holding PF1 and PF2 for 2.5 seconds enters recharge mode, which &lt;a href="http://en.wikipedia.org/wiki/Trickle_charge"&gt;trickle charges&lt;/a&gt; the NiMH batteries. Because I'm paranoid after the &lt;a href="http://buildtherobot.blogspot.com/2009/11/it-was-only-matter-of-time.html"&gt;previous incident&lt;/a&gt;, the default setting is to only charge the robot for 10 seconds at a time. If you want to fully charge the batteries, pressing PF1 while the robot is charging will keep the batteries charging indefinitely.&lt;br /&gt;&lt;br /&gt;"But Alex!" hear you cry. "If you can measure the voltage, why not simply disable charging when it's maxed out?"&lt;br /&gt;&lt;br /&gt;Unfortunately, it's &lt;a href="http://tvtropes.org/pmwiki/pmwiki.php/Main/SpannerInTheWorks"&gt;not that simple&lt;/a&gt;. When the external power source is present, the RBC automatically changes over the V++ supply to the power pack and &lt;i&gt;becomes the voltage source&lt;/i&gt;. This means that whenever the plug is in, the value of gA2D will be that of the power source - even when the battery is low. I haven't figured out a way around this - you might also have noticed that there is no automatic recharge cut-off for the default firmware either.&lt;br /&gt;&lt;br /&gt;The code is &lt;a href="http://up-file.com/download/4444.4b5877f12736faa48cd1325ef"&gt;here&lt;/a&gt;. I'm looking for a better hosting service, but in the meantime, remember the click the "free" tab.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4136375076360613625-2765862706948690546?l=buildtherobot.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://buildtherobot.blogspot.com/feeds/2765862706948690546/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://buildtherobot.blogspot.com/2009/12/son-of-voltron.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/2765862706948690546'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/2765862706948690546'/><link rel='alternate' type='text/html' href='http://buildtherobot.blogspot.com/2009/12/son-of-voltron.html' title='Son of Voltron'/><author><name>Alex Jarkey</name><uri>http://www.blogger.com/profile/02033809613943284663</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_PZjyemYqS8E/S0uqTx1jdrI/AAAAAAAAAFM/EVGW1FeCizY/S220/peas.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4136375076360613625.post-2918389571944357424</id><published>2009-12-03T02:02:00.000-08:00</published><updated>2009-12-14T23:34:39.141-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='robot'/><category scheme='http://www.blogger.com/atom/ns#' term='servo'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><category scheme='http://www.blogger.com/atom/ns#' term='interrupt'/><title type='text'>If I only had a brain</title><content type='html'>As &lt;a href="http://buildtherobot.blogspot.com/2009/11/debugging-robots-for-fun-and-profit.html"&gt;promised&lt;/a&gt;, I have made some changes to the robobuilder source files so that movement commands execute properly.&lt;br /&gt;&lt;br /&gt;The problem seemed to be that the wCK &lt;a href="http://www.nongnu.org/avr-libc/user-manual/group__avr__interrupts.html"&gt;transmit interrupt&lt;/a&gt; was being disabled prematurely, before all of the instructions could be sent. General &lt;a href="http://en.wikipedia.org/wiki/Defensive_programming"&gt;defensive programming&lt;/a&gt; practice on behalf of the designers meant that any function which placed commands into the transmit buffer intentionally waited patiently until the buffer was empty. This avoided accidentally fragmenting the instructions due to the limited size of the buffer, but meant that the program would just freeze up if (for whatever reason) the transmissions were not being sent.&lt;br /&gt;&lt;br /&gt;With a little debugging, I identified the MakeFrame() function as the culprit, which was causing the program to get stuck waiting for the transmit queue to clear, but since the interrupt was disabled it stayed in an infinite loop. Simply placing a few lines &lt;i&gt;inside the while loop&lt;/i&gt; making sure that the interrupts were enabled fixed the problem.&lt;br /&gt;&lt;br /&gt;I also made a few other aesthetic changes - mostly making things more readable by replacing "&lt;a href="http://en.wikipedia.org/wiki/Magic_number_%28programming%29#Unnamed_numerical_constants"&gt;magic numbers&lt;/a&gt;" with the names of registers. For the uninitiated, A |= (1&amp;lt;&amp;lt;X) means 'set' bit X in register A, while A &amp;amp;= ~(1&amp;lt;&amp;lt;X) will 'clear' the bit. The header file iom128.h&lt;x) &amp;amp;="~(1&amp;lt;&amp;lt;X)" a,="" a="" bit.="" bit="" clear="" file="" header="" in="" iom128.h="" means="" register="" set="" the="" while="" will="" x=""&gt;&lt;bit) &amp;amp;="~(1&amp;lt;&amp;lt;BIT) " and="" bit.="" bit="" clear="" file="" header="" in="" means="" reg="" register,="" set="" the=""&gt;&lt;iom128.h&gt; in &lt;a href="http://www.nongnu.org/avr-libc/"&gt;avr-libc &lt;/a&gt;contains the names of all the registers.&lt;/iom128.h&gt;&lt;/bit)&gt;&lt;/x)&gt;&lt;br /&gt;&lt;br /&gt;Overall, the code here is a very good starting point if you want to start messing around with your robobuilder's brain. However, the functions do a LOT of &lt;a href="http://en.wikipedia.org/wiki/Polling_%28computer_science%29"&gt;polling&lt;/a&gt;, which should be replaced with interrupt based timing control if you plan to implement more complicated functions. &lt;br /&gt;&lt;br /&gt;The files can be found &lt;a href="http://up-file.com/download/4254.493b5bd8fe8a1214feb981329"&gt;here&lt;/a&gt;. I apologise for the horrible free hosting service. Be sure you click on the "Free" tab before you hit download.&lt;br /&gt;&lt;br /&gt;My next goal is to figure out how the recharging procedure works, and give the robot some sort of power management routine. Perhaps eventually he will be able to detect when his batteries are dying and go recharge himself.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4136375076360613625-2918389571944357424?l=buildtherobot.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://buildtherobot.blogspot.com/feeds/2918389571944357424/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://buildtherobot.blogspot.com/2009/12/if-i-only-had-brain.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/2918389571944357424'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/2918389571944357424'/><link rel='alternate' type='text/html' href='http://buildtherobot.blogspot.com/2009/12/if-i-only-had-brain.html' title='If I only had a brain'/><author><name>Alex Jarkey</name><uri>http://www.blogger.com/profile/02033809613943284663</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_PZjyemYqS8E/S0uqTx1jdrI/AAAAAAAAAFM/EVGW1FeCizY/S220/peas.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4136375076360613625.post-185818899504826030</id><published>2009-11-30T17:21:00.000-08:00</published><updated>2010-01-06T17:02:12.036-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='repair'/><category scheme='http://www.blogger.com/atom/ns#' term='robot'/><category scheme='http://www.blogger.com/atom/ns#' term='servo'/><title type='text'>It was only a matter of time...</title><content type='html'>It was &lt;a href="http://www.youtube.com/watch?v=yoF518hBFjU"&gt;inevitable&lt;/a&gt;, really.&lt;br /&gt;&lt;br /&gt;While chasing a guinea pig under a table, I managed to cause enough vibrations for the robot to topple off and land face-first on the ground. Although this may sound both &lt;a href="http://tvtropes.org/pmwiki/pmwiki.php/Main/ComedicSociopathy"&gt;comical&lt;/a&gt; and &lt;a href="http://tvtropes.org/pmwiki/pmwiki.php/Main/Kawaisa"&gt;adorable&lt;/a&gt;, I was not amused.&lt;br /&gt;&lt;br /&gt;At first, everything seemed OK, but closer inspection revealed that one of the spanner shaped connectors had snapped, and more thorough testing revealed that one of the servos was making a grinding noise.&lt;br /&gt;&lt;br /&gt;Disappointed, but not discouraged, I voided my warranty and opened it up to see what the problem was.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://3.bp.blogspot.com/_PZjyemYqS8E/SxRzGxwJqRI/AAAAAAAAADI/UiffifWSR1Q/s1600/091201_open.jpg" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"&gt;&lt;img alt="" border="0" id="BLOGGER_PHOTO_ID_5410075612650514706" src="http://3.bp.blogspot.com/_PZjyemYqS8E/SxRzGxwJqRI/AAAAAAAAADI/UiffifWSR1Q/s320/091201_open.jpg" style="cursor: pointer; display: block; height: 240px; margin: 0px auto 10px; text-align: center; width: 320px;" /&gt;&lt;/a&gt;&lt;br /&gt;As it turns out, I had stripped some teeth of a plastic gear, which meant that the motor was spinning uselessly as the feedback loop was broken. Fortunatley - in one of the more pleasant customer experiences I have had - it turns out that the &lt;a href="http://www.robosavvy.com/"&gt;robosavvy&lt;/a&gt; people had included a bag of spare servo gears.&lt;br /&gt;&lt;a href="http://1.bp.blogspot.com/_PZjyemYqS8E/SxRziWYBLjI/AAAAAAAAADY/yojaFGVcqzE/s1600/091201_gears.jpg" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"&gt;&lt;img alt="" border="0" id="BLOGGER_PHOTO_ID_5410076086337875506" src="http://1.bp.blogspot.com/_PZjyemYqS8E/SxRziWYBLjI/AAAAAAAAADY/yojaFGVcqzE/s320/091201_gears.jpg" style="cursor: pointer; display: block; height: 240px; margin: 0px auto 10px; text-align: center; width: 320px;" /&gt;&lt;/a&gt;&lt;br /&gt;So fixing it was just a matter of unscrewing the case and&lt;a href="http://www.imdb.com/character/ch0003026/quotes"&gt; feasting on the delicious&lt;/a&gt; &lt;a href="http://en.wikipedia.org/wiki/Lubricant"&gt;goo inside&lt;/a&gt;. If a screwdriver was included in your kit, don't use it to open the servo cases! It's just a shade too big, and I ruined the tip by trying to get the screws out. Just one size smaller should do it, but be sure to push down hard against the screw so that you don't strip the head off.&lt;br /&gt;&lt;a href="http://3.bp.blogspot.com/_PZjyemYqS8E/SxRzTy4hWWI/AAAAAAAAADQ/RLxlTtwGWh0/s1600/091201_all.jpg" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"&gt;&lt;img alt="" border="0" id="BLOGGER_PHOTO_ID_5410075836292356450" src="http://3.bp.blogspot.com/_PZjyemYqS8E/SxRzTy4hWWI/AAAAAAAAADQ/RLxlTtwGWh0/s320/091201_all.jpg" style="cursor: pointer; display: block; height: 240px; margin: 0px auto 10px; text-align: center; width: 320px;" /&gt;&lt;/a&gt;&lt;br /&gt;Included in my kit was an instruction sheet (the backdrop of these photos), which explained how the wCK modules can be re-assembled. I don't know if this is because the expect them to need servicing at some time, or just because they had the CAD models lying around. Either way, there isn't much to the gear assembly, so don't be afraid to open one up if you are curious. After replacing the damaged gear, I simply slid the bearing back on to the drive shaft and put the case back on.&lt;br /&gt;&lt;a href="http://1.bp.blogspot.com/_PZjyemYqS8E/SxR0uhVouYI/AAAAAAAAADg/tDPrk9_xnw0/s1600/091201_assemble.jpg" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"&gt;&lt;img alt="" border="0" id="BLOGGER_PHOTO_ID_5410077394950732162" src="http://1.bp.blogspot.com/_PZjyemYqS8E/SxR0uhVouYI/AAAAAAAAADg/tDPrk9_xnw0/s320/091201_assemble.jpg" style="cursor: pointer; display: block; height: 240px; margin: 0px auto 10px; text-align: center; width: 320px;" /&gt;&lt;/a&gt;At this stage, I was worried that I might have not oriented the output shaft correctly, resulting in the servo position being slightly out of phase with the desired angle. However, the wCKs must use &lt;a href="http://en.wikipedia.org/wiki/Rotary_encoder"&gt;optical encoding&lt;/a&gt; or something to establish their position, so after putting the case back on it just worked straight away. [UPDATE - The servos actually use a potentiometer, but the shaft is designed to only fit correctly].&lt;br /&gt;&lt;br /&gt;So there you go - a potentially disastrous situation was averted thanks to the inclusion of some spare parts. Since nothing lasts forever, I would recommend you order from &lt;a href="http://www.robosavvy.com/"&gt;robosavvy&lt;/a&gt; - their service so far has been exemplary.&lt;br /&gt;&lt;br /&gt;[UPDATE - the &lt;a href="https://admin.robotshop.ca/content/PDF/wck-module-gear-replacement.pdf"&gt;official servo repair instructions&lt;/a&gt; are available]&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4136375076360613625-185818899504826030?l=buildtherobot.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://buildtherobot.blogspot.com/feeds/185818899504826030/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://buildtherobot.blogspot.com/2009/11/it-was-only-matter-of-time.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/185818899504826030'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/185818899504826030'/><link rel='alternate' type='text/html' href='http://buildtherobot.blogspot.com/2009/11/it-was-only-matter-of-time.html' title='It was only a matter of time...'/><author><name>Alex Jarkey</name><uri>http://www.blogger.com/profile/02033809613943284663</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_PZjyemYqS8E/S0uqTx1jdrI/AAAAAAAAAFM/EVGW1FeCizY/S220/peas.bmp'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_PZjyemYqS8E/SxRzGxwJqRI/AAAAAAAAADI/UiffifWSR1Q/s72-c/091201_open.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4136375076360613625.post-64621314470785713</id><published>2009-11-30T13:41:00.000-08:00</published><updated>2009-12-14T13:45:39.290-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='robot'/><category scheme='http://www.blogger.com/atom/ns#' term='software'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><title type='text'>Debugging robots for fun and profit</title><content type='html'>More astute readers who followed the procedure in my last post may have noticed that it didn't actually work.&lt;br /&gt;&lt;br /&gt;That's not to say that the instructions were wrong - those are still the steps to build the &lt;span id="SPELLING_ERROR_0"&gt;robobuilder&lt;/span&gt; C source files and upload them to the &lt;span id="SPELLING_ERROR_1"&gt;RBC&lt;/span&gt;. The problem was that the code which I linked doesn't actually do what it says on the side of the box, so to speak.&lt;br /&gt;&lt;br /&gt;The execution of the code posted on the &lt;span id="SPELLING_ERROR_2"&gt;robosavvy&lt;/span&gt; forum (which is primarily an &lt;span id="SPELLING_ERROR_3"&gt;english&lt;/span&gt; adaptation of the official code) should result in the robot performing the &lt;span id="SPELLING_ERROR_4"&gt;RIGHTPUNCH&lt;/span&gt; action when the PF1 button is pressed. However, when the files are built and installed on the robot, no amount of button pressing will elicit a response from the robot.&lt;br /&gt;&lt;br /&gt;I'm working on producing an updated version of the code which is nice and flexible, which I will upload here when I'm satisfied with it. In the meantime, for those of you playing along at home, I thought I would share a quick debugging procedure known only to a secluded group of embedded systems programmers.&lt;br /&gt;&lt;br /&gt;There are on-chip debuggers available for the &lt;span id="SPELLING_ERROR_5"&gt;AVR&lt;/span&gt; family of &lt;span id="SPELLING_ERROR_6"&gt;microcontrollers&lt;/span&gt;, however I don't have one. There are also situations when the debugger causes more problems than it solves - &lt;span id="SPELLING_ERROR_7"&gt;ie&lt;/span&gt;, by hogging certain pins on the board, or restricting the flow of real-time interrupts. The poor mans solution to this is to set up a quick method of stepping through your program and seeing where it gets to and where it gets stuck. The easiest way of allowing your program to communicate back to you is using the &lt;span id="SPELLING_ERROR_8"&gt;onboard&lt;/span&gt; &lt;span id="SPELLING_ERROR_9"&gt;LEDs&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;#include "macro.h"&lt;br /&gt;#include "main.h"&lt;br /&gt;&lt;br /&gt;WORD &lt;span id="SPELLING_ERROR_10"&gt;gDebugMode&lt;/span&gt; = 1;&lt;br /&gt;&lt;br /&gt;void Debug(BYTE code)&lt;br /&gt;{&lt;br /&gt;if(&lt;span id="SPELLING_ERROR_11"&gt;gDebugMode&lt;/span&gt;)&lt;br /&gt;{&lt;br /&gt;&lt;span id="SPELLING_ERROR_12"&gt;CHK&lt;/span&gt;_BIT7(code)? RUN_LED2_ON : RUN_LED2_OFF; //Green&lt;br /&gt;&lt;span id="SPELLING_ERROR_13"&gt;CHK&lt;/span&gt;_BIT6(code)? PF1_LED2_ON : PF1_LED2_OFF; //Red&lt;br /&gt;&lt;span id="SPELLING_ERROR_14"&gt;CHK&lt;/span&gt;_BIT5(code)? &lt;span id="SPELLING_ERROR_15"&gt;PWR&lt;/span&gt;_LED2_ON : &lt;span id="SPELLING_ERROR_16"&gt;PWR&lt;/span&gt;_LED2_OFF; //Green&lt;br /&gt;&lt;span id="SPELLING_ERROR_17"&gt;CHK&lt;/span&gt;_BIT4(code)? &lt;span id="SPELLING_ERROR_18"&gt;PWR&lt;/span&gt;_LED1_ON : &lt;span id="SPELLING_ERROR_19"&gt;PWR&lt;/span&gt;_LED1_OFF; //Red&lt;br /&gt;&lt;span id="SPELLING_ERROR_20"&gt;CHK&lt;/span&gt;_BIT3(code)? PF1_LED1_ON : PF1_LED1_OFF; //Blue&lt;br /&gt;&lt;span id="SPELLING_ERROR_21"&gt;CHK&lt;/span&gt;_BIT2(code)? RUN_LED1_ON : RUN_LED1_OFF; //Blue&lt;br /&gt;&lt;span id="SPELLING_ERROR_22"&gt;CHK&lt;/span&gt;_BIT1(code)? PF2_LED_ON : PF2_LED_OFF; //Yellow&lt;br /&gt;&lt;span id="SPELLING_ERROR_23"&gt;CHK&lt;/span&gt;_BIT0(code)? ERR_LED_ON : ERR_LED_OFF; //Red&lt;br /&gt;}&lt;br /&gt;return;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;The input to this function is just a number you can assign to a particular error/state code: &lt;span id="SPELLING_ERROR_24"&gt;ie&lt;/span&gt;, Debug(3) would have the error and PF1 &lt;span id="SPELLING_ERROR_25"&gt;LEDs&lt;/span&gt; lit, while DEBUG(0) turns all the &lt;span id="SPELLING_ERROR_26"&gt;LEDs&lt;/span&gt; off. Combined with the use of the _delay_ms(1000) command, you can sprinkle these throughout problem areas and observe how your code branches or if it gets stuck anywhere.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://4.bp.blogspot.com/_PZjyemYqS8E/SxRuPQqYQkI/AAAAAAAAADA/IUADq_steSw/s1600/091201_LED.png" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"&gt;&lt;img alt="" border="0" id="BLOGGER_PHOTO_ID_5410070260828619330" src="http://4.bp.blogspot.com/_PZjyemYqS8E/SxRuPQqYQkI/AAAAAAAAADA/IUADq_steSw/s320/091201_LED.png" style="cursor: pointer; display: block; height: 240px; margin: 0px auto 10px; text-align: center; width: 320px;" /&gt;&lt;/a&gt;&lt;br /&gt;The ordering of the &lt;span id="SPELLING_ERROR_27"&gt;LEDs&lt;/span&gt; may seem arbitrary, and it can be a little hard because the ordering &lt;span id="SPELLING_ERROR_28"&gt;zig&lt;/span&gt;-&lt;span id="SPELLING_ERROR_29"&gt;zags&lt;/span&gt; upwards from &lt;span id="SPELLING_ERROR_30"&gt;LSB&lt;/span&gt; (error) to &lt;span id="SPELLING_ERROR_31"&gt;MSB&lt;/span&gt; (power), and then &lt;span id="SPELLING_ERROR_32"&gt;zigs&lt;/span&gt; back down again. The reasoning behind this is because I wanted to make the lower numbers easier to read, since three of the &lt;span id="SPELLING_ERROR_33"&gt;LEDs&lt;/span&gt; have two possible colours. Hence, it's just normal binary for error values up to 2^5 = 32, and only mildly more complicated for bigger numbers.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4136375076360613625-64621314470785713?l=buildtherobot.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://buildtherobot.blogspot.com/feeds/64621314470785713/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://buildtherobot.blogspot.com/2009/11/debugging-robots-for-fun-and-profit.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/64621314470785713'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/64621314470785713'/><link rel='alternate' type='text/html' href='http://buildtherobot.blogspot.com/2009/11/debugging-robots-for-fun-and-profit.html' title='Debugging robots for fun and profit'/><author><name>Alex Jarkey</name><uri>http://www.blogger.com/profile/02033809613943284663</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_PZjyemYqS8E/S0uqTx1jdrI/AAAAAAAAAFM/EVGW1FeCizY/S220/peas.bmp'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_PZjyemYqS8E/SxRuPQqYQkI/AAAAAAAAADA/IUADq_steSw/s72-c/091201_LED.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4136375076360613625.post-7279872080650171337</id><published>2009-11-25T19:41:00.000-08:00</published><updated>2010-01-11T13:59:16.835-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='robot'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='software'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><title type='text'>C is for cookie</title><content type='html'>The robobuilder kit comes with a suite of tools which can be used to easily create poses and moves. Unfortunately, the overall impression they gave me was that they were useful for little more than making the &lt;a href="http://www.youtube.com/watch?v=9XD_csNQ9l4"&gt;robot dance&lt;/a&gt;. There were some useful features, such as being able to record the current pose of the robot and save it to a file, so I will probably play around with them later.&lt;br /&gt;&lt;br /&gt;One of the most attractive features of the robobuilder system is that the firmware can be reprogrammed in C. If that doesn't send shivers down your spine, the rest of this post will probably be over your head. Go &lt;a href="http://www.escapistmagazine.com/videos/view/zero-punctuation"&gt;watch tv&lt;/a&gt; until the grown-ups are finished talking.&lt;br /&gt;&lt;br /&gt;The tools to customise the robobuilder firmware are available for &lt;a href="http://robosavvy.com/RoboSavvyPages/Robobuilder/C_Tutorial_Source.zip"&gt;download&lt;/a&gt;. It comes with a 70 page PDF tutorial which walks you through the process of using the CodeVisionAVR IDE to customise the example builds included. The CodeVision IDE is not free, but I would recommend following the official procedure if: a) You are new to the C language or microprocessor programming and b) you use Windows.&lt;br /&gt;&lt;br /&gt;If, like me, you fall into neither of the above categories, I suggest you save your money and have a go at using the avr-gcc compiler and/or WinAVR (which is just a Windows implementation of avr-gcc).&lt;br /&gt;&lt;br /&gt;But first, a short rant.&lt;br /&gt;&lt;br /&gt;When did motherboard manufacturers stop including serial ports?! I know that they are an aging technology, but they are &lt;a href="http://www.codeproject.com/KB/IP/serialporttocommunicate.aspx"&gt;damn&lt;/a&gt; &lt;a href="http://hackaday.com/2009/10/21/mind-control-via-serial-port/"&gt;useful&lt;/a&gt;. And you, robobuilder - you knew this all along but you didn't ship with a USB adapter or anything. I'm very disappointed. So here I am, forced to write code on the only computer in the house with a serial port - an old Dell Latitude D600. It runs Ubuntu 9.04 and was being used as a media centre PC, but I've since commandeered it in the name of the robot uprising. FYI, all of the robobuilder tools and software will run under WINE.&lt;br /&gt;&lt;br /&gt;If you are compiling your code in linux, you will need to install avr-gcc and avr-libc. For reasons unknown, avr-gcc will not detect that avr-libc is installed and include it's headers when you compile. If you get an error message like:&lt;br /&gt;&lt;br /&gt;error: avr/io.h: No such file or directory&lt;br /&gt;&lt;br /&gt;You may need to copy the contents of /usr/lib/avr/include to /usr/lib/gcc/avr/4.3.2/include.&lt;br /&gt;&lt;br /&gt;This &lt;a href="http://robosavvy.co.uk/forum/viewtopic.php?p=17022"&gt;robosavvy&lt;/a&gt; thread contains a port of the official robobuilder example source files which use the standard avr-gcc headers (also, comments in english!). Details about converting headers to gcc can be found at the &lt;a href="http://www.nongnu.org/avr-libc/"&gt;avr-libc page&lt;/a&gt;. This is the skeleton code you need to edit. Use the command:&lt;br /&gt;&lt;br /&gt;avr-gcc -mmcu=atmega128 -I. -g -Wall -Os -c main.c&lt;br /&gt;&lt;br /&gt;to compile the source. I do recommend the -Os flag, since there is only 128kB of flash memory on the chip. You may still get some error messages at this stage - I did.&lt;br /&gt;&lt;avr h=""&gt;&lt;br /&gt;The names of header files are case sensitive in gcc, so check that the names of the #includes match the filenames:&lt;stdio.h&gt;&lt;util h=""&gt;&lt;avr h=""&gt;&lt;avr h=""&gt;&lt;br /&gt;&lt;br /&gt;#include "macro.h"&lt;br /&gt;#include "main.h"&lt;br /&gt;#include "comm.h"&lt;br /&gt;#include "dio.h"&lt;br /&gt;#include "math.h"&lt;br /&gt;&lt;br /&gt;This should get rid of the remaining compile errors. Next you must link the files together using:&lt;br /&gt;&lt;br /&gt;avr-gcc -o main.elf -mmcu=atmega128 main.o comm.o dio.o&lt;br /&gt;&lt;br /&gt;If you get linker errors at this stage, check that you used the same -mmcu values for both compiling and linking (otherwise, gcc will try to link to code intended for different platforms).The final step is to convert the instructions to hex using the command:&lt;br /&gt;&lt;br /&gt;avr-objcopy -j .text -O ihex main.elf main.hex&lt;br /&gt;&lt;br /&gt;The .hex file created from this step is the actual firmware which will be written to the atmega128 chip. To upload it to the robot, simply run the "RBC Firmware update tool", and connect the robot using the (shudder) serial cable. Select the appropriate .hex file, and click the "Click Here" button. Now, press the reset button on the robot, and let the download finish.&lt;br /&gt;&lt;br /&gt;To start the custom program, press the PF1 button. BEWARE! If you've made a mistake in your code, your robot will spaz out like an epileptic kid during a fire drill! To prevent damage itself and nearby life forms, either hold it by the head or make sure it is on the floor before testing it. Also note that unless you've specifically prevented such actions, the robot has no idea of it's own kinematics - meaning that it is quite likley to try and put it's arms through it's body when trying to scratch it's back. Be ready to kill the power if you want to prevent damage to the servos.&lt;br /&gt;&lt;/avr&gt;&lt;/avr&gt;&lt;/util&gt;&lt;/stdio.h&gt;&lt;/avr&gt;&lt;br /&gt;&lt;avr h=""&gt;&lt;stdio.h&gt;&lt;util h=""&gt;&lt;avr h=""&gt;&lt;avr h=""&gt;Now that I have some skeleton code to play with, over the next few days I'll experiment with various useful functions of the chip, like loading pre-built motions and getting data from the IR remote.&lt;br /&gt;&lt;br /&gt;&lt;/avr&gt;&lt;/avr&gt;&lt;/util&gt;&lt;/stdio.h&gt;&lt;/avr&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4136375076360613625-7279872080650171337?l=buildtherobot.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://buildtherobot.blogspot.com/feeds/7279872080650171337/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://buildtherobot.blogspot.com/2009/11/c-is-for-cookie.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/7279872080650171337'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/7279872080650171337'/><link rel='alternate' type='text/html' href='http://buildtherobot.blogspot.com/2009/11/c-is-for-cookie.html' title='C is for cookie'/><author><name>Alex Jarkey</name><uri>http://www.blogger.com/profile/02033809613943284663</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_PZjyemYqS8E/S0uqTx1jdrI/AAAAAAAAAFM/EVGW1FeCizY/S220/peas.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4136375076360613625.post-2571347135424453653</id><published>2009-11-23T18:39:00.000-08:00</published><updated>2009-11-23T22:07:40.883-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='mechanical'/><category scheme='http://www.blogger.com/atom/ns#' term='robot'/><category scheme='http://www.blogger.com/atom/ns#' term='servo'/><category scheme='http://www.blogger.com/atom/ns#' term='biped'/><title type='text'>It's Alive!!</title><content type='html'>The Robobuilder kit is actually really easy to put together. Inspired by &lt;a href="http://www.youtube.com/watch?v=ejROvUC-gWU"&gt;similar&lt;/a&gt; &lt;a href="http://www.youtube.com/watch?v=V__NZ8LQ-DE"&gt;robots&lt;/a&gt;, I chose to assemble the &lt;a href="http://www.robobuilder.net/eng/robobuilder/jorip_huno_02.asp"&gt;HUNO&lt;/a&gt; configuration.&lt;br /&gt;&lt;br /&gt;The instructions are very easy to follow, but here are a few things that I learned which might make it easier if you are having trouble.&lt;br /&gt;&lt;br /&gt;Firstly, whenever I build something, I assume I will make at least one mistake. This might mean undoing and re-doing several steps, so I never tighten anything down completely. This has the added advantage of making it easier to line up parts which are already attached to the assembly. Most of the wCK servos are attached to the frame using four screws, but only two are necessary to fully constrain the unit. Once I had fully tested the robot, I went back and put the other two screws in each of the servos.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_PZjyemYqS8E/SwtaRBJXMyI/AAAAAAAAACo/F78RQRXFZ50/s1600/091124_leg.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 320px; height: 183px;" src="http://1.bp.blogspot.com/_PZjyemYqS8E/SwtaRBJXMyI/AAAAAAAAACo/F78RQRXFZ50/s320/091124_leg.png" alt="" id="BLOGGER_PHOTO_ID_5407515026000392994" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;I was glad I took my own advice when I realised about 4 steps in that &lt;span style="font-style: italic;"&gt;the numbers on the servos actually matter.&lt;/span&gt; I should have realised this earlier, since the servos are daisy chained together, so they must need to be addressed in some fashion. It is possible to reassign the ID numbers on the servo, but all of the examples and tools assume you have assembled the model as shown in the instructions.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_PZjyemYqS8E/SwtcjHxmlpI/AAAAAAAAAC4/9Q7b5u9oN_A/s1600/091124_servo.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 320px; height: 288px;" src="http://4.bp.blogspot.com/_PZjyemYqS8E/SwtcjHxmlpI/AAAAAAAAAC4/9Q7b5u9oN_A/s320/091124_servo.png" alt="" id="BLOGGER_PHOTO_ID_5407517536040687250" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;The little &lt;a href="http://en.wikipedia.org/wiki/Adjustable_spanner"&gt;spanner&lt;/a&gt; shaped connectors have a tiny bronze threaded nut in one side of them. If the bolt you are using isn't exactly lined up with the hole, it has a tendency to push the bronze nut out of the plastic. Once out, it's really hard to get back in, so make sure that you can see right through the hole before you put the bolt in.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_PZjyemYqS8E/SwtY_Pvo0uI/AAAAAAAAACg/YvBXOHZo3A0/s1600/091124_spanner.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 320px; height: 315px;" src="http://2.bp.blogspot.com/_PZjyemYqS8E/SwtY_Pvo0uI/AAAAAAAAACg/YvBXOHZo3A0/s320/091124_spanner.png" alt="" id="BLOGGER_PHOTO_ID_5407513621169754850" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Finally, I strongly recommend attaching the arms (steps 15 and 16) before attaching the legs (step 14). The legs are very heavy and tend to flop around while you're trying to orient the arms to put the bolt in. The arms are much lighter and won't move under their own weight.&lt;br /&gt;&lt;br /&gt;Anyway, without further ado, here he is!&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_PZjyemYqS8E/SwtVYuOrqRI/AAAAAAAAACY/Bddqk_z-8fI/s1600/091124_assembled.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 238px; height: 320px;" src="http://3.bp.blogspot.com/_PZjyemYqS8E/SwtVYuOrqRI/AAAAAAAAACY/Bddqk_z-8fI/s320/091124_assembled.png" alt="" id="BLOGGER_PHOTO_ID_5407509660803246354" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Isn't he cute?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4136375076360613625-2571347135424453653?l=buildtherobot.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://buildtherobot.blogspot.com/feeds/2571347135424453653/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://buildtherobot.blogspot.com/2009/11/its-alive.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/2571347135424453653'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/2571347135424453653'/><link rel='alternate' type='text/html' href='http://buildtherobot.blogspot.com/2009/11/its-alive.html' title='It&apos;s Alive!!'/><author><name>Alex Jarkey</name><uri>http://www.blogger.com/profile/02033809613943284663</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_PZjyemYqS8E/S0uqTx1jdrI/AAAAAAAAAFM/EVGW1FeCizY/S220/peas.bmp'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_PZjyemYqS8E/SwtaRBJXMyI/AAAAAAAAACo/F78RQRXFZ50/s72-c/091124_leg.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4136375076360613625.post-4091105681643148656</id><published>2009-11-22T17:10:00.000-08:00</published><updated>2009-11-22T22:45:58.813-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='robot'/><category scheme='http://www.blogger.com/atom/ns#' term='birthday'/><category scheme='http://www.blogger.com/atom/ns#' term='family'/><category scheme='http://www.blogger.com/atom/ns#' term='girlfriend'/><title type='text'>Some assembly required</title><content type='html'>Having a birthday close to Christmas can be challenging when you are young. &lt;a href="http://hubpages.com/hub/original-super-soaker"&gt;Cool&lt;/a&gt; &lt;a href="http://en.wikipedia.org/wiki/Lego_Mindstorms"&gt;toys&lt;/a&gt; are released all year round, so it is important to put a lot of forethought into your letters to Santa if you are to weather the 11-month-drought until next year.&lt;br /&gt;&lt;br /&gt;As an adult however, has it's perks. Despite the discovery of impulse purchases, knowing how hard you work for each dollar you can spare for indulgences usually sucks out all the fun. Hence, I restrict myself to cruising the interslice, imagining all the &lt;a href="http://www.thinkgeek.com/tshirts-apparel/interactive/8a5b/"&gt;cool&lt;/a&gt; &lt;a href="http://www.thinkgeek.com/caffeine/drinks/a273/"&gt;stuff&lt;/a&gt; I could buy and stopping just short of entering my credit card information.&lt;br /&gt;&lt;br /&gt;Often, more than half of my open tabs fall into the "would love to have, but would never buy for myself" category. Sometimes, the right mix of unattended computer, exceptionally bright girlfriend and a wonderful family allows the Christmas-birthday combo to really pay off...&lt;br /&gt;&lt;br /&gt;..like when your entire extended family pitches in to get you your very own &lt;a href="http://robosavvy.com/store/product_info.php/products_id/445"&gt;robotic minion&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Now, as everyone has surely figured out, &lt;a href="http://www.youtube.com/watch?v=oSo49BPYiCc"&gt;robots&lt;/a&gt; are cool. However, I find them particularly fascinating, and have spent 5 years of my life studying them. So I did what any self respecting member of the internet would do, and started a blog.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4136375076360613625-4091105681643148656?l=buildtherobot.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://buildtherobot.blogspot.com/feeds/4091105681643148656/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://buildtherobot.blogspot.com/2009/11/some-assembly-required.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/4091105681643148656'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4136375076360613625/posts/default/4091105681643148656'/><link rel='alternate' type='text/html' href='http://buildtherobot.blogspot.com/2009/11/some-assembly-required.html' title='Some assembly required'/><author><name>Alex Jarkey</name><uri>http://www.blogger.com/profile/02033809613943284663</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_PZjyemYqS8E/S0uqTx1jdrI/AAAAAAAAAFM/EVGW1FeCizY/S220/peas.bmp'/></author><thr:total>0</thr:total></entry></feed>
