Added lot's of code-files used during work

This commit is contained in:
sicarius 2007-02-11 18:32:03 +00:00
parent 644121b478
commit 56d9bdd39e
155 changed files with 23423 additions and 0 deletions

View file

@ -0,0 +1,98 @@
#ifndef AVAILABLE_BEHAVIOURS_H_
#define AVAILABLE_BEHAVIOURS_H_
#ifdef BEHAVIOUR_AVAILABLE
//#define BEHAVIOUR_SIMPLE_AVAILABLE /*!< sind die Beispielverhalten vorhanden ?*/
//#define BEHAVIOUR_DRIVE_SQUARE_AVAILABLE /*!< Demoverhalten im quadrat fahren vorhanden ?*/
#define BEHAVIOUR_AVOID_BORDER_AVAILABLE /*!< Abgruenden ausweichen vorhanden ?*/
#define BEHAVIOUR_AVOID_COL_AVAILABLE /*!< Hindernis ausweichen vorhanden ?*/
//#define BEHAVIOUR_GOTO_AVAILABLE /*!< goto vorhanden ?*/
#define BEHAVIOUR_GOTOXY_AVAILABLE /*!< gotoxy vorhanden ?*/
#define BEHAVIOUR_TURN_AVAILABLE /*!< turn vorhanden ?*/
#define BEHAVIOUR_DRIVE_DISTANCE_AVAILABLE /*!< strecke fahren vorhanden ?*/
#define BEHAVIOUR_SCAN_AVAILABLE /*!< gegend scannen vorhanden ?*/
#define BEHAVIOUR_SOLVE_MAZE_AVAILABLE /*!< Wandfolger vorhanden ?*/
#define BEHAVIOUR_FOLLOW_LINE_AVAILABLE /*!< Linienfolger vorhanden ?*/
#define BEHAVIOUR_SERVO_AVAILABLE /*!< Kontrollverhalten fuer die Servos */
//#define BEHAVIOUR_OLYMPIC_AVAILABLE /*!< Olympiadenverhalten vorhanden ?*/
#define BEHAVIOUR_CATCH_PILLAR_AVAILABLE /*!< Suche eine Dose und fange sie ein */
#define BEHAVIOUR_REMOTECALL_AVAILABLE /*!< Nehmen wir Remote-kommandos entgegen?*/
/* Aufgrund einer ganzen reihe von Abhaengigkeiten sollte man beim Versuch Speicher
* zu sparen, zuerst mal bei den Hauptverhalten ausmisten, sonst kommen die
* Unterverhalten durch die Hintertuer wieder rein
*/
#ifndef MAP_AVAILABLE
#undef BEHAVIOUR_SCAN_AVAILABLE
#endif
#ifdef BEHAVIOUR_GOTOXY_AVAILABLE
#define BEHAVIOUR_TURN_AVAILABLE
#endif
#ifdef BEHAVIOUR_AVOID_COL_AVAILABLE
#define BEHAVIOUR_TURN_AVAILABLE
#endif
#ifdef BEHAVIOUR_FOLLOW_LINE_AVAILABLE
#define BEHAVIOUR_DRIVE_DISTANCE_AVAILABLE
#define BEHAVIOUR_TURN_AVAILABLE
#endif
#ifdef BEHAVIOUR_OLYMPIC_AVAILABLE
#define BEHAVIOUR_DRIVE_DISTANCE_AVAILABLE
#define BEHAVIOUR_TURN_AVAILABLE
#endif
#ifdef BEHAVIOUR_SIMPLE_AVAILABLE
#define BEHAVIOUR_DRIVE_DISTANCE_AVAILABLE
#endif
#ifdef BEHAVIOUR_SOLVE_MAZE_AVAILABLE
#define BEHAVIOUR_DRIVE_DISTANCE_AVAILABLE
#endif
#ifdef BEHAVIOUR_DRIVE_SQUARE_AVAILABLE
#define BEHAVIOUR_GOTO_AVAILABLE
#endif
#ifdef BEHAVIOUR_CATCH_PILLAR_AVAILABLE
#define BEHAVIOUR_SERVO_AVAILABLE
#endif
#include "bot-logic/behaviour_simple.h"
#include "bot-logic/behaviour_drive_square.h"
#include "bot-logic/behaviour_avoid_border.h"
#include "bot-logic/behaviour_avoid_col.h"
#include "bot-logic/behaviour_goto.h"
#include "bot-logic/behaviour_gotoxy.h"
#include "bot-logic/behaviour_turn.h"
#include "bot-logic/behaviour_drive_distance.h"
#include "bot-logic/behaviour_scan.h"
#include "bot-logic/behaviour_solve_maze.h"
#include "bot-logic/behaviour_follow_line.h"
#include "bot-logic/behaviour_olympic.h"
#include "bot-logic/behaviour_servo.h"
#include "bot-logic/behaviour_catch_pillar.h"
#include "bot-logic/remote_calls.h"
#endif
#endif /*AVAILABLE_BEHAVIOURS_H_*/

View file

