Extending the ASURO: AsuroLib
I've known about this library for quite a while now, but I haven't really paid any serious attention to it. Shame on me!
By visiting the project's home page you can see that the guys are busy with three packages:
- Asurino, which is a library for the Arduino IDE
- AsuroBoot, a modified Bootloader for ASURO (the modified version that is compatible with Arduino)
- AsuroLib, a library for ASURO
I did say 'the guys are busy with...' and that was with a good reason: all the packages have been kept up to date and continuously improved (most recent update is from the end of March).
So, let's talk about AsuroLib.
It would've been a great pity if I missed this and sticked only to the original ASURO API. Now, this is not to say that the original API is not good or anything, in fact it's great, but as anything created around 2004...it's just old.
Ok, so you may ask...What's so great about it? (I asked the same question myself)
1. you get new functions for your ASURO. And I don't only mean those that allow you to turn the robot a certain angle, go a certain distance, motor calibration, etc. I'm especially talking about new LCD functions (for those that have an LCD on their ASURO), Encoder functions, RC5 remote control, and of course...the Ultra-Sonic sensor.
2. you get much smaller .hex file when you compile your code to feed it to your robot. (my average was 46 pages to flash, now it's really only 24!!). This is because starting from version 2.70 AsuroLib is no longer just a source code library but an object code library. This means that only what you really need and use in your code will be included into the .hex file. Very nice! (read about object code)
3. you don't have to change anything on your robot. I thought I should mention that. In fact, if you have the already compiled program (a sample), all you have to do is to flash it and nothing more.
However in order to build and compile your own application you may have to read the help file at least once. Hopefully you know German as well, because from time to time the English version of the manual becomes plain German
'Google Translate' will try to be your friend on this one.
Here's a short sample of making the ASURO 'sense' collisions. You can also find it in the AsuroLib/examples folder.
/*************************************************************************** * * File Name: kollisiontest.c * Project : ASURO * * Description: Kollisionstest mit Hilfe der Tastensensoren * * Ver. Date Author Comments * ------- ---------- ----------------- ------------------------------ * 1.0 10.09.2005 m.a.r.v.i.n initial build * 1.1 08.01.2006 m.a.r.v.i.n 2x PollSwitch + Vergleich, * anstelle 8x PollSwitch * * benoetigt die modifizierte Asuro Bibliothek 'asuro.c' * von waste, stochri und andun. Zu finden bei www.roboternetz.de */ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * any later version. * ***************************************************************************/ #include "asuro.h" #define FULL_L 128 #define FULL_R 128 /* Drive forward*/ void MotorFwd(void) { MotorDir(FWD,FWD); MotorSpeed(FULL_L,FULL_R); } /* Drive backwawrd */ void MotorRwd(void) { MotorDir(RWD,RWD); MotorSpeed(FULL_L,FULL_R); } /* Reverse curve left */ void MotorRwdL(void) { MotorDir(RWD,RWD); MotorSpeed(FULL_L,0); } /* Reverse curve right */ void MotorRwdR(void) { MotorDir(RWD,RWD); MotorSpeed(0, FULL_R); } /* Motor stop */ void MotorStop(void) { MotorSpeed(0,0); } int main(void) { unsigned char t1, t2; Init(); while (1) { t1 = PollSwitch(); t2 = PollSwitch(); if (t1 == 0 && t2 == 0) /* no contact */ { MotorFwd(); /* drive forward */ FrontLED(ON); BackLED(OFF,OFF); } else if (t1 && t2 && t1 == t2) { MotorStop(); if (t1 & 0x07) /* Left touch sensors contact? */ { MotorRwdL(); /* Reverse curve left */ FrontLED(OFF); BackLED(ON,OFF); } if (t1 & 0x38) /* Right touch sensors contact? */ { MotorRwdR(); /* Reverse curve right */ FrontLED(OFF); BackLED(OFF,ON); } Msleep(1000); /* Drive for 1 second */ } } return 0; }


