Würde mich wirklich freuen, wenn mehr Nibo-Besitzer sich hier einfinden würden. Sowohl die Hardware als auch bereits die allererste C/C++-Bibliothek ist eine hervorragende Basis für eigene Entwicklungen, und der ATmega128 bietet ausreichend Platz und I/O-Ports. Die "Dreckarbeit" (Motor steuern, Kollision vermeiden) erledigen ja bereits die beiden ATtiny44, mit denen der Hauptprozessor über I²C kommuniziert. :)Zitat:
... hab jetzt die Doku überflogen, sieht sauber aus, denk' ich könnt' den auch aufbauen. *fg*
Als kleines Beispiel (noch nicht perfekt) für die Motorsteuerung:
Im Gegensatz zu seinem kleinen Bruder fällt Nibo das Geradeausfahren leicht. Der MOTCO nimmt dem Hauptprozessor delegierbare Regelungs-Arbeit (Geschwindigkeit, Richtung) gerne ab.Code:#include <avr/interrupt.h>
#include "nibo/niboconfig.h"
#include "nibo/delay.h"
#include "nibo/pwm.h"
#include "nibo/display.h"
#include "nibo/bot.h"
#include "nibo/gfx.h"
#include "nibo/bot.h"
#include "nibo/gfx.h"
#include "nibo/leds.h"
#include "nibo/motco.h"
void textout(int x, int y, char* str, int ft)
{
gfx_move(x,y);
gfx_print_text(str,ft);
}
void Go(int dist, int cm_pro_sec)
{
const float TICKS_PER_CM = 1.75f;
motco_resetOdometry(0,0);
motco_update();
int limit = dist * TICKS_PER_CM;
int pwm = cm_pro_sec * 80;
if (pwm > 1024) pwm = 1024;
if (pwm < -1024) pwm = -1024;
motco_setPWM(pwm,pwm);
motco_setSpeed(cm_pro_sec * TICKS_PER_CM , cm_pro_sec * TICKS_PER_CM);
motco_update();
delay(3000); //TODO: Verzögerung muss noch weg
do
{
motco_update(); /* fährt brav geradeaus */
}
while(motco_ticks_l < limit);
}
int main()
{
sei(); // enable interrupts
bot_init();
leds_init();
pwm_init();
display_init();
gfx_init();
leds_set_displaylight(800);
textout(10,10,"Nibo meldet:",0);
textout(10,24,"Motor an!",0);
textout(10,38,"Licht an!",0);
leds_set_headlights(512);
int i,j;
for(i=1;i<=6;++i)
{
for(j=0;j<i;++j)
leds_set_status(LEDS_GREEN,j);
Go(50,10*i);
}
leds_set_headlights(0);
motco_stop();
motco_update();
for(j=0;j<6;++j)
leds_set_status(LEDS_OFF,j);
textout(10,24,"Motor aus!",0);
textout(10,38,"Licht aus!",0);
while(1);
return 0;
}
Hier der Video-Link (2,7 MB) zum Programm: http://www.henkessoft.de/Roboter/Bilder/Nibo.wmv
Die Abstandsmessung mittels IR-Sensoren wird prinzipiell in diesem Programm gezeigt:
Allerdings nimmt Nibo bei mir selbst den Boden noch als Hindernis wahr. Das leuchtet mir konstruktiv noch nicht richtig ein.Code:#include <stdlib.h>
#include <avr/interrupt.h>
#include "nibo/niboconfig.h"
#include "nibo/delay.h"
#include "nibo/pwm.h"
#include "nibo/display.h"
#include "nibo/leds.h"
#include "nibo/bot.h"
#include "nibo/gfx.h"
#include "nibo/irco.h"
void float2string(float value, int decimal, char* valuestring)
{
//... siehe oben!
}
float SupplyVoltage(void)
{
bot_update();
return(0.0166 * bot_supply - 1.19);
}
void textout(int x, int y, char* str, int ft)
{
gfx_move(x,y);
gfx_print_text(str,ft);
}
void Init(void)
{
sei(); // enable interrupts
bot_init();
leds_init();
pwm_init();
display_init();
gfx_init();
}
int main()
{
Init();
leds_set_displaylight(1000);
while(1)
{
float Ubatt = SupplyVoltage();
char text[6];
float2string(Ubatt,2,text);
textout( 0,0,text, 0);
textout(35,0,"Volt",0);
irco_update();
irco_startMeasure();
irco_update();
char irco_string[5][5];
int i;
for(i=0; i<5; ++i)
{
textout(i*21,8," ",0); //löschen
}
for(i=0; i<5; ++i)
{
itoa(irco_distance[i],irco_string[i],10);
textout(i*21,8,irco_string[i],0);
}
delay(200);
}
while(1);
return 0;
}
Das Prinzip ist hier beschrieben: http://nibo.editthis.info/wiki/IR-Controller
Hat jemand eine Idee, wie man die Messung optimieren kann? Das "Raumgefühl" durch Messungen in fünf Richtungen (rechts, vorne rechts, vorne mitte, vorne links, links) soll einer der Vorzüge des Nibo sein. Später können über den Erweiterungsport z.B. weitere Abstandsmessungen nach hinten oder für die berühmten Bürostühle hinzu kommen.