@ -0,0 +1,39 @@
/*
* c't-Bot
*
* 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 (at your
* option) any later version.
* This program is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the Free
* Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307, USA.
*
*/
/*! @file behaviour_avoid_border.c
* @brief Vermeide Abgruende
*
* @author Benjamin Benz (bbe@heise.de)
* @date 03.11.06
*/
#ifndef BEHAVIOUR_AVOID_BORDER_H_
#define BEHAVIOUR_AVOID_BORDER_H_
#include "bot-logic/bot-logik.h"
#ifdef BEHAVIOUR_AVOID_BORDER_AVAILABLE
/*!
* Verhindert, dass der Bot in Graeben faellt
* @param *data der Verhaltensdatensatz
*/
void bot_avoid_border_behaviour(Behaviour_t *data);
#endif
#endif /*BEHAVIOUR_AVOID_BORDER_H_*/

View file

@ -0,0 +1,42 @@
/*
* c't-Bot
*
* 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 (at your
* option) any later version.
* This program is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the Free
* Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307, USA.
*
*/
/*! @file behaviour_avoid_col.h
* @brief Vermeide Kollisionen
*
* @author Benjamin Benz (bbe@heise.de)
* @date 03.11.06
*/
#ifndef BEHAVIOUR_AVOID_COL_H_
#define BEHAVIOUR_AVOID_COL_H_
#include "bot-logic/bot-logik.h"
#ifdef BEHAVIOUR_AVOID_COL_AVAILABLE
/*!
* Passt auf, dass keine Kollision mit Hindernissen an der Front des Roboters
* geschieht.
* TODO: Diese Funktion ist nur ein Dummy-Beispiel, wie eine Kollisionsvermeidung aussehen
* koennte. Hier ist ein guter Einstiegspunkt fuer eigene Experimente und Algorithmen!
* @param *data der Verhaltensdatensatz
*/
void bot_avoid_col_behaviour(Behaviour_t *data);
#endif
#endif /*BEHAVIOUR_AVOID_COL_H_*/

View file

@ -0,0 +1,51 @@
/*
* c't-Bot
*
* 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 (at your
* option) any later version.
* This program is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the Free
* Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307, USA.
*
*/
/*! @file behaviour_catch_pillar.c
* @brief sucht nach einer Dose und fängt sie ein
*
* @author Benjamin Benz (bbe@heise.de)
* @date 08.12.06
*/
#ifndef BEHAVIOUR_CATCH_PILLAR_H_
#define BEHAVIOUR_CATCH_PILLAR_H_
#include "ct-Bot.h"
#include "bot-logic/bot-logik.h"
#ifdef BEHAVIOUR_CATCH_PILLAR_AVAILABLE
/*!
* Fange eine Dose ein
* @param *data der Verhaltensdatensatz
*/
void bot_catch_pillar_behaviour(Behaviour_t *data);
/*!
* Botenfkt
* Fange eine Dose ein
* @param caller Der obligatorische Verhaltensdatensatz des Aufrufers
*/
void bot_catch_pillar(Behaviour_t * caller);
#endif
#endif /*BEHAVIOUR_CATCH_PILLAR_H_*/

View file

@ -0,0 +1,57 @@
/*
* c't-Bot
*
* 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 (at your
* option) any later version.
* This program is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the Free
* Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307, USA.
*
*/
/*! @file behaviour_drive_distance.c
* @brief Bot faehrt ein Stueck
*
* @author Benjamin Benz (bbe@heise.de)
* @date 03.11.06
*/
#ifndef BEHAVIOUR_DRIVE_DISTANCE_H_
#define BEHAVIOUR_DRIVE_DISTANCE_H_
#include "bot-logic/bot-logik.h"
#ifdef BEHAVIOUR_DRIVE_DISTANCE_AVAILABLE
/*!
* Das Verhalten laesst den Bot eine vorher festgelegte Strecke fahren.
* @param *data der Verhaltensdatensatz
* @see bot_drive_distance()
*/
void bot_drive_distance_behaviour(Behaviour_t* data);
/*!
* Das Verhalten laesst den Bot eine vorher festgelegte Strecke fahren. Dabei legt die Geschwindigkeit fest, ob der Bot vorwaerts oder rueckwaerts fahren soll.
* @param curve Gibt an, ob der Bot eine Kurve fahren soll. Werte von -127 (So scharf wie moeglich links) ueber 0 (gerade aus) bis 127 (so scharf wie moeglich rechts)
* @param speed Gibt an, wie schnell der Bot fahren soll. Negative Werte lassen den Bot rueckwaerts fahren.
* @param cm Gibt an, wie weit der Bot fahren soll. In cm :-) Die Strecke muss positiv sein, die Fahrtrichtung wird ueber speed geregelt.
*/
void bot_drive_distance(Behaviour_t* caller,int8 curve, int16 speed, int16 cm);
/*!
* laesst den Bot in eine Richtung fahren.
* Es handelt sich hierbei nicht im eigentlichen Sinn um ein Verhalten, sondern ist nur eine Abstraktion der Motorkontrollen.
* @param curve Gibt an, ob der Bot eine Kurve fahren soll. Werte von -127 (So scharf wie moeglich links) ueber 0 (gerade aus) bis 127 (so scharf wie moeglich rechts)
* @param speed Gibt an, wie schnell der Bot fahren soll. */
void bot_drive(int8 curve, int16 speed);
#endif
#endif /*BEHAVIOUR_DRIVE_DISTANCE_H_*/

View file

@ -0,0 +1,50 @@
/*
* c't-Bot
*
* 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 (at your
* option) any later version.
* This program is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the Free
* Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307, USA.
*
*/
/*! @file behaviour_drive_square.h
* @brief Bot faehrt im Quadrat
*
* @author Benjamin Benz (bbe@heise.de)
* @date 03.11.06
*/
#ifndef BEHAVIOUR_DRIVE_SQUARE_H_
#define BEHAVIOUR_DRIVE_SQUARE_H_
#include "bot-logic/bot-logik.h"
#ifdef BEHAVIOUR_DRIVE_SQUARE_AVAILABLE
/*!
* Laesst den Roboter ein Quadrat abfahren.
* Einfaches Beispiel fuer ein Verhalten, das einen Zustand besitzt.
* Es greift auf andere Behaviours zurueck und setzt daher
* selbst keine speedWishes.
* @param *data der Verhaltensdatensatz
*/
void bot_drive_square_behaviour(Behaviour_t *data);
/*!
* Laesst den Roboter ein Quadrat abfahren.
* @param caller Der obligatorische Verhaltensdatensatz des aufrufers
*/
void bot_drive_square(Behaviour_t* caller);
#endif
#endif /*BEHAVIOUR_DRIVE_SQUARE_H_*/

View file

@ -0,0 +1,44 @@
/*
* c't-Bot
*
* 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 (at your
* option) any later version.
* This program is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the Free
* Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307, USA.
*
*/
/*! @file behaviour_follow_line.h
* @brief Linienverfolger
*
* @author Benjamin Benz (bbe@heise.de)
* @date 03.11.06
*/
#include "bot-logic/bot-logik.h"
#ifndef BEHAVIOUR_FOLLOW_LINE_H_
#define BEHAVIOUR_FOLLOW_LINE_H_
#ifdef BEHAVIOUR_FOLLOW_LINE_AVAILABLE
/*! Folgt einer Linie, sobald beide Liniensensoren ausloesen
* Die Linie sollte in etwa die Breite beider CNY70 haben
*/
void bot_follow_line_behaviour(Behaviour_t *data);
/*! Folgt einer Linie, sobald beide Liniensensoren ausloesen
* Die Linie sollte in etwa die Breite beider CNY70 haben
*/
void bot_follow_line(Behaviour_t *caller);
#endif
#endif /*BEHAVIOUR_FOLLOW_LINE_H_*/

View file

@ -0,0 +1,46 @@
/*
* c't-Bot
*
* 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 (at your
* option) any later version.
* This program is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the Free
* Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307, USA.
*
*/
/*! @file behaviour_goto.h
* @brief Fahre ein stueck
*
* @author Benjamin Benz (bbe@heise.de)
* @date 03.11.06
*/
#ifndef BEHAVIOUR_GOTO_H_
#define BEHAVIOUR_GOTO_H_
#include "bot-logic/bot-logik.h"
#ifdef BEHAVIOUR_GOTO_AVAILABLE
/*!
* Kuemmert sich intern um die Ausfuehrung der goto-Kommandos,
* @param *data der Verhaltensdatensatz
* @see bot_goto()
*/
void bot_goto_behaviour(Behaviour_t *data);
/*!
* Drehe die Raeder um die gegebene Zahl an Encoder-Schritten weiter
* @param left Schritte links
* @param right Schritte rechts
*/
void bot_goto(Behaviour_t * caller, int16 left, int16 right);
#endif
#endif /*BEHAVIOUR_GOTO_H_*/

View file

@ -0,0 +1,50 @@
/*
* c't-Bot
*
* 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 (at your
* option) any later version.
* This program is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the Free
* Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307, USA.
*
*/
/*! @file behaviour_gotoxy.c
* @brief Bot faehrt eine Position an
*
* @author Benjamin Benz (bbe@heise.de)
* @date 03.11.06
*/
#ifndef BEHAVIOUR_GOTOXY_H_
#define BEHAVIOUR_GOTOXY_H_
#include "bot-logic/bot-logik.h"
#ifdef BEHAVIOUR_GOTOXY_AVAILABLE
/*!
* Das Verhalten faehrt von der aktuellen Position zur angegebenen Position (x/y)
* @param *data der Verhaltensdatensatz
* Verbessert von Thomas Noll, Jens Schoemann, Ben Horst (Philipps-Universitaet Marburg)
*/
void bot_gotoxy_behaviour(Behaviour_t *data);
/*!
* Botenfunktion: Das Verhalten faehrt von der aktuellen Position zur angegebenen Position (x/y)
* @param caller Aufrufendes Verhalten
* @param x X-Ordinate an die der Bot fahren soll
* @param y Y-Ordinate an die der Bot fahren soll
*/
void bot_gotoxy(Behaviour_t *caller, float x, float y);
#endif
#endif /*BEHAVIOUR_GOTOXY_H_*/

View file

@ -0,0 +1,93 @@
/*
* c't-Bot
*
* 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 (at your
* option) any later version.
* This program is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the Free
* Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307, USA.
*
*/
/*! @file behaviour_olympic.h
* @brief Bot sucht saeulen und faehrt dann slalom
*
* @author Benjamin Benz (bbe@heise.de)
* @date 03.11.06
*/
#ifndef BEHAVIOUR_OLYMPIC_H_
#define BEHAVIOUR_OLYMPIC_H_
#include "bot-logic/bot-logik.h"
#ifdef BEHAVIOUR_OLYMPIC_AVAILABLE
/*!
* Das Verhalten setzt sich aus 3 Teilverhalten zusammen:
* Nach Licht suchen, auf das Licht zufahren, im Licht Slalom fahren. */
void bot_olympic_behaviour(Behaviour_t *data);
/*!
* Das Verhalten laesst den Roboter den Raum durchsuchen.
* Das Verhalten hat mehrere unterschiedlich Zustaende:
* 1. Zu einer Wand oder einem anderen Hindernis fahren.
* 2. Zu einer Seite drehen, bis der Bot parallel zur Wand ist.
* Es macht vielleicht Sinn, den Maussensor auszulesen, um eine Drehung um
* einen bestimmten Winkel zu realisieren. Allerdings muesste dafuer auch der
* Winkel des Bots zur Wand bekannt sein.
* 3. Eine feste Strecke parallel zur Wand vorwaerts fahren.
* Da bot_glance_behaviour abwechselnd zu beiden Seiten schaut, ist es fuer die Aufgabe,
* einer Wand auf einer Seite des Bots zu folgen, nur bedingt gewachsen und muss
* evtl. erweitert werden.
* 4. Senkrecht zur Wand drehen.
* Siehe 2.
* 5. Einen Bogen fahren, bis der Bot wieder auf ein Hindernis stoesst.
* Dann das Ganze von vorne beginnen, nur in die andere Richtung und mit einem
* weiteren Bogen. So erforscht der Bot einigermassen systematisch den Raum.
*
* Da das Verhalten jeweils nach 10ms neu aufgerufen wird, muss der Bot sich
* 'merken', in welchem Zustand er sich gerade befindet.
* */
void bot_explore_behaviour(Behaviour_t *data);
/*!
* Das Verhalten laesst den Bot einen Slalom fahren.
* @see bot_do_slalom()
* */
void bot_do_slalom_behaviour(Behaviour_t *data);
/*!
* Das Verhalten laesst den Bot zwischen einer Reihe beleuchteter Saeulen Slalom fahren.
* Das Verhalten ist wie bot_explore() in eine Anzahl von Teilschritten unterteilt.
* 1. Vor die aktuelle Saeule stellen, so dass sie zentral vor dem Bot und ungefaehr
* COL_CLOSEST (100 mm) entfernt ist.
* 2. 90 Grad nach rechts drehen.
* 3. In einem relativ engen Bogen 20 cm weit fahren.
* 4. Auf der rechten Seite des Bot nach einem Objekt suchen, dass
* a) im rechten Sektor des Bot liegt, also zwischen -45 Grad und -135 Grad zur Fahrtrichtung liegt,
* b) beleuchtet und
* c) nicht zu weit entfernt ist.
* Wenn es dieses Objekt gibt, wird es zur aktuellen Saeule und der Bot faehrt jetzt Slalom links.
* 5. Sonst zurueck drehen, 90 Grad drehen und Slalom rechts fahren.
* In diesem Schritt kann der Bot das Verhalten auch abbrechen, falls er gar kein Objekt mehr findet.
*/
void bot_do_slalom(Behaviour_t *caller);
/*!
* Initialisiert das Olympische Verhalten
* @param prio_main Prioritaet des Olympischen Verhalten (typ. 100)
* @param prio_helper Prioritaet der Hilfsfunktionen (typ. 52)
* @param active ACTIVE wenn es sofort starten soll, sonst INACTIVE
*/
void bot_olympic_init(int8 prio_main,int8 prio_helper, int8 active);
#endif
#endif /*BEHAVIOUR_OLYMPIC_H_*/

View file

@ -0,0 +1,51 @@
/*
* c't-Bot
*
* 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 (at your
* option) any later version.
* This program is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the Free
* Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307, USA.
*
*/
/*! @file behaviour_scan.h
* @brief Scannt die Umgebung und traegt sie in die Karte ein
*
* @author Benjamin Benz (bbe@heise.de)
* @date 03.11.06
*/
#ifndef BEHAVIOUR_SCAN_H_
#define BEHAVIOUR_SCAN_H_
#include "bot-logic/bot-logik.h"
#ifdef BEHAVIOUR_SCAN_AVAILABLE
/*!
* Der Roboter faehrt einen Vollkreis und scannt dabei die Umgebung
* @param *data der Verhaltensdatensatz
*/
void bot_scan_onthefly_behaviour(Behaviour_t *data);
/*!
* Der Roboter faehrt einen Vollkreis und scannt dabei die Umgebung
* @param *data der Verhaltensdatensatz
*/
void bot_scan_behaviour(Behaviour_t *data);
/*!
* Der Roboter faehrt einen Vollkreis und scannt dabei die Umgebung
* @param Der aufrufer
*/
void bot_scan(Behaviour_t* caller);
#endif
#endif /*BEHAVIOUR_SCAN_H_*/

View file

@ -0,0 +1,55 @@
/*
* c't-Bot
*
* 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 (at your
* option) any later version.
* This program is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the Free
* Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307, USA.
*
*/
/*! @file behaviour_servo.h
* @brief kontrolliert die Servos
*
* @author Benjamin Benz (bbe@heise.de)
* @date 07.12.06
*/
#ifndef BEHAVIOUR_SERVO_H_
#define BEHAVIOUR_SERVO_H_
#include "ct-Bot.h"
#include "bot-logic/bot-logik.h"
#ifdef BEHAVIOUR_SERVO_AVAILABLE
uint8 servo_active; /*!< 0, wenn kein Servo aktiv, sonst Bit der gerade aktiven Servos gesetzt */
/*!
* Dieses Verhalten fuehrt ein Servo-Kommando aus und schaltet danach den Servo wieder ab
*
* @param *data der Verhaltensdatensatz
*/
void bot_servo_behaviour(Behaviour_t *data);
/*!
* Fahre den Servo an eine Position
* @param servo Nummer des Servos
* @param pos Zielposition des Servos
*/
void bot_servo(Behaviour_t * caller, uint8 servo, uint8 pos);
#endif
#endif /*BEHAVIOUR_SIMPLE_H_*/

View file

@ -0,0 +1,90 @@
/*
* c't-Bot
*
* 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 (at your
* option) any later version.
* This program is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the Free
* Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307, USA.
*
*/
/*! @file behaviour_simple.h
* @brief ganz einfache Beispielverhalten
* Diese Datei sollte der Einstiegspunkt fuer eigene Experimente sein,
* den Roboter zu steuern.
*
* @author Benjamin Benz (bbe@heise.de)
* @date 03.11.06
*/
#ifndef BEHAVIOUR_SIMPLE_H_
#define BEHAVIOUR_SIMPLE_H_
#include "ct-Bot.h"
#include "bot-logic/bot-logik.h"
#ifdef BEHAVIOUR_SIMPLE_AVAILABLE
/*!
* Ein ganz einfaches Beispiel fuer ein Hilfsverhalten,
* das selbst SpeedWishes aussert und
* nach getaner Arbeit die aufrufende Funktion wieder aktiviert
* Zudem prueft es, ob eine Uebergabebedingung erfuellt ist.
*
* Zu diesem Verhalten gehoert die Botenfunktion bot_simple2()
*
* Hier kann man auf ganz einfache Weise die ersten Schritte wagen.
* Wer die Moeglichkeiten des ganzen Verhaltensframeworks ausschoepfen will, kann diese Funktion getrost auskommentieren
* und findet dann in bot_behave_init() und bot_behave() weitere Hinweise fuer elegante Bot-Programmierung....
*
* Das Verhalten ist per default abgeschaltet. Daher muss man es erst in bot_behave_init() aktivieren.
* Dort steht aber bereits eine auskommentierte Zeile dazu, von der man nur die zwei Kommentarzeichen wegnehmen muss.
* Achtung, da bot_simple2_behaviour() maximale Prioritaet hat, kommt es vor den anderen Regeln, wie dem Schutz vor Abgruenden, etc. zum Zuge
* Das sollte am Anfang nicht stoeren, spaeter sollte man jedoch die Prioritaet herabsetzen.
*
* bot_simple2_behaviour faehrt den Bot solange geradeaus, bis es dunkler als im Uebergabeparameter spezifiziert ist wird
*
* @param *data der Verhaltensdatensatz
*/
void bot_simple2_behaviour(Behaviour_t *data);
/*!
* Rufe das Simple2-Verhalten auf und uebergebe light
* @param caller Der obligatorische Verhaltensdatensatz des Aufrufers
* @param light Uebergabeparameter
*/
void bot_simple2(Behaviour_t * caller, int16 light);
/*!
* Ein ganz einfaches Verhalten, es hat maximale Prioritaet
* Hier kann man auf ganz einfache Weise die ersten Schritte wagen.
* Wer die Moeglichkeiten des ganzen Verhaltensframeworks ausschoepfen will, kann diese Funktion getrost auskommentieren
* und findet dann in bot_behave_init() und bot_behave() weitere Hinweise fuer elegante Bot-Programmierung....
*
* Das Verhalten ist per default abgeschaltet. Daher muss man es erst in bot_behave_init() aktivieren.
* Dort steht aber bereits eine auskommentierte Zeile dazu, von der man nur die zwei Kommentarzeichen wegnehmen muss.
* Achtung, da bot_simple_behaviour() maximale Prioritaet hat, kommt es vor den anderen Regeln, wie dem Schutz vor Abgruenden, etc. zum Zuge
* Das sollte am Anfang nicht stoeren, spaeter sollte man jedoch die Prioritaet herabsetzen.
*
* @param *data der Verhaltensdatensatz
*/
void bot_simple_behaviour(Behaviour_t *data);
/*!
* Rufe das Simple-Verhalten auf
* @param caller Der obligatorische Verhaltensdatensatz des Aufrufers
*/
void bot_simple(Behaviour_t * caller, int16 light);
#endif
#endif /*BEHAVIOUR_SIMPLE_H_*/

View file

@ -0,0 +1,61 @@
/*
* c't-Bot
*
* 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 (at your
* option) any later version.
* This program is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the Free
* Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307, USA.
*
*/
/*! @file behaviour_solve_maze.h
* @brief Wandfolger durchs Labyrinth
*
* @author Benjamin Benz (bbe@heise.de)
* @date 03.11.06
*/
#ifndef BEHAVIOUR_SOLVE_MAZE_H_
#define BEHAVIOUR_SOLVE_MAZE_H_
#include "bot-logic/bot-logik.h"
#ifdef BEHAVIOUR_SOLVE_MAZE_AVAILABLE
/*!
* Das Verhalten findet seinen Weg durch ein Labyrinth, das nach gewissen Grundregeln gebaut ist
* in nicht immer optimaler Weise aber in jedem Fall. Es arbeitet nach dem Hoehlenforscher-Algorithmus.
* Einschraenkung: Objekte im Labyrinth, die Endlossschleifen verursachen koennen, z.b. ein einzeln
* stehender Pfeiler im Labyrinth um den der Bot dann immer wieder herum fahren wuerde.
*/
void bot_solve_maze(Behaviour_t *caller);
/*!
* Das Verhalten findet seinen Weg durch ein Labyrinth, das nach gewissen Grundregeln gebaut ist
* in nicht immer optimaler Weise aber in jedem Fall. Es arbeitet nach dem Hoehlenforscher-Algorithmus.
* Einschraenkung: Objekte im Labyrinth, die Endlossschleifen verursachen koennen, z.b. ein einzeln
* stehender Pfeiler im Labyrinth um den der Bot dann immer wieder herum fahren wuerde.
*/
void bot_solve_maze_behaviour(Behaviour_t *data);
/*!
* Initialisiert den Hoelenforscher
* @param prio_main Prioritaet des Hoehlenforschers (typ. 100)
* @param prio_helper Prioritaet der Hilfsfunktionen (typ. 42)
* @param active ACTIVE wenn der hoehlenforcher sofort starten soll, sonst INACTIVE
*/
void bot_solve_maze_init(int8 prio_main,int8 prio_helper, int8 active);
#endif
#endif /*BEHAVIOUR_SOLVE_MAZE_H_*/

View file

@ -0,0 +1,51 @@
/*
* c't-Bot
*
* 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 (at your
* option) any later version.
* This program is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the Free
* Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307, USA.
*
*/
/*! @file behaviour_turn.h
* @brief Drehe den Bot
*
* @author Benjamin Benz (bbe@heise.de)
* @date 03.11.06
*/
#ifndef BEHAVIOUR_TURN_H_
#define BEHAVIOUR_TURN_H_
#ifdef BEHAVIOUR_TURN_AVAILABLE
#include "bot-logic/bot-logik.h"
/*!
* Das Verhalten laesst den Bot eine Punktdrehung durchfuehren.
+ * Drehen findet in drei Schritten statt. Die Drehung wird dabei
+ * bei Winkeln > 15 Grad zunaechst mit hoeherer Geschwindigkeit ausgefuehrt. Bei kleineren
+ * Winkeln oder wenn nur noch 15 Grad zu drehen sind, nur noch mit geringer Geschwindigkeit
* @param *data der Verhaltensdatensatz
* @see bot_turn()
*/
void bot_turn_behaviour(Behaviour_t *data);
/*!
* Dreht den Bot im mathematisch positiven Sinn.
* @param degrees Grad, um die der Bot gedreht wird. Negative Zahlen drehen im (mathematisch negativen) Uhrzeigersinn.
* Die Aufloesung betraegt rund 3 Grad
*/
void bot_turn(Behaviour_t* caller,int16 degrees);
#endif
#endif

View file

@ -0,0 +1,196 @@
/*
* c't-Sim - Robotersimulator fuer den c't-Bot
*
* 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 (at your
* option) any later version.
* This program is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the Free
* Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307, USA.
*
*/
/*! @file bot-logik.h
* @brief High-Level-Routinen fuer die Steuerung des c't-Bots
* @author Benjamin Benz (bbe@heise.de)
* @date 01.12.05
*/
#ifndef bot_logik_H_
#define bot_logik_H_
#include "global.h"
#include "ct-Bot.h"
#include "motor.h"
#include "sensor.h"
#include "bot-local.h"
#define BEHAVIOUR_DRIVE_AVAILABLE
// Includes aller verfuegbaren Verhalten
#define INACTIVE 0 /*!< Verhalten ist aus */
#define ACTIVE 1 /*!< Verhalten ist an */
#define OVERRIDE 1 /*!< Konstante, wenn Verhalten beim Aufruf alte Wuensche ueberschreiben sollen */
#define NOOVERRIDE 0 /*!< Konstanten, wenn Verhalten beim Aufruf alte Wuensche nicht ueberschreiben sollen */
#define SUBSUCCESS 1 /*!< Konstante fuer Behaviour_t->subResult: Aufgabe erfolgreich abgeschlossen */
#define SUBFAIL 0 /*!< Konstante fuer Behaviour_t->subResult: Aufgabe nicht abgeschlossen */
#define SUBRUNNING 2 /*!< Konstante fuer Behaviour_t->subResult: Aufgabe wird noch beabeitet */
#define BOT_BEHAVIOUR_RUNNING 1 /*!< Rueckgabewert eines Verhaltens, das noch weiter laufen moechte. */
#define BOT_BEHAVIOUR_DONE 0 /*!< Rueckgabewert eines Verhaltens, das fertig ist. */
/*! Verwaltungsstruktur fuer die Verhaltensroutinen */
typedef struct _Behaviour_t {
void (*work) (struct _Behaviour_t *data); /*!< Zeiger auf die Funktion, die das Verhalten bearbeitet */
uint8 priority; /*!< Prioritaet */
struct _Behaviour_t *caller ; /* aufrufendes verhalten */
uint8 active:1; /*!< Ist das Verhalten aktiv */
#ifdef DISPLAY_BEHAVIOUR_AVAILABLE
#ifndef DISPLAY_DYNAMIC_BEHAVIOUR_AVAILABLE /*!< bei dynamischer Anzeige und Wahl keine Puffervar notwendig */
uint8 active_new:1; /*!< Ist das via Display gewaehlte neue Sollverhalten */
#endif
#endif
uint8 subResult:2; /*!< War das aufgerufene unterverhalten erfolgreich (==1)?*/
struct _Behaviour_t *next; /*!< Naechster Eintrag in der Liste */
#ifndef DOXYGEN
}__attribute__ ((packed)) Behaviour_t;
#else
} Behaviour_t;
#endif
/*! Dieser Typ definiert eine Funktion die das eigentliche Verhalten ausfuehrt. */
typedef void (*BehaviourFunc)(Behaviour_t *data);
/*! Liste mit allen Verhalten */
extern Behaviour_t *behaviour;
extern int16 speedWishLeft; /*!< Puffervariablen fuer die Verhaltensfunktionen absolut Geschwindigkeit links*/
extern int16 speedWishRight; /*!< Puffervariablen fuer die Verhaltensfunktionen absolut Geschwindigkeit rechts*/
extern float faktorWishLeft; /*!< Puffervariablen fuer die Verhaltensfunktionen Modifikationsfaktor links*/
extern float faktorWishRight; /*!< Puffervariablen fuer die Verhaltensfunktionen Modifikationsfaktor rechts */
extern int16 target_speed_l; /*!< Sollgeschwindigkeit linker Motor */
extern int16 target_speed_r; /*!< Sollgeschwindigkeit rechter Motor */
/*!
* Kuemmert sich intern um die Ausfuehrung der goto-Kommandos
* @see bot_goto()
*/
extern void bot_behave(void);
/*!
* Initilaisert das ganze Verhalten
*/
extern void bot_behave_init(void);
/*!
* Aktiviert eine Regel mit gegebener Funktion
* @param function Die Funktion, die das Verhalten realisiert.
*/
void activateBehaviour(BehaviourFunc function);
/*!
* Aktiviert eine Regel mit gegebener Funktion
* @param function Die Funktion, die das Verhalten realisiert.
*/
void deactivateBehaviour(BehaviourFunc function);
/*!
* Deaktiviert alle Verhalten bis auf Grundverhalten. Bei Verhaltensauswahl werden die Aktivitaeten vorher
* in die Verhaltens-Auswahlvariable gesichert.
*/
void deactivateAllBehaviours(void);
/*!
* Ruft ein anderes Verhalten auf und merkt sich den Ruecksprung
* return_from_behaviour() kehrt dann spaeter wieder zum aufrufenden Verhalten zurueck
* @param from aufrufendes Verhalten
* @param to aufgerufenes Verhalten
* @param override Hier sind zwei Werte Moeglich:
* 1. OVERRIDE : Das Zielverhalten to wird aktiviert, auch wenn es noch aktiv ist.
* Das Verhalten, das es zuletzt aufgerufen hat wird dadurch automatisch
* wieder aktiv und muss selbst sein eigenes Feld subResult auswerten, um zu pruefen, ob das
* gewuenschte Ziel erreicht wurde, oder vorher ein Abbruch stattgefunden hat.
* 2. NOOVERRIDE : Das Zielverhalten wird nur aktiviert, wenn es gerade nichts zu tun hat.
* In diesem Fall kann der Aufrufer aus seinem eigenen subResult auslesen,
* ob seibem Wunsch Folge geleistet wurde.
*/
void switch_to_behaviour(Behaviour_t * from, void *to, uint8 override );
/*!
* Kehrt zum aufrufenden Verhalten zurueck
* @param running laufendes Verhalten
*/
void return_from_behaviour(Behaviour_t * data);
/*!
* Fuegt ein Verhalten der Verhaltenliste anhand der Prioritaet ein.
* @param list Die Speicherstelle an der die globale Verhaltensliste anfaengt
* @param behave Einzufuegendes Verhalten
*/
void insert_behaviour_to_list(Behaviour_t **list, Behaviour_t *behave);
/*!
* Erzeugt ein neues Verhalten
* @param priority Die Prioritaet
* @param *work Den Namen der Funktion, die sich drum kuemmert
*/
Behaviour_t *new_behaviour(uint8 priority, void (*work) (struct _Behaviour_t *data), int8 active);
#include "bot-logic/available_behaviours.h"
#ifdef DISPLAY_BEHAVIOUR_AVAILABLE
/*!
* ermittelt ob noch eine weitere Verhaltensseite existiert
*/
extern int8 another_behaviour_page(void) ;
/*!
* toggled ein Verhalten der Verhaltensliste an Position pos
* @param pos Listenposition, entspricht der Taste 1-6 der gewaehlten Verhaltensseite
*/
void toggleNewBehaviourPos(int8 pos);
/*!
* Startschuss, die gewaehlten neuen Verhaltensaktivitaeten werden in die
* Verhaltensliste geschrieben und die Verhalten damit scharf geschaltet
*/
void set_behaviours_active_to_new(void);
/*!
* Die Aktivitaeten der Verhalten werden in die Puffervariable geschrieben,
* welche zur Anzeige und Auswahl verwendet wird
*/
void set_behaviours_equal(void);
int8 behaviour_page ; /*!< angezeigte Verhaltensseite */
#endif
#endif

View file

@ -0,0 +1,89 @@
/*
* c't-Bot
*
* 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 (at your
* option) any later version.
* This program is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the Free
* Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307, USA.
*
*/
/*! @file remote_calls.h
* @brief Liste mit Botenfkts, die man aus der Ferne aufrufen kann
*
* @author Benjamin Benz (bbe@heise.de)
* @date 19.12.06
*/
#ifndef REMOTE_CALLS_H_
#define REMOTE_CALLS_H_
#include "bot-logik.h"
#define REMOTE_CALL_FUNCTION_NAME_LEN 20
#define PARAM_TEXT_LEN 40
#define REMOTE_CALL_MAX_PARAM 3
#define REMOTE_CALL_BUFFER_SIZE (REMOTE_CALL_FUNCTION_NAME_LEN+1+REMOTE_CALL_MAX_PARAM*4)
// Die Kommandostruktur
typedef struct {
void* (*func)(void *); /*!< Zeiger auf die auszufuehrende Funktion*/
uint8 param_count; /*!< Anzahl der Parameter kommen Und zwar ohne den obligatorischen caller-parameter*/
uint8 param_len[REMOTE_CALL_MAX_PARAM]; /*!< Angaben ueber die Anzahl an Bytes, die jeder einzelne Parameter belegt */
char name[REMOTE_CALL_FUNCTION_NAME_LEN+1]; /*!< Text, maximal TEXT_LEN Zeichen lang + 1 Zeichen terminierung*/
char param_info[PARAM_TEXT_LEN+1]; /*!< String, der Angibt, welche und was fuer Parameter die Fkt erwartet */
} call_t;
typedef union{
uint32 u32;
float fl32;
} remote_call_data_t; /*!< uint32 und float werden beide gleich ausgelesen, daher stecken wir sie in einen Speicherbereich */
/*! Dieses Makro bereitet eine Botenfunktion als Remote-Call-Funktion vor.
* Der erste parameter ist der Funktionsname selbst
* Der zweite Parameter ist die Anzahl an Bytes, die die Fkt erwartet.
* Und zwar unabhaengig vom Datentyp. will man also einen uin16 uebergeben steht da 2
* Will man einen Float uebergeben eine 4. Fuer zwei Floats eine 8, usw.
*/
#define PREPARE_REMOTE_CALL(func,count,param,param_len...) {(void*)func, count, {param_len}, #func,param }
/*!
* Dieses Verhalten kuemmert sich darum die Verhalten, die von außen angefragt wurden zu starten und liefert ein feedback zurueck, wenn sie beendet sind.
* @param *data der Verhaltensdatensatz
*/
void bot_remotecall_behaviour(Behaviour_t *data);
/*!
* Fuehre einen remote_call aus. Es gibt KEIN aufrufendes Verhalten!!
* @param func Zeiger auf den Namen der Fkt
* @param data Zeiger auf die Daten
*/
void bot_remotecall(char* func, remote_call_data_t* data);
/*!
* Fuehre einen remote_call aus. Es gibt KEIN aufrufendes Verhalten!!
* @param data Zeiger die Payload eines Kommandos. Dort muss zuerst ein String mit dem Fkt-Namen stehen. ihm folgen die Nutzdaten
*/
void bot_remotecall_from_command(uint8 * data);
/*! Listet alle verfuegbaren Remote-Calls auf und verschickt sie als einzelne Kommanods
*/
void remote_call_list(void);
#endif /*REMOTE_CALLS_H_*/