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,120 @@
/*
* 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 TWI_driver.h
* @brief TWI Treiber
* @author Chris efstathiou hendrix@otenet.gr & Carsten Giesen (info@cnau.de)
* @date 11.04.2006
*/
#include <avr/io.h>
#include "global.h"
#ifndef TWI_driver_H
#define TWI_driver_H 1
/*!
Struktur Definition
tx_type ist eine Datenstruktur um den TWI Treiber anzusprechen
und behinhaltet folgende Informationen:
Slave Adresse + Datenrichtung
Anzahl der zu uebertragendenden Bytes (Senden oder Empfangen)
Pointer auf den Sende- oder Empfangspuffer
*/
typedef struct
{
uint8 slave_adr; /*!< Slave Adresse and W/R byte */
uint8 size; /*!< Anzahl der Bytes, die gesendet oder empfagen werden sollen */
uint8 *data_ptr; /*!< Pointer zum Sende und Empfangs Puffer */
}tx_type;
/*!
* Hier wird der eigentliche TWI-Treiber angesprochen
* @param *data_pack Container mit den Daten fuer den Treiber
* @return Resultat der Aktion
*/
extern uint8 Send_to_TWI(tx_type *data_pack);
/*!
* Sende ein Byte
* @param data das zu uebertragende Byte
*/
extern uint8 Send_byte(uint8 data);
/*!
* Empfange ein Byte
* @param *rx_ptr Container f<EFBFBD>r die Daten
* @param last_byte Flag ob noch Daten erwartet werden
* @return Resultat der Aktion
*/
extern uint8 Get_byte(uint8 *rx_ptr, uint8 last_byte);
/*!
* Sende Start Sequence
* @return Resultat der Aktion
*/
extern uint8 Send_start(void);
/*!
* Sende Slave Adresse
* @param adr die gewuenschte Adresse
* @return Resultat der Aktion
*/
extern uint8 Send_adr(uint8 adr);
/*!
* Sende Stop Sequence
*/
extern void Send_stop(void);
/*!
* Warte auf TWI interrupt
*/
extern void Wait_TWI_int(void);
/*!
* TWI Bus initialsieren
* @return Resultat der Aktion
*/
extern int8 Init_TWI(void);
/*!
* TWI Bus schliesen
* @return Resultat der Aktion
*/
extern int8 Close_TWI(void);
#define W 0 /*!< Daten Transfer Richtung Schreiben */
#define R 1 /*!< Daten Transfer Richtung Lesen */
#define OWN_ADR 60 /*!< Die eigene Slave Adresse */
#define SUCCESS 0xFF /*!< Status Code alles OK */
/*!
TWI Stautus Register Definitionen
*/
/*!< Genereller Master Statuscode */
#define START 0x08 /*!< START wurde uebertragen */
#define REP_START 0x10 /*!< Wiederholter START wurde uebertragen */
/*!< Master Sender Statuscode */
#define MTX_ADR_ACK 0x18 /*!< SLA+W wurde uebertragen und ACK empfangen */
#define MTX_ADR_NACK 0x20 /*!< SLA+W wurde uebertragen und NACK empfangen */
#define MTX_DATA_ACK 0x28 /*!< Datenbyte wurde uebertragen und ACK empfangen */
#define MTX_DATA_NACK 0x30 /*!< Datenbyte wurde uebertragen und NACK empfangen */
#define MTX_ARB_LOST 0x38 /*!< Schlichtung verloren in SLA+W oder Datenbytes */
/*!< Master Empfaenger Statuscode */
#define MRX_ARB_LOST 0x38 /*!< Schlichtung verloren in SLA+R oder NACK bit */
#define MRX_ADR_ACK 0x40 /*!< SLA+R wurde uebertragen und ACK empfangen */
#define MRX_ADR_NACK 0x48 /*!< SLA+R wurde uebertragen und NACK empfangen */
#define MRX_DATA_ACK 0x50 /*!< Datenbyte wurde empfangen und ACK gesendet */
#define MRX_DATA_NACK 0x58 /*!< Datenbyte wurde empfangen und NACK gesendet */
#endif

View file

@ -0,0 +1,55 @@
/*
* 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 adc.h
* @brief Routinen zum Einlesen der Analogeingaenge
* @author Benjamin Benz (bbe@heise.de)
* @date 26.12.05
*/
#ifndef ADC_H_
#define ADC_H_
#include "global.h"
/*!
* Liest einen analogen Kanal aus
* @param channel Kanal - hex-Wertigkeit des Pins (0x01 fuer PA0; 0x02 fuer PA1, ..)
*/
uint16 adc_read(uint8 channel);
/*!
* Wechselt einen ADU-kanal. Dafuer muessen auch die Puffer zurueckgesetzt werden
* @param channel Kanal - hex-Wertigkeit des Pins (0x01 fuer PA0; 0x02 fuer PA1, ..)
*/
void adc_select_channel(uint8 channel);
/*!
* Diese Routine wird vom Timer-Interrupt aufgerufen und speichert einen
* Messwert (vorher wendet sie evtl. noch eine Filterfunktion an).
*/
void adc_isr(void);
/*!
* Initialisert den AD-Umsetzer.
* @param channel fuer jeden Kanal, den man nutzen moechte,
* muss das entsprechende Bit in channel gesetzt sein.
* Bit0 = Kanal 0 usw.
*/
void adc_init(uint8 channel);
#endif

View file

@ -0,0 +1,47 @@
/*
* 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-2-pc.h
* @brief Verbindung c't-Bot zum PC
* @author Benjamin Benz (bbe@heise.de)
* @date 01.03.06
*/
#ifndef __bot_2_pc
#define __bot_2_pc
#include "global.h"
/*!
* Diese Funktion nimmt die Daten vom PC entgegen
* und wertet sie aus. dazu nutzt er die Funktion command_evaluate()
*/
void bot_2_pc_listen(void);
/*!
* Diese Funktion informiert den PC ueber alle Sensor und Aktuator-Werte
*/
void bot_2_pc_inform(void);
/*!
* Meldet den Bot am c't-Sim an
*/
void bot_2_pc_init(void);
#endif

View file

@ -0,0 +1,71 @@
/*
* 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-2-sim.h
* @brief Verbindung c't-Bot zu c't-Sim
* @author Benjamin Benz (bbe@heise.de)
* @date 26.12.05
*/
#ifndef __bot_2_sim
#define __bot_2_sim
#include "ct-Bot.h"
#include "global.h"
/*!
* Ein wenig Initilisierung kann nicht schaden
*/
void bot_2_sim_init(void);
/*!
* Frage Simulator nach Daten
*/
int bot_2_sim_ask(uint8 command, uint8 subcommand,int16* data_l,int16* data_r);
/*!
* Schickt einen Thread in die Warteposition
* @param timeout_us Wartezeit in Mikrosekunden
*/
void wait_for_time(long timeout_us);
/*!
* Wartet auf die Antwort des PC
* Achtung blockierend ohne Timeout
* @param command Das kommando auf das gewartet wird.
* @return 0, wenn Ok
*/
int wait_for_special_command(uint8 command);
/*!
* Schleife, die Kommandis empfaengt und bearbeitet, bis ein Kommando vom Typ Frame kommt
* @param frame Kommando zum abbruch
*/
int8 receive_until_Frame(int8 frame);
#ifdef WIN32
#include <sys/time.h>
/*!
* Hilfsfunktion, die es nur auf dem PC gibt
*/
void gettimeofday_win(struct timeval* p, void* tz /* IGNORED */);
#define GETTIMEOFDAY gettimeofday_win
#else
#define GETTIMEOFDAY gettimeofday
#endif // WIN32
#endif

View file

@ -0,0 +1,111 @@
/*
* 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-local.h
* @brief Konstanten, die den Bot an reale Umgebungen anpassen
* @author Benjamin Benz (bbe@heise.de)
* @author Christoph Grimmer (c.grimmer@futurio.de)
* @date 28.02.06
*/
#ifndef BOTLOCAL_H_
#define BOTLOCAL_H_
#include "ct-Bot.h"
#define ENCODER_MARKS 60 /*!< Anzahl der Flanken, die ein Encoder bei einer Radumdrehung liefert, also Anzahl der weissen + Anzahl der schwarzen Felder */
#define WHEEL_DIAMETER 57 /*!< Durchmesser eines Rades in mm */
#define WHEEL_PERIMETER 179 /*!< Umfang eines Rades in mm */
#define WHEEL_TO_WHEEL_DIAMETER 97 /*!< Abstand der beiden Raeder in mm */
#define DISTSENSOR_POS_FW 35 /*!< Abstand der Distanzsensoren von der Radachse (in fahrtrichtung)*/
#define DISTSENSOR_POS_SW 32 /*!< Abstand der Distanzsensoren von der Mittelachse (in querrichtung)*/
#define SPEED_CONTROL_INTERVAL 333 /*!> Intervall fuer die Motorregelung [ms]*/
//#define SPEED_TO_ENCODER_RATE (WHEEL_PERIMETER /ENCODER_MARKS*(1000/SPEED_CONTROL_INTERVAL)) /*!< Faktor durch den man eine Speed [mm/s] teilt um Ticks/intervall zu erhalten */
#define SPEED_TO_ENCODER_RATE 9 /*!< Faktor durch den man eine Speed [mm/s] teilt um Ticks/intervall zu erhalten */
/* Odometrie-Konstanten */
//#define MOUSE_CPI 401 /*!< CPI-Wert aus Kalibrierung */
//#define MOUSE_FULL_TURN 1430 /*!< Mausaenderung in X-Richtung fuer einen vollen Kreis */
#define MOUSE_CPI 400 /*!< CPI-Wert aus Kalibrierung (Wert fuer den Sim) */
#define MOUSE_FULL_TURN 1484 /*!< Mausaenderung in X-Richtung fuer einen vollen Kreis (Wert fuer den Sim) */
#define WHEEL_DISTANCE 49 /*!< Abstand eines Rades zur Mitte des Bots */
#define STUCK_DIFF 100 /*!< ab welcher Differenz haben wir durchdrehende Raeder? */
#define G_SPEED 0.5 /*!< Kopplung Encoder- und Maussensor fuer Geschwindigkeiten (0.0=nur Radencoder, 1.0=nur Maussensor) */
#define G_POS 0.5 /*!< Kopplung Encoder- und Maussensor fuer Positionen und Winkel (0.0=nur Radencoder, 1.0=nur Maussensor) */
/*! Hilfskonstante */
#define ANGLE_CONSTANT (WHEEL_TO_WHEEL_DIAMETER * ENCODER_MARKS / WHEEL_DIAMETER)
/* Motorregelung */
#define PID_LOW_RATE (BOT_SPEED_MEDIUM / SPEED_TO_ENCODER_RATE) /*!< Encoder-rate/aufruf, fuer den dieser PID-Satz gilt */
#define PID_LOW_Kp 8 /*!< Regelung PID-Parameter [Zehntel Schritte] */
#define PID_LOW_Ki 6 /*!< Regelung PID-Parameter [Zehntel Schritte] */
#define PID_LOW_Kd 0 /*!< Regelung PID-Parameter */
#define PID_HIGH_RATE (BOT_SPEED_NORMAL / SPEED_TO_ENCODER_RATE) /*!< Encoder-rate/aufruf, fuer den dieser PID-Satz gilt */
#define PID_HIGH_Kp 70 /*!< Regelung PID-Parameter [Zehntel Schritte] */
#define PID_HIGH_Ki 40 /*!< Regelung PID-Parameter [Zehntel Schritte] */
#define PID_HIGH_Kd 0 /*!< Regelung PID-Parameter */
/* Einstellunge fuer die Verhaltensregeln */
#define BORDER_DANGEROUS 0x3A0 /*!< Wert, ab dem wir sicher sind, dass es eine Kante ist */
#define GLANCE_FACTOR 0.9 /*!< Schlangenlinienfaktor zur Erweiterung des Sensorfeldes */
#define GLANCE_STRAIGHT 20 /*!< Anzahl der Zyklen, die nicht geschielt wird Gesamtzahl der Zyklen ist GLANCE_STRAIGHT + GLANCE_SIDE*4 */
#define GLANCE_SIDE 5 /*!< Anzahl der Zyklen, die geschielt wird (jeweils pro Seite) Gesamtzahl der Zyklen ist GLANCE_STRAIGHT + GLANCE_SIDE*4 */
#define COL_CLOSEST 200 /*!< Abstand in mm, den wir als zu nah betrachten -- je nach echtem Sensor ist das schon zu nah! */
#define COL_NEAR 300 /*!< Nahbereich */
#define COL_FAR 400 /*!< Fernbereich */
#define SWEEP_STATE_TURN 0 /*!< Zustand: Drehung im Sweep. */
#define SWEEP_STATE_CHECK 1 /*!< Zustamd: Ueberpruefe Objekt vor dem Bot. */
/* Zustaende und Konstanten fuer das bot_solve_maze_behaviour-Verhalten */
#define BOT_DIAMETER 12
#define OPTIMAL_DISTANCE BOT_DIAMETER*12 /* etwas mehr als Bot-Durchmesser ist ideal (vergroessert aufgrund der kennlinien der sharps) */
#define ADJUST_DISTANCE 10
#define IGNORE_DISTANCE 240
#define GROUND_GOAL 0x221
#define STARTPAD1 0x2B2
#define STARTPAD2 0x332
/* Konstanten fuer das bot_follow_line_behaviour-Verhalten */
#define LINE_SENSE 0x350 // Ab wann ist es Linie? (Fuer den Sim auf 350 setzen, helle Tischflaeche 50)
/* Konstanten fuer Verhaltensanzeige, Verhalten mit prio von bis sichtbar */
#define PRIO_VISIBLE_MIN 3
#define PRIO_VISIBLE_MAX 200
#endif /*BOTLOCAL_H_*/

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_*/

View file

@ -0,0 +1,195 @@
/*
* 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 command.h
* @brief Kommando-Management
* @author Benjamin Benz (bbe@heise.de)
* @date 20.12.05
*/
#ifndef __command_h_
#define __command_h_
#include "global.h"
#include "ct-Bot.h"
#define MAX_PAYLOAD 255 /*!< Max. Anzahl Bytes, die an ein Command angehaengt werden */
#ifdef PC
#define low_read tcp_read /*!< Which function to use to read data */
#define low_write tcp_send_cmd /*!< Which function to use to write data */
#define low_write_data tcp_write /*!< Which function to use to write data */
#endif
#ifdef MCU
#define low_read uart_read /*!< Which function to use to read data */
#define low_write uart_send_cmd /*!< Which function to use to write data */
// #define low_write uart_send_cmd /*!< Which function to use to write data */
#define low_write_data uart_write /*!< Which function to use to write data */
#endif
/*!
* Request Teil eines Kommandos
*/
typedef struct {
uint8 command:8; /*!< command */
uint8 subcommand:7; /*!< subcommand */
uint8 direction:1; /*!< 0 ist Anfrage, 1 ist Antwort */
#ifndef DOXYGEN
} __attribute__ ((packed)) request_t; // Keine Luecken in der Struktur lassen
#else
} request_t; // Keine Luecken in der Struktur lassen
#endif
/*!
* Kommando
*/
typedef struct {
uint8 startCode; /*!< Markiert den Beginn eines Commands */
request_t request; /*!< Command-ID */
uint8 payload; /*!< Bytes, die dem Kommando noch folgen*/
int16 data_l; /*!< Daten zum Kommando links*/
int16 data_r; /*!< Daten zum Kommando rechts*/
int16 seq; /*!< Paket-Sequenznummer*/
uint8 CRC; /*!< Markiert das Ende des Commands*/
#ifndef DOXYGEN
} __attribute__ ((packed)) command_t;// Keine Luecken in der Struktur lassen
#else
} command_t;
#endif
#define CMD_STARTCODE '>' /*!< Anfang eines Kommandos*/
#define CMD_STOPCODE '<' /*!< Ende eines Kommandos*/
//Sensoren
#define CMD_SENS_IR 'I' /*!< Abstandssensoren*/
#define CMD_SENS_ENC 'E' /*!< Radencoder*/
#define CMD_SENS_BORDER 'B' /*!< Abgrundsensoren*/
#define CMD_SENS_LINE 'L' /*!< Liniensensoren*/
#define CMD_SENS_LDR 'H' /*!< Helligkeitssensoren */
#define CMD_SENS_TRANS 'T' /*!< Ueberwachung Transportfach */
#define CMD_SENS_DOOR 'D' /*!< Ueberwachung Klappe */
#define CMD_SENS_MOUSE 'm' /*!< Maussensor */
#define CMD_SENS_ERROR 'e' /*!< Motor- oder Batteriefehler */
#define CMD_SENS_RC5 'R' /*!< IR-Fernbedienung */
#define CMD_SENS_MOUSE_PICTURE 'P' /*!< Bild vom Maussensor in data_l steht, welche Nummer da 1. Pixel hat*/
// Aktuatoren
#define CMD_AKT_MOT 'M' /*!< Motorgeschwindigkeit */
#define CMD_AKT_DOOR 'd' /*!< Steuerung Klappe */
#define CMD_AKT_SERVO 'S' /*!< Steuerung Servo */
#define CMD_AKT_LED 'l' /*!< LEDs steuern */
#define CMD_AKT_LCD 'c' /*!< LCD Anzeige */
#define CMD_DONE 'X' /*!< Markiert das Ende einer Uebertragung */
#define SUB_CMD_NORM 'N' /*!< Standard-Kommando */
#define SUB_CMD_LEFT 'L' /*!< Kommmando fuer links */
#define SUB_CMD_RIGHT 'R' /*!< Kommando fuer rechts */
// Subcommandos fuer LCD
#define SUB_LCD_CLEAR 'c' /*!< Subkommando Clear Screen */
#define SUB_LCD_DATA 'D' /*!< Subkommando Text ohne Cursor */
#define SUB_LCD_CURSOR 'C' /*!< Subkommando Cursorkoordinaten */
// Log-Ausgaben
#define CMD_LOG 'O' /*!< Logausgaben */
//Kommandos fuer die Verbindung zum c't-Sim
#define CMD_WELCOME 'W' /*!< Kommado zum anmelden an c't-Sim */
#define SUB_WELCOME_REAL 'R' /*!< Subkommado zum anmelden eine realen Bots an c't-Sim */
#define SUB_WELCOME_SIM 'S' /*!< Subkommado zum anmelden eines simulierten Bots an c't-Sim */
//Kommandos fuer die Remote-Calls
#define CMD_REMOTE_CALL 'r' /*!< Kommado fuer Remote-Calls */
#define SUB_REMOTE_CALL_LIST 'L' /*!< Anforderung an den Bot alle verfuegbaren Kommandos zu listen */
#define SUB_REMOTE_CALL_ENTRY 'E' /*!< Hiermit leifert der Bot ein erfuegbares Kommandos an den PC */
#define SUB_REMOTE_CALL_ORDER 'O' /*!< Hiermit gibt der PC einen Remote-call in Auftrag */
#define SUB_REMOTE_CALL_DONE 'D' /*!< Hiermit signalisiert der MCU dem PC die beendigung des Auftrags. Ergebins steht in DataL 0=FAIL 1=SUCCESS */
#define DIR_REQUEST 0 /*!< Richtung fuer Anfragen */
#define DIR_ANSWER 1 /*!< Richtung fuer Antworten */
#ifdef PC // Auf dem PC muss der Zugriff auf received_command Thread-sicher sein
#include <pthread.h>
extern pthread_mutex_t command_mutex; /*!< Zugriff auf das Kommando */
#define command_lock() pthread_mutex_lock(&command_mutex) /*!< Zugriff auf das Kommando */
#define command_unlock() pthread_mutex_unlock(&command_mutex) /*!< Zugriff auf das Kommando */
#endif
extern command_t received_command; /*!< Puffer fuer Kommandos */
/*!
* Liest ein Kommando ein, ist blockierend!
* greift auf low_read() zurueck
* @see low_read()
*/
int8 command_read(void);
/*!
* Uebertraegt ein Kommando und wartet nicht auf eine Antwort
* @param command Kennung zum Command
* @param subcommand Kennung des Subcommand
* @param data_l Daten fuer den linken Kanal
* @param data_r Daten fuer den rechten Kanal
* @param payload Anzahl der Bytes, die diesem Kommando als Payload folgen
*/
void command_write(uint8 command, uint8 subcommand, int16* data_l,int16* data_r,uint8 payload);
/*!
* Gibt dem Simulator Daten mit Anhang und wartet nicht auf Antwort
* @param command Kennung zum Command
* @param subcommand Kennung des Subcommand
* @param data_l Daten fuer den linken Kanal
* @param data_r Daten fuer den rechten Kanal
* @param data Datenanhang an das eigentliche Command
*/
void command_write_data(uint8 command, uint8 subcommand, int16* data_l, int16* data_r, const char* data);
/*!
* Gibt dem Simulator Daten mit Anhang und wartet nicht auf Antwort
* @param command Kennung zum Command
* @param subcommand Kennung des Subcommand
* @param data_l Daten fuer den linken Kanal
* @param data_r Daten fuer den rechten Kanal
* @param payload Anzahl der Bytes im Anhang
* @param data Datenanhang an das eigentliche Command
*/
void command_write_rawdata(uint8 command, uint8 subcommand, int16* data_l, int16* data_r, uint8 payload, uint8* data);
/*!
* Wertet das Kommando im Puffer aus
* return 1, wenn Kommando schon bearbeitet wurde, 0 sonst
*/
int command_evaluate(void);
/*!
* Gibt ein Kommando auf dem Bildschirm aus
*/
void command_display(command_t * command);
#endif

View file

@ -0,0 +1,41 @@
/*
* 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 delay.h
* @brief Hilfsroutinen
* @author Benjamin Benz (bbe@heise.de)
* @date 20.12.05
*/
#ifndef delay_H_
#define delay_H_
/*!
* Warte 100 ms
*/
void delay_100ms(void);
/*!
* Verzoegert um ms Millisekunden
* Wenn RTC_AVAILABLE, dann ueber rtc, sonst ueber delay_100ms
* ==> Aufloesung ohne rtc: 100-ms-schritte; mit rtc: 5-ms-Schritte
* @param ms Anzahl der Millisekunden
*/
void delay(int ms);
#endif

View file

@ -0,0 +1,69 @@
/*
* 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 display.h
* @brief Routinen zur Displaysteuerung
* @author Benjamin Benz (bbe@heise.de)
* @date 20.12.05
*/
#ifndef display_H_
#define display_H_
#define DISPLAY_LENGTH 20 /*!< Wieviele Zeichen passen in eine Zeile */
extern uint8 display_update; /*!< Muss das Display aktualisiert werden? */
#ifdef DISPLAY_SCREENS_AVAILABLE
#define DISPLAY_SCREENS 5 /*!< Anzahl der Screens */
#define DISPLAY_SCREEN_TOGGLE 42 /*!< Screen-Nummer, die zum wechseln verwendet wird */
extern uint8 display_screen; /*!< Welcher Screen soll gezeigt werden? */
#endif
/*!
* Init Display
*/
void display_init(void);
/*!
* Zeigt einen String an
* @return -1 falls String zu Ende, 0 falls Zeile (20 zeichen) zu Ende
*/
//int display_string(char data[20]);
/*!
* Loescht das ganze Display
*/
void display_clear(void);
/*!
* Positioniert den Cursor
* @param row Zeile
* @param column Spalte
*/
void display_cursor (uint8 row, uint8 column) ;
/*!
* Schreibt einen String auf das Display.
* @param format Format, wie beim printf
* @param ... Variable Argumentenliste, wie beim printf
*/
void display_printf(char *format, ...);
//void display_test();
#endif

View file

@ -0,0 +1,68 @@
/*
* 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 ena.h
* @brief Routinen zur Steuerung der Enable-Leitungen
* @author Benjamin Benz (bbe@heise.de)
* @date 26.12.05
*/
#ifndef ENA_H_
#define ENA_H_
#ifndef MMC_LOW_H_
#include "global.h"
#endif
#define ENA_ABSTAND (1<<0) /*!< Enable-Leitung Abstandssensoren */
#define ENA_RADLED (1<<1) /*!< Enable-Leitung Radencoder */
#define ENA_SCHRANKE (1<<2) /*!< Enable-Leitung Fachueberwachung */
#define ENA_KANTLED (1<<3) /*!< Enable-Leitung Angrundsensor */
#define ENA_KLAPPLED (1<<4) /*!< Enable-Leitung Schieberueberwachung */
#define ENA_MAUS (1<<5) /*!< Enable-Leitung Liniensensor auf Mausplatine */
#define ENA_MMC (1<<6) /*!< Enable-Leitung Reserve 1 */
#define ENA_MOUSE_SENSOR (1<<7) /*!< Enable-Leitung Reserve 2 */
#ifndef MMC_LOW_H_
/*!
* Initialisiert die Enable-Leitungen
*/
void ENA_init(void);
/*!
* Schaltet einzelne Enable-Leitungen an,
* andere werden nicht beeinflusst
* @param enable Bitmaske der anzuschaltenden LEDs
*/
void ENA_on(uint8 enable);
/*!
* Schaltet einzelne Enable-Leitungen aus,
* andere werden nicht beeinflusst
* @param enable Bitmaske der anzuschaltenden LEDs
*/
void ENA_off(uint8 enable);
/*!
* Schaltet die Enable-Leitungen
* @param enable Wert der eingestellt werden soll
*/
void ENA_set(uint8 enable);
#endif
#endif

View file

@ -0,0 +1,67 @@
/*
* 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 global.h
* @brief Allgemeine Definitionen
* @author Benjamin Benz (bbe@heise.de)
* @date 20.12.05
*/
#ifndef global_H
#define global_H /*!< Bereits definiert */
#ifndef MCU
#ifndef PC
#define PC /*!< Zielplattform PC */
#endif
#endif
#ifndef WIN32
typedef unsigned char byte; /*!< vorzeichenlose 8-Bit-Zahl */
typedef byte bool; /*!< True/False-Aussage */
#endif
//#define DOXYGEN /*!< Nur zum Generieren von Doku!!!! */
#ifdef DOXYGEN /*!< Nur zum Generieren von Doku!!!! */
#define PC /*!< Zielplattform PC */
#define MCU /*!< Zielplattform MCU */
#define WIN32 /*!< System Windows */
#define __linux__ /*!< System Linux */
#endif
typedef unsigned char uint8; /*!< vorzeichenlose 8-Bit-Zahl */
typedef unsigned int word; /*!< vorzeichenlose 16-Bit-Zahl */
typedef signed char int8; /*!< vorzeichenbehaftete 8-Bit-Zahl */
typedef short int int16; /*!< vorzeichenbehaftete 16-Bit-Zahl */
typedef unsigned long uint32; /*!< vorzeichenlose 32-Bit-Zahl */
typedef signed long int32; /*!< vorzeichenbehaftete 32-Bit-Zahl */
#define uint16 word /*!< Int mit 16 Bit */
#define True 1 /*!< Wahr */
#define False 0 /*!< Falsch */
#define On 1 /*!< An */
#define Off 0 /*!< Aus */
// #define PI 3.14159 /*!< Kreiszahl Pi fuer trigonometrische Berechnungen */
#define binary(var,bit) ((var >> bit)&1)
//#define NULL 0
#endif

View file

@ -0,0 +1,51 @@
/*
* 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 ir-rc5.h
* @brief Routinen fuer die Dekodierung von RC5-Fernbedienungs-Codes
* @author Benjamin Benz (bbe@heise.de)
* @date 20.12.05
*/
#ifndef ir_rc5_H_
#define ir_rc5_H_
#include "ct-Bot.h"
#include "global.h"
extern volatile uint16 ir_data; /*!< letztes komplett gelesenes RC5-Paket */
/*!
* Init IR-System
*/
void ir_init (void);
/*!
* IR-Daten lesen
* @return Wert von ir_data, loescht anschliessend ir_data
*/
uint16 ir_read (void);
/*!
* Interrupt Serviceroutine,
* wird ca. alle 177.8 <EFBFBD>s aufgerufen
*/
void ir_isr (void);
#endif

View file

@ -0,0 +1,86 @@
/*
* 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 led.h
* @brief Routinen zur LED-Steuerung
* @author Benjamin Benz (bbe@heise.de)
* @date 26.12.05
*/
#ifndef led_H_
#define led_H_
#include "ct-Bot.h"
#define LED_RECHTS (1<<0) /*!< LED in Fahrichtung rechts*/
#define LED_LINKS (1<<1) /*!< LED in Fahrichtung links*/
#define LED_ROT (1<<2) /*!< LED Rot */
#define LED_ORANGE (1<<3) /*!< LED Orange */
#define LED_GELB (1<<4) /*!< LED Gelb */
#define LED_GRUEN (1<<5) /*!< LED Gruen */
#define LED_TUERKIS (1<<6) /*!< LED Tuerkis */
#define LED_WEISS (1<<7) /*!< LED Weiss */
#define LED_ALL 0xFF /*!< LED Alle */
/*! Datenfeld fuer den Zugriff auf die LEDs */
typedef struct {
uint8 rechts:1; /*!< LED in Fahrichtung rechts*/
uint8 links:1; /*!< LED in Fahrichtung links*/
uint8 rot:1; /*!< LED Rot */
uint8 orange:1; /*!< LED Orange */
uint8 gelb:1; /*!< LED Gelb */
uint8 gruen:1; /*!< LED Gruen */
uint8 tuerkis:1; /*!< LED Tuerkis */
uint8 weiss:1; /*!< LED Weiss */
#ifndef DOXYGEN
} __attribute__ ((packed)) led_t;
#else
} led_t;
#endif
extern uint8 led;
/*!
* Initialisiert die LEDs
*/
void LED_init(void);
/*!
* Zeigt eine 8-Bit Variable mit den LEDs an
* @param LED Wert der gezeigt werden soll
*/
void LED_set(uint8 LED);
/*! Schaltet eine LED aus
*
* @param LED HEX-Code der LED
*/
void LED_off(uint8 LED);
/*! Schaltet eine LED an
*
* @param LED HEX-Code der LED
*/
void LED_on(uint8 LED);
#endif

172
source/ct-Bot/include/log.h Normal file
View file

@ -0,0 +1,172 @@
/*
* 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 log.c
* @brief Routinen zum Loggen von Informationen. Es sollten ausschliesslich nur
* die Log-Makros: LOG_DEBUG(), LOG_INFO(), LOG_WARN(), LOG_ERROR() und LOG_FATAL()
* verwendet werden.
* Eine Ausgabe kann wie folgt erzeugt werden:
* LOG_DEBUG(("Hallo Welt!"));
* LOG_INFO(("Wert x=%d", x));
* Wichtig ist die doppelte Klammerung. Bei den Ausgaben kann auf ein Line Feed
* '\n' am Ende des Strings verzichtet werden, da dies automatisch angeh<EFBFBD>ngt
* hinzugefuegt wird.
*
* <pre>
* Die Logausgaben werden generell mit der Definition von LOG_AVAILABLE eingeschaltet
* und sind ansonsten nicht aktiv.
*
* Loggings auf dem PC:
* --------------------
* Hier stehen drei Arten der Ausgabeschnittstellen zur Verfuegung.
* 1. Logging ueber ct-Sim: LOG_CTSIM_AVAILABLE muss definiert sein.
* 2. Logging ueber Display: LOG_DISPLAY_AVAILABLE muss definiert sein, sowie
* DISPLAY_AVAILABLE und DISPLAY_SCREENS_AVAILABLE.
* Logging erfolgt auf Screen 5.
* 3. Logging ueber Konsole: Es muss LOG_STDOUT_AVAILABLE definiert sein.
*
* LOG_UART_AVAILABLE steht auf dem PC nicht zur Verfuegung.
*
* Loggings auf dem MCU:
* ---------------------
* Hier stehen drei Arten der Ausgabeschnittstellen zur Verfuegung.
* 1. Logging ueber UART: LOG_UART_AVAILABLE muss definiert sein.
* Es darf BOT_2_PC_AVAILABLE nicht definiert sein, da ansonsten
* diese Kommunikation ueber den UART laeuft.
* 2. Logging ueber ct-Sim: LOG_CTSIM_AVAILABLE muss definiert sein.
* BOT_2_PC_AVAILABLE muss zusaetzlich definiert sein.
* 3. Logging ueber Display: LOG_DISPLAY_AVAILABLE muss definiert sein, sowie
* DISPLAY_AVAILABLE und DISPLAY_SCREENS_AVAILABLE.
* Logging erfolgt auf Screen 5.
* </pre>
*
* @author Andreas Merkle (mail@blue-andi.de)
* @date 27.02.06
*/
#ifndef LOG_H_
#define LOG_H_
#include "ct-Bot.h"
#ifdef LOG_AVAILABLE
/*!
* Allgemeines Debugging (Methode DiesUndDas wurde mit Parameter SoUndSo
* aufgerufen ...)
*/
#define LOG_DEBUG(__dbg) log_begin(__FILE__, __LINE__, LOG_TYPE_DEBUG), \
log_printf __dbg, \
log_end()
/*!
* Allgemeine Informationen (Programm gestartet, Programm beendet, Verbindung
* zu Host Foo aufgebaut, Verarbeitung dauerte SoUndSoviel Sekunden ...)
*/
#define LOG_INFO(__dbg) log_begin(__FILE__, __LINE__, LOG_TYPE_INFO), \
log_printf __dbg, \
log_end()
/*!
* Auftreten einer unerwarteten Situation.
*/
#define LOG_WARN(__dbg) log_begin(__FILE__, __LINE__, LOG_TYPE_WARN), \
log_printf __dbg, \
log_end()
/*!
* Fehler aufgetreten, Bearbeitung wurde alternativ fortgesetzt.
*/
#define LOG_ERROR(__dbg) log_begin(__FILE__, __LINE__, LOG_TYPE_ERROR), \
log_printf __dbg, \
log_end()
/*!
* Kritischer Fehler, Programmabbruch.
*/
#define LOG_FATAL(__dbg) log_begin(__FILE__, __LINE__, LOG_TYPE_FATAL), \
log_printf __dbg, \
log_end()
#else
/*!
* Allgemeines Debugging (Methode DiesUndDas wurde mit Parameter SoUndSo
* aufgerufen ...)
*/
#define LOG_DEBUG(__dbg)
/*!
* Allgemeine Informationen (Programm gestartet, Programm beendet, Verbindung
* zu Host Foo aufgebaut, Verarbeitung dauerte SoUndSoviel Sekunden ...)
*/
#define LOG_INFO(__dbg)
/*!
* Auftreten einer unerwarteten Situation.
*/
#define LOG_WARN(__dbg)
/*!
* Fehler aufgetreten, Bearbeitung wurde alternativ fortgesetzt.
*/
#define LOG_ERROR(__dbg)
/*!
* Kritischer Fehler, Programmabbruch.
*/
#define LOG_FATAL(__dbg)
#endif /* LOG_AVAILABLE */
/*! Dieser Typ definiert die Typen der Log-Ausgaben. */
typedef enum {
LOG_TYPE_DEBUG = 0, /*!< Allgemeines Debugging */
LOG_TYPE_INFO, /*!< Allgemeine Informationen */
LOG_TYPE_WARN, /*!< Auftreten einer unerwarteten Situation */
LOG_TYPE_ERROR, /*!< Fehler aufgetreten */
LOG_TYPE_FATAL /*!< Kritischer Fehler */
} LOG_TYPE;
#ifdef LOG_AVAILABLE
/*!
* Schreibt Angaben ueber Datei, Zeilennummer und den Log-Typ in den Puffer.
* Achtung, Mutex wird gelockt und muss explizit durch log_end() wieder
* freigegeben werden!
* @param filename Dateiname
* @param line Zeilennummer
* @param log_type Log-Typ
*/
extern void log_begin(char *filename, unsigned int line, LOG_TYPE log_type);
/*!
* Schreibt die eigentliche Ausgabeinformation in den Puffer.
* @param format Format
*/
extern void log_printf(char *format, ...);
/*!
* Gibt den Puffer entsprechend aus.
*/
extern void log_end(void);
#endif /* LOG_AVAILABLE */
#endif /*LOG_H_*/

149
source/ct-Bot/include/map.h Normal file
View file

@ -0,0 +1,149 @@
#ifndef MAP_H_
#define MAP_H_
/*
* c't-Bot - 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 map.h
* @brief Karte
* @author Benjamin Benz (bbe@heise.de)
* @date 19.09.06
*/
#include <stdio.h>
#include "ct-Bot.h"
#ifdef MAP_AVAILABLE
/* Es lohnt nicht gigantische Karten auszugeben, wenn sie nichts enthalten, daher hier zwei Varianten, um die Karte auf die realen groesse zu reduzieren */
#define SHRINK_MAP_ONLINE /*!< Wenn gesetzt, wird bei jedem update der belegte Bereich der Karte protokolliert. Pro: schnelle ausgabe Contra permanenter aufwand */
//#define SHRINK_MAP_OFFLINE /*!< Wenn gesetzt, wird erst beid er Ausgabe der belegte Bereich der Karte berechnet. Pro: kein permanenter aufwand Contra: ausgabe dauert lange */
#ifdef MCU
#ifdef MMC_AVAILABLE
#define MAP_SIZE 4 /*! Kantenlaenge der Karte in Metern. Ursprung ist der Startplatz des Bots */
#define MAP_RESOLUTION 128 /*!< Aufloesung der Karte in Punkte pro Meter */
#define MAP_SECTION_POINTS 16 /*!< Kantenlaenge einer Section in Punkten ==> eine Section braucht MAP_SECTION_POINTS*MAP_SECTION_POINTS Bytes */
#else
#define MAP_SIZE 4 /*! Kantenlaenge der Karte in Metern. Ursprung ist der Startplatz des Bots */
#define MAP_SECTION_POINTS 32 /*!< Kantenlaenge einer Section in Punkten ==> eine Section braucht MAP_SECTION_POINTS*MAP_SECTION_POINTS Bytes */
#define MAP_RESOLUTION (MAP_SECTION_POINTS/MAP_SIZE) /*!< Aufloesung der Karte in Punkte pro Meter */
#endif
#else
#define MAP_SIZE 4 /*! Kantenlaenge der Karte in Metern. Ursprung ist der Startplatz des Bots */
#define MAP_RESOLUTION 128 /*!< Aufloesung der Karte in Punkte pro Meter */
#define MAP_SECTION_POINTS 16 /*!< Kantenlaenge einer Section in Punkten ==> eine Section braucht MAP_SECTION_POINTS*MAP_SECTION_POINTS Bytes */
#endif
// Die folgenden Variablen/konstanten NICHT direkt benutzen, sondern die zugehoerigen Makros: get_map_min_x() und Co!
// Denn sonst erhaelt man Karten und nicht Weltkoordinaten!
#ifdef SHRINK_MAP_ONLINE
extern uint16 map_min_x; /*!< belegter Bereich der Karte [Kartenindex]: kleinste X-Koordinate */
extern uint16 map_max_x; /*!< belegter Bereich der Karte [Kartenindex]: groesste X-Koordinate */
extern uint16 map_min_y; /*!< belegter Bereich der Karte [Kartenindex]: kleinste Y-Koordinate */
extern uint16 map_max_y; /*!< belegter Bereich der Karte [Kartenindex]: groesste Y-Koordinate */
#else
#define map_min_x 0
#define map_min_y 0
#define map_max_x (MAP_SIZE*MAP_RESOLUTION)
#define map_max_y (MAP_SIZE*MAP_RESOLUTION)
#endif
/*!
* Aktualisiert die interne Karte
* @param x X-Achse der Position
* @param y Y-Achse der Position
* @param head Blickrichtung in Grad
* @param distL Sensorwert links
* @param distR Sensorwert rechts
*/
void update_map(float x, float y, float head, int16 distL, int16 distR);
/*!
* Aktualisiert den Standkreis der internen Karte
* @param x X-Achse der Position
* @param y Y-Achse der Position
*/
void update_map_location(float x, float y);
/*!
* liefert den Wert eines Feldes
* @param x x-Ordinate der Karte (nicht der Welt!!!)
* @param y y-Ordinate der Karte (nicht der Welt!!!)
* @return Wert des Feldes (>0 heisst frei, <0 heisst belegt
*/
int8 map_get_field (uint16 x, uint16 y);
/*!
* liefert den Wert eines Feldes
* @param x x-Ordinate der Welt
* @param y y-Ordinate der Welt
* @return Wert des Feldes (>0 heisst frei, <0 heisst belegt
*/
int8 map_get_point (float x, float y);
/*!
* Konvertiert eine Weltkoordinate in eine Kartenkoordinate
* @param koord Weltkordiante
* @return kartenkoordinate
*/
uint16 world_to_map(float koord);
/*!
* Konvertiert eine Kartenkoordinate in eine Weltkoordinate
* @param map_koord kartenkoordinate
* @return Weltkordiante
*/
float map_to_world(uint16 map_koord);
/*!
* Zeigt die Karte an
*/
void print_map(void);
/*!
* initialisiere die Karte
* @return 0 wenn alles ok ist
*/
int8 map_init(void);
/*! Liest eine Map wieder ein
* @param filename Quelldatei
*/
void read_map(char * filename);
/*!
* Schreibt einbe Karte in eine PGM-Datei
* @param filename Zieldatei
*/
void map_to_pgm(char * filename);
// Makros, um die belegte kartenbereiche (in weltkoordinaten) zu ermitteln
#define map_get_min_x() map_to_world(map_min_x)
#define map_get_min_y() map_to_world(map_min_y)
#define map_get_max_x() map_to_world(map_max_x)
#define map_get_max_y() map_to_world(map_max_y)
#endif
#endif /*MAP_H_*/

View file

@ -0,0 +1,63 @@
/*
* 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 mini-fat.h
* @brief Routinen zum Auffinden von markierten Files auf einer MMC-Karte.
* Dies ist keine vollstaendige FAT-Unterstuetzung, sondern sucht nur eien Datei, die mit einer 3-Zeichen Sequenz beginnt.
* @author Benjamin Benz (bbe@heise.de)
* @author Ulrich Radig (mail@ulrichradig.de) www.ulrichradig.de
* @date 07.11.06
*/
#ifndef MINIFAT_H_
#define MINIFAT_H_
#include "ct-Bot.h"
#define MMC_FILENAME_MAX 255 /*!< Maximale Dateienamenlaenge in Zeichen [1;255] */
typedef union{
uint32 u32; // Laenge in 32 Bit
uint8 u8[4]; // laenge in 4 "einzelnen" Bytes
} file_len_t;
#ifdef MINI_FAT_AVAILABLE
/*!
* Sucht einen Block auf der MMC-Karte, dessen erste drei Bytes dem key entsprechen
* liefert dann den folgenden Block zurueck.
* Achtung das prinzip geht nur, wenn die Dateien nicht fragmentiert sind
* @param key 3 Byte zur Identifikation
* @param buffer Zeiger auf 512 Byte Puffer im SRAM
*/
uint32 mini_fat_find_block(const char key[3], uint8* buffer);
#endif
#ifdef PC
/*! Erzeugt eine Datei, die an den ersten 3 Byte die ID- enthaelt. dann folgen 512 - sizeof(id) nullen
* Danach kommen so viele size kByte Nullen
* @param filename Der Dateiname der zu erzeugenden Datei
* @param id_string Die ID des Files, wie sie zu beginn steht
* @param size kByte Nutzdaten, die der MCU spaeter beschreiben darf
*/
void create_mini_fat_file(const char* filename, const char* id_string, uint32 size);
#endif
#endif /*MINIFAT_H_*/

View file

@ -0,0 +1,85 @@
/*
* 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 mmc-emu.h
* @brief MMC / SD-Card Emulation fuer PC
* @author Timo Sandmann (mail@timosandmann.de)
* @date 10.12.2006
*/
#ifndef MMC_EMU_H_
#define MMC_EMU_H_
#include "ct-Bot.h"
#ifdef PC
/*!
* Checkt Initialisierung der emulierten Karte
* @return 0, wenn initialisiert
* @see mcu/mmc.c
* @date 29.12.2006
*/
inline uint8 mmc_emu_get_init_state(void);
/*!
* Initialisiere die emulierte SD/MMC-Karte
* @return 0 wenn allles ok, sonst 1
* @see mcu/mmc.c
* @date 29.12.2006
*/
uint8 mmc_emu_init (void);
/*!
* Liest einen Block von der emulierten Karte
* @param addr Nummer des 512-Byte Blocks
* @param buffer Puffer von mindestens 512 Byte
* @return 0 wenn alles ok ist
* @see mcu/mmc.c
* @date 10.12.2006
*/
uint8 mmc_emu_read_sector(uint32 addr, uint8* buffer);
/*!
* Schreibt einen 512-Byte Sektor auf die emulierte Karte
* @param addr Nummer des 512-Byte Blocks
* @param buffer Zeiger auf den Puffer
* @param async Wird bei der PC-Version nicht ausgewertet
* @return 0 wenn alles ok ist
* @date 10.12.2006
* @see mcu/mmc.c
*/
uint8 mmc_emu_write_sector(uint32 addr, uint8* buffer, uint8 async);
/*!
* Liefert die Groesse der emulierten Karte zurueck
* @return Groesse der emulierten Karte in Byte.
* @date 29.12.2006
*/
uint32 mmc_emu_get_size(void);
/*!
* Testet VM und MMC / SD-Card Emulation am PC
* @date 30.12.2006
*/
uint8 mmc_emu_test(void);
#endif // PC
#endif /*MMC_H_*/

View file

@ -0,0 +1,45 @@
/*
* 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 mmc-low.h
* @brief Low-Level-Routinen zum Lesen/Schreiben einer MMC / SD-Card
* @author Timo Sandmann (mail@timosandmann.de)
* @date 14.11.06
*/
#ifndef MMC_LOW_H_
#define MMC_LOW_H_
/* Portkonfiguration */
#define MMC_PORT_OUT PORTB // Port an der die MMC/SD-Karte angeschlossen ist also des SPI
#define MMC_PORT_IN PINB
#define MMC_DDR DDRB
#define SPI_DI 6 // Port Pin an dem Data Output der MMC/SD-Karte angeschlossen ist
#define SPI_DO 5 // Port Pin an dem Data Input der MMC/SD-Karte angeschlossen ist
#define MMC_CLK_DDR DDRB
#define MMC_CLK_PORT PORTB
#define SPI_CLK 7 // Port Pin an dem die Clock der MMC/SD-Karte angeschlossen ist (clk)
#define MMC_TIMEOUT 500 // Wartezyklen auf Cardresponse
#define MMC_ASYNC_WRITE 0 // 1 Aktiviert asynchrones Schreiben auf die Karte, wo es sinnvoll ist, 0 schaltet es aus. Funktioniert allerdings nicht mit allen Karten */
#endif // MMC_LOW_H

View file

@ -0,0 +1,150 @@
/*
* 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 mmc_vm.h
* @brief Virtual Memory Management mit MMC / SD-Card
* @author Timo Sandmann (mail@timosandmann.de)
* @date 30.11.2006
* @see Documentation/mmc-vm.html
*/
#ifndef MMC_VM_H_
#define MMC_VM_H_
#include "ct-Bot.h"
#ifdef MMC_VM_AVAILABLE
//#define VM_STATS_AVAILABLE /*!< Schaltet die Leistungsdatensammlung ein und ermoeglicht die Ausgabe einer Statistik */
#ifdef VM_STATS_AVAILABLE
typedef struct{
uint32 page_access; /*!< Anzahl der Seitenzugriffe seit Systemstart */
uint32 swap_ins; /*!< Anzahl der Seiteneinlagerungen seit Systemstart */
uint32 swap_outs; /*!< Anzahl der Seitenauslagerungen seit Systemstart */
uint32 vm_used_bytes; /*!< Anzahl der vom VM belegten Bytes auf der MMC / SD-Card */
uint32 device_size; /*!< Groesse des Speichervolumes */
uint32 vm_size; /*!< Groesse des Virtuellen Speichers */
uint8 cache_size; /*!< Groesse des Caches */
int8 cache_load; /*!< Belegter Speicher des Caches */
uint16 page_access_s; /*!< Seitenzugriffe pro Sekunde */
uint16 swap_ins_s; /*!< Pagefaults pro Sekunde */
uint16 swap_outs_s; /*!< Seitenauslagerungen pro Sekunde */
uint16 delta_t; /*!< Sekunden seit Beginn der Messung */
} vm_extern_stats_t;
/*!
* Gibt die Anzahl der Pagefaults seit Systemstart bzw. Ueberlauf zurueck
* @return #Pagefaults
* @author Timo Sandmann (mail@timosandmann.de)
* @date 30.11.2006
*/
uint32 mmc_get_pagefaults(void);
/*!
* Erstellt eine kleine Statistik ueber den VM
* @return Zeiger auf Statistikdaten
* @date 01.01.2007
*/
vm_extern_stats_t* mmc_get_vm_stats(void);
/*!
* Gibt eine kleine Statistik ueber den VM aus (derzeit nur am PC)
* @date 01.01.2007
*/
void mmc_print_statistic(void);
#endif
/*!
* Fordert virtuellen Speicher an
* @param size Groesse des gewuenschten Speicherblocks
* @param aligned 0: egal, 1: 512 Byte ausgerichtet
* @return Virtuelle Anfangsadresse des angeforderten Speicherblocks, 0 falls Fehler
* @author Timo Sandmann (mail@timosandmann.de)
* @date 30.11.2006
*/
uint32 mmcalloc(uint32 size, uint8 aligned);
/*!
* Gibt einen Zeiger auf einen Speicherblock im RAM zurueck
* @param addr Eine virtuelle Adresse
* @return Zeiger auf uint8, NULL falls Fehler
* @author Timo Sandmann (mail@timosandmann.de)
* @date 30.11.2006
*/
uint8* mmc_get_data(uint32 addr);
/*!
* Gibt die letzte Adresse einer Seite zurueck
* @param addr Eine virtuelle Adresse
* @return Adresse
* @author Timo Sandmann (mail@timosandmann.de)
* @date 30.11.2006
*/
inline uint32 mmc_get_end_of_page(uint32 addr);
/*!
* Erzwingt das Zurueckschreiben einer eingelagerten Seite auf die MMC / SD-Card
* @param addr Eine virtuelle Adresse
* @return 0: ok, 1: Seite zurzeit nicht eingelagert, 2: Fehler beim Zurueckschreiben
* @author Timo Sandmann (mail@timosandmann.de)
* @date 15.12.2006
*/
uint8 mmc_page_write_back(uint32 addr);
/*!
* Schreibt alle eingelagerten Seiten auf die MMC / SD-Card zurueck
* @return 0: alles ok, sonst: Fehler beim Zurueckschreiben
* @author Timo Sandmann (mail@timosandmann.de)
* @date 21.12.2006
*/
uint8 mmc_flush_cache(void);
/*!
* Oeffnet eine Datei im FAT16-Dateisystem auf der MMC / SD-Card und gibt eine virtuelle Adresse zurueck,
* mit der man per mmc_get_data() einen Pointer auf die gewuenschten Daten bekommt. Das Ein- / Auslagern
* macht das VM-System automatisch. Der Dateiname muss derzeit am Amfang in der Datei stehen.
* Achtung: Irgendwann muss man die Daten per mmc_flush_cache() oder mmc_page_write_back() zurueckschreiben!
* @param filename Dateiname als 0-terminierter String
* @return Virtuelle Anfangsadresse der angeforderten Datei, 0 falls Fehler
* @author Timo Sandmann (mail@timosandmann.de)
* @date 21.12.2006
*/
uint32 mmc_fopen(const char *filename);
/*!
* Leert eine Datei im FAT16-Dateisystem auf der MMC / SD-Card, die zuvor mit mmc_fopen() geoeffnet wurde.
* @param file_start (virtuelle) Anfangsadresse der Datei
* @return 0: ok, 1: ungueltige Datei oder Laenge, 2: Fehler beim Schreiben
* @date 02.01.2007
*/
uint8 mmc_clear_file(uint32 file_start);
/*!
* Liest die Groesse einer Datei im FAT16-Dateisystem auf der MMC / SD-Card aus, die zu zuvor mit
* mmc_fopen() geoeffnet wurde.
* @param file_start (virtuelle Anfangsadresse der Datei)
* @return Groesse der Datei in Byte
* @date 12.01.2007
*/
uint32 mmc_get_filesize(uint32 file_start);
#endif // MMC_VM_AVAILABLE
#endif // MMC_VM_H_

104
source/ct-Bot/include/mmc.h Normal file
View file

@ -0,0 +1,104 @@
/*
* 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 mmc.h
* @brief Routinen zum Auslesen/Schreiben einer MMC-Karte
* @author Benjamin Benz (bbe@heise.de)
* @author Ulrich Radig (mail@ulrichradig.de) www.ulrichradig.de
* @date 07.11.06
*/
#ifndef MMC_H_
#define MMC_H_
#include "ct-Bot.h"
#ifdef MMC_AVAILABLE
#define MMC_INFO_AVAILABLE /*!< Die Karte kann uns einiges ueber sich verrraten, wenn wir sie danach fragen. Aber es kostet halt Platz im Flash */
//#define MMC_WRITE_TEST_AVAILABLE /*!< Achtung dieser Test zerstoert die Daten auf der Karte!!! */
/*!
* Checkt Initialisierung der Karte
* @return 0, wenn initialisiert
*/
inline uint8 mmc_get_init_state(void);
uint8 mmc_enable(void);
/*!
* Liest einen Block von der Karte
* @param addr Nummer des 512-Byte Blocks
* @param Buffer Puffer von mindestens 512 Byte
* @return 0 wenn alles ok ist, 1 wenn Init nicht moeglich oder Timeout vor / nach Kommando 17
* @author Timo Sandmann (mail@timosandmann.de)
* @date 17.11.2006
* @see mmc-low.s
*/
uint8 mmc_read_sector(uint32 addr, uint8 *buffer);
/*!
* Schreibt einen 512-Byte Sektor auf die Karte
* @param addr Nummer des 512-Byte Blocks
* @param Buffer Zeiger auf den Puffer
* @param async 0: synchroner, 1: asynchroner Aufruf, siehe MMC_ASYNC_WRITE in mmc-low.h
* @return 0 wenn alles ok ist, 1 wenn Init nicht moeglich oder Timeout vor / nach Kommando 24, 2 wenn Timeout bei busy
* @author Timo Sandmann (mail@timosandmann.de)
* @date 16.11.2006
* @see mmc-low.s
*/
uint8 mmc_write_sector(uint32 addr, uint8 *buffer, uint8 async);
/*!
* Initialisiere die SD/MMC-Karte
* @return 0 wenn allles ok, sonst Nummer des Kommandos bei dem abgebrochen wurde
*/
uint8 mmc_init (void);
#ifdef MMC_INFO_AVAILABLE
/*!
* Liest das CSD-Register (16 Byte) von der Karte
* @param Buffer Puffer von mindestens 16 Byte
*/
void mmc_read_csd (uint8 *buffer);
/*!
* Liest das CID-Register (16 Byte) von der Karte
* @param Buffer Puffer von mindestens 16 Byte
*/
void mmc_read_cid (uint8 *buffer);
/*!
* Liefert die Groesse der Karte zurueck
* @return Groesse der Karte in Byte. Bei einer 4 GByte-Karte kommt 0xFFFFFFFF zurueck
*/
uint32 mmc_get_size(void);
#endif
#ifdef MMC_WRITE_TEST_AVAILABLE
/*! Testet die MMC-Karte. Schreibt nacheinander 2 Sektoren a 512 Byte mit testdaten voll und liest sie wieder aus
* !!! Achtung loescht die Karte
* @return 0, wenn alles ok
*/
uint8 mmc_test(void);
#endif
#endif
#endif /*MMC_H_*/

View file

@ -0,0 +1,53 @@
/*
* 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 motor-low.h
* @brief Low-Level Routinen fuer die Motorsteuerung des c't-Bots
* @author Benjamin Benz (bbe@heise.de)
* @date 01.12.05
*/
#ifndef motor_low_H_
#define motor_low_H_
#include "global.h"
/*!
* Initialisiert alles fuer die Motosteuerung
*/
void motor_low_init(void);
/*!
* Unmittelbarer Zugriff auf die beiden Motoren
* normalerweise NICHT verwenden!!!!!
* @param left speed links
* @param right speed rechts
*/
void bot_motor(int16 left, int16 right);
/*!
* Stellt die Servos
* Sinnvolle Werte liegen zwischen 8 und 16
*/
void servo_low(uint8 servo, uint8 pos);
#endif

View file

@ -0,0 +1,98 @@
/*
* 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 motor.h
* @brief High-Level Routinen fuer die Motorsteuerung des c't-Bots
* @author Benjamin Benz (bbe@heise.de)
* @date 15.01.05
*/
#ifndef motor_H_
#define motor_H_
#include "global.h"
#include "ct-Bot.h"
#define BOT_SPEED_IGNORE 1000 /*!< Wert ausserhalb von -BOT_SPEED_MAX und BOT_SPEED_MAX wird verwendet um einen Eintrag zu ignorieren */
#define BOT_SPEED_STOP 0 /*!< Motor aus */
#define BOT_SPEED_SLOW 49 /*!< langsame Fahrt in mm/s */
#define BOT_SPEED_FOLLOW 72 /*!< vorsichtige Fahrt, fuer Folgeverhalten in mm/s */
#define BOT_SPEED_MEDIUM 99 /*!< mittlere Fahrt in mm/s */
#define BOT_SPEED_NORMAL 144 /*!< normale Fahrt in mm/s */
#define BOT_SPEED_FAST 297 /*!< schnelle Fahrt in mm/s */
#define BOT_SPEED_MAX 450 /*!< maximale Fahrt in mm/s */
#define DIRECTION_FORWARD 0 /*!< Drehrichtung vorwaerts */
#define DIRECTION_BACKWARD 1 /*!< Drehrichtung rueckwaerts */
#define DOOR_CLOSE 7 /*!< Rechter Anschlag des Servos */
#define DOOR_OPEN 14 /*!< Linker Anschlag des Servos */
#define SERVO_OFF 0 /*!< Servo wird zum stromsparen deaktiviert */
#define SERVO1 1 /*!< Servo1 */
#define SERVO2 2 /*!< Servo1 */
extern int16 speed_l; /*!< Geschwindigkeit des linken Motors */
extern int16 speed_r; /*!< Geschwindigkeit des rechten Motors */
extern int16 motor_left; /*!< zuletzt gestellter Wert linker Motor */
extern int16 motor_right; /*!< zuletzt gestellter Wert rechter Motor */
/*! In diesem Typ steht die Drehrichtung, auch wenn die Speed-Variablen bereits wieder auf Null sind */
typedef struct {
uint8 left:1;
uint8 right:1;
#ifndef DOXYGEN
} __attribute__ ((packed)) direction_t;
#else
} direction_t;
#endif
extern direction_t direction; /*!< Drehrichtung der Motoren, auch wenn die Speed-Variablen bereits wieder auf Null sind */
/*!
* Initialisiere den Motorkrams
*/
void motor_init(void);
/*!
* Direkter Zugriff auf den Motor
* @param left Geschwindigkeit fuer den linken Motor
* @param right Geschwindigkeit fuer den linken Motor
* zwischen -255 und +255;
* 0 bedeutet Stillstand, 255 volle Kraft voraus, -255 volle Kraft zurueck
* Sinnvoll ist die Verwendung der Konstanten: BOT_SPEED_XXX,
* also z.B. motor_set(BOT_SPEED_LOW,-BOT_SPEED_LOW);
* fuer eine langsame Drehung
*/
void motor_set(int16 left, int16 right);
/*!
* Stellt die Servos
* Sinnvolle Werte liegen zwischen 8 und 16
* @param servo Nummer des Servos
* @param servo Zielwert
*/
void servo_set(uint8 servo, uint8 pos);
#endif

View file

@ -0,0 +1,113 @@
/*
* 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 mouse.h
* @brief Routinen fuer die Ansteuerung eines optischen Maussensors
* @author Benjamin Benz (bbe@heise.de)
* @date 26.12.05
*/
#ifndef mouse_H_
#define mouse_H_
#define ADNS2610 /*!< Welcher Sensortyp? ADNS2610 oder 2620 */
#ifdef ADNS2610
/* ADNS2610 */
#define MOUSE_CONFIG_REG 0x00 /*!< Reset, Power Down, Forced Awake, etc */
#define MOUSE_STATUS_REG 0x01 /*!< Product ID, Mouse state of Asleep or Awake */
#define MOUSE_DELTA_Y_REG 0x02 /*!< Y Movement */
#define MOUSE_DELTA_X_REG 0x03 /*!< X Movement */
#define MOUSE_SQUAL_REG 0x04 /*!< Measure of the number of features visible by the sensor */
#define MOUSE_MAX_PIXEL_REG 0x05 /*!< Maximum Pixel value in current frame.*/
#define MOUSE_MIN_PIXEL_REG 0x06 /*!< Minimum Pixel value in current frame.*/
#define MOUSE_PIXEL_SUM_REG 0x07 /*!< This register is used to find the average pixel value.*/
#define MOUSE_PIXEL_DATA_REG 0x08 /*!< Actual picture of surface */
#define MOUSE_SHUTTER_UPPER_REG 0x09 /*!< The sensor adjusts the shutter to keep the average and maximum pixel values within normal operating ranges.*/
#define MOUSE_SHUTTER_LOWER_REG 0x0A /*!< The sensor adjusts the shutter to keep the average and maximum pixel values within normal operating ranges.*/
#define MOUSE_INVERSE_PRODUCT_ID_REG 0x11 /*!< Inverse Product ID */
#define MOUSE_CFG_RESET 0x80 /*!< Reset Circuit */
#define MOUSE_CFG_POWERDOWN 0x40 /*!< Power Down analog Circuit */
#define MOUSE_CFG_FORCEAWAKE 0x01 /*!< Keep Sensor awake */
#else
/* ADNS2620 */
#define MOUSE_CONFIG_REG 0x40 /*!< Reset, Power Down, Forced Awake, etc */
#define MOUSE_STATUS_REG 0x41 /*!< Product ID, Mouse state of Asleep or Awake */
#define MOUSE_DELTA_Y_REG 0x42 /*!< Y Movement */
#define MOUSE_DELTA_X_REG 0x43 /*!< X Movement */
#define MOUSE_SQUAL_REG 0x44 /*!< Measure of the number of features visible by the sensor */
#define MOUSE_MAX_PIXEL_REG 0x45 /*!< Maximum Pixel value in current frame.*/
#define MOUSE_MIN_PIXEL_REG 0x46 /*!< Minimum Pixel value in current frame.*/
#define MOUSE_PIXEL_SUM_REG 0x47 /*!< This register is used to find the average pixel value.*/
#define MOUSE_PIXEL_DATA_REG 0x48 /*!< Actual picture of surface */
#define MOUSE_SHUTTER_UPPER_REG 0x49 /*!< The sensor adjusts the shutter to keep the average and maximum pixel values within normal operating ranges.*/
#define MOUSE_SHUTTER_LOWER_REG 0x4A /*!< The sensor adjusts the shutter to keep the average and maximum pixel values within normal operating ranges.*/
#define MOUSE_FRAME_PERIOD_REG 0x4B /*!< The frame period counter counts up until it overflows. */
#endif
/*!
* Initialisiere Maussensor
*/
void maus_sens_init(void);
/*!
* Schickt ein Lesekommando an den Sensor
* und liest ein Byte zurueck
* @param adr die Adresse
* @return das Datum
*/
uint8 maus_sens_read(uint8 adr);
/*! Stellt sicher, dass der Maussensor nicht mehr die serielle Datenleitung treibt */
#define maus_sens_highZ() maus_sens_write(0x77,0x00)
/*!
* Uebertraegt ein write-Kommando an den Sensor
* @param adr Adresse
* @param data Datum
*/
void maus_sens_write(int8 adr, uint8 data);
/*!
* Liefert bei jedem Aufruf das naechste Pixel des Bildes
* Insgesamt gibt es 324 Pixel
* <pre>
* 18 36 ... 324
* .. .. ... ..
* 2 20 ... ..
* 1 19 ... 307
* </pre>
* Bevor diese Funktion aufgerufen wird, muss maus_image_prepare() aufgerufen werden!
* @return Die Pixeldaten (Bit 0 bis Bit5), Pruefbit, ob Daten gueltig (Bit6), Markierung fuer den Anfang eines Frames (Bit7)
*/
int8 maus_image_read(void);
/*!
* Bereitet das auslesen eines ganzen Bildes vor
*/
void maus_image_prepare(void);
/*!
* Gibt den SQUAL-Wert zurueck. Dieser gibt an, wieviele Merkmale der Sensor
* im aktuell aufgenommenen Bild des Untergrunds wahrnimmt
*/
uint8 maus_get_squal(void);
#endif

View file

@ -0,0 +1,591 @@
/*
* 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 rc5-codes.h
* @brief RC5-Fernbedienungscodes
* @author Andreas Merkle (mail@blue-andi.de)
* @date 15.02.06
* Wer diese Datei angepasst hat, kann Sie durch einen .cvsignore Eintrag schützen.
* Dann Ueberschreibt Eclipse Sie nicht mehr automatisch
*/
#ifndef RC5CODE_H_
#define RC5CODE_H_
#define RC5_TOGGLE 0x0800 /*!< Das RC5-Toggle-Bit */
#define RC5_ADDRESS 0x07C0 /*!< Der Adressbereich */
#define RC5_COMMAND 0x103F /*!< Der Kommandobereich */
/* Im Normalbetrieb hilft die Beschränkung der RC5_MASK auf RC5_COMMAND dem Bot,
* moeglichst viele FBs zu erkennen.
* Zum erfassen neuer Codes sollte man unbedingt RC5_MASK auf (RC5_COMMAND|RC5_ADDRESS) setzen */
// Normalbetrieb
#define RC5_MASK (RC5_COMMAND) /*!< Welcher Teil des Kommandos wird ausgewertet? */
// Erfassen neuer FB-Codes
//#define RC5_MASK (RC5_COMMAND|RC5_ADDRESS) /*!< Welcher Teil des Kommandos wird ausgewertet? */
/*!
* Definition RC5-Codes verschiedener Fernbedienungen. Wer eine neue FB
* einfuegen will, sollte
*
* - eine Definition per cut&paste duplizieren,
* - eine geeignete Konstante RC_HAVE_{Herstellername}_{Fernbedienungsname}
* waehlen,
* - diese Konstante in die obere Liste der FB-Selektion eintragen,
* - die alte FB-Konstante im kopierten Bereich ersetzen,
* - festlegen, ob die FB ein Jog-Dial hat, ob der RC5_NOT_AVAIL-Code
* wirklich nie von der FB generiert werden kann (0xFFFF ist meisst ok)
* - die eigentlichen, herausgefunden Codes eintragen.
*
* Ist das erledigt, und funktioniert die neue FB-Definition, kann diese
* in der c't-bot-Entwicklerliste vorgestellt werden. (mb/18.03.2006)
*/
/* Nur auf dem realen Bot gibt es verschiedene FBs */
#ifdef MCU
// Dies ist die Standard-Fernbedienung unter anderem fuer den Sim
#define RC_HAVE_HQ_RC_UNIVERS29_334
//#define RC_HAVE_HAUPPAUGE_WINTV
//#define RC_HAVE_HAUPPAUGE_MediaMPV
//#define RC_HAVE_CONRAD_PROMO8
//#define RC_HAVE_VIVANCO_UR89
//#define RC_HAVE_VIVANCO_UR89_TV_CODE_089
//#define RC_HAVE_Technisat_TTS35AI
//#define RC_HAVE_LIFETEC_LT3607
#else
// Dies ist die Standard-Fernbedienung unter anderem fuer den Sim
#define RC_HAVE_HQ_RC_UNIVERS29_334
//#define RC_HAVE_DEFAULT
#endif
// Code um zu kennzeichnen, dass eine Taste nicht vorhanden ist
#define RC5_NOT_AVAIL (0xFFFF) /*!< Code fuer Taste nicht vorhanden */
/*!
* Default-Fernbedienung
* HQ RC Univers 29, Geraetecode 334
*/
#ifdef RC_HAVE_HQ_RC_UNIVERS29_334
#define RC5_CODE_PWR (0x118C & RC5_MASK) /*!< Taste An/Aus */
#define RC5_CODE_0 (0x1180 & RC5_MASK) /*!< Taste 0 /10*/
#define RC5_CODE_1 (0x1181 & RC5_MASK) /*!< Taste 1 */
#define RC5_CODE_2 (0x1182 & RC5_MASK) /*!< Taste 2 */
#define RC5_CODE_3 (0x1183 & RC5_MASK) /*!< Taste 3 */
#define RC5_CODE_4 (0x1184 & RC5_MASK) /*!< Taste 4 */
#define RC5_CODE_5 (0x1185 & RC5_MASK) /*!< Taste 5 */
#define RC5_CODE_6 (0x1186 & RC5_MASK) /*!< Taste 6 */
#define RC5_CODE_7 (0x1187 & RC5_MASK) /*!< Taste 7 */
#define RC5_CODE_8 (0x1188 & RC5_MASK) /*!< Taste 8 */
#define RC5_CODE_9 (0x1189 & RC5_MASK) /*!< Taste 9 */
#define RC5_CODE_11 (0x118A & RC5_MASK) /*!< Taste 11 /1-*/
#define RC5_CODE_12 (0x11A3 & RC5_MASK) /*!< Taste 12 /2-*/
#define RC5_CODE_GREEN (0x01BA & RC5_MASK) /*!< Gruene Taste */
#define RC5_CODE_RED (0x01BD & RC5_MASK) /*!< Rote Taste */
#define RC5_CODE_YELLOW (0x01B1 & RC5_MASK) /*!< Gelbe Taste */
#define RC5_CODE_BLUE (0x01B0 & RC5_MASK) /*!< Blaue Taste */
#define RC5_CODE_I_II (0x11AB & RC5_MASK) /*!< I/II-Taste */
#define RC5_CODE_TV_VCR (0x11B8 & RC5_MASK) /*!< TV/VCR-Taste */
#define RC5_CODE_DOT (0x11AB & RC5_MASK) /*!< Taste mit rundem Punkt */
#define RC5_CODE_PLAY (0x11B5 & RC5_MASK) /*!< PLAY-Taste */
#define RC5_CODE_STILL (0x11A9 & RC5_MASK) /*!< Pause Taste */
#define RC5_CODE_STOP (0x11B6 & RC5_MASK) /*!< Pause Taste */
#define RC5_CODE_BWD (0x11B2 & RC5_MASK) /*!< Backward Taste */
#define RC5_CODE_FWD (0x11B4 & RC5_MASK) /*!< Forward Taste */
#define RC5_CODE_CH_PC (0x11BF & RC5_MASK) /*!< CH*P/C Taste */
#define RC5_CODE_MUTE (0x01BF & RC5_MASK) /*!< Mute-Taste */
#define RC5_VOL_PLUS (0x1190 & RC5_MASK) /*!< Vol + Taste */
#define RC5_VOL_MINUS (0x1191 & RC5_MASK) /*!< Vol - Taste */
#define RC5_CH_PLUS (0x11A0 & RC5_MASK) /*!< Ch + Taste */
#define RC5_CH_MINUS (0x11A1 & RC5_MASK) /*!< Ch - Taste */
#define RC5_CODE_UP RC5_CODE_STILL /*!< Taste Hoch */
#define RC5_CODE_DOWN RC5_CODE_STOP /*!< Taste Runter */
#define RC5_CODE_LEFT RC5_CODE_BWD /*!< Taste Links */
#define RC5_CODE_RIGHT RC5_CODE_FWD /*!< Taste Rechts */
#endif
/*!
* Default-Fernbedienung
* HQ RC Univers 29, Geraetecode 335
*/
#ifdef RC_HAVE_HQ_RC_UNIVERS29_335
#define RC5_CODE_PWR (0x100C & RC5_MASK) /*!< Taste An/Aus */
#define RC5_CODE_0 (0x1000 & RC5_MASK) /*!< Taste 0 /10*/
#define RC5_CODE_1 (0x1001 & RC5_MASK) /*!< Taste 1 */
#define RC5_CODE_2 (0x1002 & RC5_MASK) /*!< Taste 2 */
#define RC5_CODE_3 (0x1003 & RC5_MASK) /*!< Taste 3 */
#define RC5_CODE_4 (0x1004 & RC5_MASK) /*!< Taste 4 */
#define RC5_CODE_5 (0x1005 & RC5_MASK) /*!< Taste 5 */
#define RC5_CODE_6 (0x1006 & RC5_MASK) /*!< Taste 6 */
#define RC5_CODE_7 (0x1007 & RC5_MASK) /*!< Taste 7 */
#define RC5_CODE_8 (0x1008 & RC5_MASK) /*!< Taste 8 */
#define RC5_CODE_9 (0x1009 & RC5_MASK) /*!< Taste 9 */
#define RC5_CODE_11 (0x100A & RC5_MASK) /*!< Taste 11 /1-*/
#define RC5_CODE_12 (0x1003 & RC5_MASK) /*!< Taste 12 /2-*/
#define RC5_CODE_GREEN (0x101E & RC5_MASK) /*!< Gruene Taste */
#define RC5_CODE_RED (0x101D & RC5_MASK) /*!< Rote Taste */
#define RC5_CODE_YELLOW (0x1027 & RC5_MASK) /*!< Gelbe Taste */
#define RC5_CODE_BLUE (0x101C & RC5_MASK) /*!< Blaue Taste */
#define RC5_CODE_I_II (0x1023 & RC5_MASK) /*!< I/II-Taste */
#define RC5_CODE_TV_VCR (0x1038 & RC5_MASK) /*!< TV/VCR-Taste */
#define RC5_CODE_DOT (0x1037 & RC5_MASK) /*!< Taste mit rundem Punkt */
#define RC5_CODE_PLAY (0x11B5 & RC5_MASK) /*!< PLAY-Taste */
#define RC5_CODE_STILL (0x1029 & RC5_MASK) /*!< Pause Taste */
#define RC5_CODE_STOP (0x1036 & RC5_MASK) /*!< Pause Taste */
#define RC5_CODE_BWD (0x1032 & RC5_MASK) /*!< Backward Taste */
#define RC5_CODE_FWD (0x1034 & RC5_MASK) /*!< Forward Taste */
#define RC5_CODE_CH_PC (0x100B & RC5_MASK) /*!< CH*P/C Taste */
#define RC5_CODE_MUTE (0x003F & RC5_MASK) /*!< Mute-Taste */
#define RC5_VOL_PLUS (0x1010 & RC5_MASK) /*!< Vol + Taste */
#define RC5_VOL_MINUS (0x1011 & RC5_MASK) /*!< Vol - Taste */
#define RC5_CH_PLUS (0x1020 & RC5_MASK) /*!< Ch + Taste */
#define RC5_CH_MINUS (0x1021 & RC5_MASK) /*!< Ch - Taste */
#define RC5_CODE_UP RC5_CODE_STILL /*!< Taste Hoch */
#define RC5_CODE_DOWN RC5_CODE_STOP /*!< Taste Runter */
#define RC5_CODE_LEFT RC5_CODE_BWD /*!< Taste Links */
#define RC5_CODE_RIGHT RC5_CODE_FWD /*!< Taste Rechts */
#endif
/*!
* Fernbedienung Hauppauge (simple WinTV-Karten Fernbedienung)
*/
#ifdef RC_HAVE_HAUPPAUGE_WINTV
#define RC_HAVE_CODES /*!< Definiert Codes */
#undef JOG_DIAL /*!< Hat keinen Jog Dial */
#define RC5_CODE_0 (0x1000 & RC5_MASK) /*!< Taste 0 */
#define RC5_CODE_1 (0x1001 & RC5_MASK) /*!< Taste 1 */
#define RC5_CODE_2 (0x1002 & RC5_MASK) /*!< Taste 2 */
#define RC5_CODE_3 (0x1003 & RC5_MASK) /*!< Taste 3 */
#define RC5_CODE_4 (0x1004 & RC5_MASK) /*!< Taste 4 */
#define RC5_CODE_5 (0x1005 & RC5_MASK) /*!< Taste 5 */
#define RC5_CODE_6 (0x1006 & RC5_MASK) /*!< Taste 6 */
#define RC5_CODE_7 (0x1007 & RC5_MASK) /*!< Taste 7 */
#define RC5_CODE_8 (0x1008 & RC5_MASK) /*!< Taste 8 */
#define RC5_CODE_9 (0x1009 & RC5_MASK) /*!< Taste 9 */
#define RC5_CODE_PWR (0x1026 & RC5_MASK) /*!< Taste Minimize */
#define RC5_CODE_FULL (0x102E & RC5_MASK) /*!< Taste Full Screen */
#define RC5_CODE_SOURCE (0x1022 & RC5_MASK) /*!< Taste Source */
#define RC5_CODE_UP (0x1020 & RC5_MASK) /*!< Taste CH + */
#define RC5_CODE_DOWN (0x1021 & RC5_MASK) /*!< Taste CH - */
#define RC5_CODE_LEFT (0x1011 & RC5_MASK) /*!< Taste VOL- */
#define RC5_CODE_RIGHT (0x1010 & RC5_MASK) /*!< Taste VOL+ */
#define RC5_CODE_FWD RC5_NOT_AVAIL /*!< Taste nicht vorhanden */
#define RC5_CODE_BWD RC5_NOT_AVAIL /*!< Taste nicht vorhanden */
#define RC5_CODE_RED RC5_NOT_AVAIL /*!< Taste nicht vorhanden */
#define RC5_CODE_GREEN RC5_NOT_AVAIL /*!< Taste nicht vorhanden */
#define RC5_CODE_YELLOW RC5_NOT_AVAIL /*!< Taste nicht vorhanden */
#define RC5_CODE_BLUE RC5_NOT_AVAIL /*!< Taste nicht vorhanden */
#define RC5_CODE_I_II RC5_CODE_SOURCE
#define RC5_CODE_TV_VCR RC5_CODE_FULL
#endif /* RC_HAVE_HAUPPAUGE_WINTV */
#ifdef RC_HAVE_HAUPPAUGE_MediaMPV
#define RC_HAVE_CODES /*!< Definiert Codes */
#undef JOG_DIAL /*!< Hat keinen Jog Dial */
#define RC5_CODE_0 (0x17C0 & RC5_MASK) /*!< Taste 0 */
#define RC5_CODE_1 (0x17C1 & RC5_MASK) /*!< Taste 1 */
#define RC5_CODE_2 (0x17C2 & RC5_MASK) /*!< Taste 2 */
#define RC5_CODE_3 (0x17C3 & RC5_MASK) /*!< Taste 3 */
#define RC5_CODE_4 (0x17C4 & RC5_MASK) /*!< Taste 4 */
#define RC5_CODE_5 (0x17C5 & RC5_MASK) /*!< Taste 5 */
#define RC5_CODE_6 (0x17C6 & RC5_MASK) /*!< Taste 6 */
#define RC5_CODE_7 (0x17C7 & RC5_MASK) /*!< Taste 7 */
#define RC5_CODE_8 (0x17C8 & RC5_MASK) /*!< Taste 8 */
#define RC5_CODE_9 (0x17C9 & RC5_MASK) /*!< Taste 9 */
#define RC5_CODE_SELECT RC5_NOT_AVAIL /*!< Taste Source */
#define RC5_CODE_UP (0x17E0 & RC5_MASK) /*!< Taste CH + */
#define RC5_CODE_DOWN (0x17E1 & RC5_MASK) /*!< Taste CH - */
#define RC5_CODE_LEFT (0x17D1 & RC5_MASK) /*!< Taste VOL- */
#define RC5_CODE_RIGHT (0x17D0 & RC5_MASK) /*!< Taste VOL+ */
#define RC5_CODE_OK (0x17E5 & RC5_MASK) /*!< Taste OK */
#define RC5_CODE_PWR (0x17FD & RC5_MASK) /*!< Taste An/Aus */
#define RC5_CODE_RED (0x17CB & RC5_MASK) /*!< Taste Rot */
#define RC5_CODE_GREEN (0x17EE & RC5_MASK) /*!< Taste Gruen */
#define RC5_CODE_YELLOW (0x17F8 & RC5_MASK) /*!< Taste Gelb */
#define RC5_CODE_BLUE (0x17E9 & RC5_MASK) /*!< Taste Blau */
#define RC5_CODE_FWD (0x17F4 & RC5_MASK) /*!< Taste >> */
#define RC5_CODE_BWD (0x17F2 & RC5_MASK) /*!< Taste << */
#define RC5_CODE_PLAY (0x17F5 & RC5_MASK) /*!< Taste > */
#define RC5_CODE_RECORD (0x17F7 & RC5_MASK) /*!< Taste Aufnahme */
#define RC5_CODE_STOP (0x17F6 & RC5_MASK) /*!< Taste Stop */
#define RC5_CODE_WAIT (0x17F0 & RC5_MASK) /*!< Taste Pause */
#define RC5_CODE_REPLAY (0x17E4 & RC5_MASK) /*!< Taste Anfang |< */
#define RC5_CODE_SKIP (0x17DE & RC5_MASK) /*!< Taste Ende >| */
#define RC5_CODE_MUTE (0x17CF & RC5_MASK) /*!< Taste Mute */
#define RC5_CODE_VIEW (0x17CC & RC5_MASK) /*!< Taste View zwischen Mute und Full */
#define RC5_CODE_FULL (0x17FC & RC5_MASK) /*!< Taste Full */
#define RC5_CODE_BACK (0x17DF & RC5_MASK) /*!< Taste Back/Exit */
#define RC5_CODE_MENU (0x17CD & RC5_MASK) /*!< Taste Menue */
#define RC5_CODE_GO (0x17FB & RC5_MASK) /*!< Taste GO */
#define RC5_CODE_I_II RC5_CODE_SELECT
#define RC5_CODE_TV_VCR RC5_CODE_VIEW
#define RC5_CH_PLUS RC5_CODE_BWD /*!< Taste fuer Transprtfach schliessen */
#define RC5_CH_MINUS RC5_CODE_FWD /*!< Taste fuer Transportfach oeffnen */
#endif /* RC_HAVE_HAUPPAUGE_MediaMPV */
/*!
* Fernbedienung Conrad Promo 8
*/
#ifdef RC_HAVE_CONRAD_PROMO8
#define RC_HAVE_CODES /*!< Definiert Codes */
#undef JOG_DIAL /*!< Hat keinen Jog Dial */
#define RC5_CODE_0 (0x3000 & RC5_MASK) /*!< Taste 0 */
#define RC5_CODE_1 (0x3001 & RC5_MASK) /*!< Taste 1 */
#define RC5_CODE_2 (0x3002 & RC5_MASK) /*!< Taste 2 */
#define RC5_CODE_3 (0x3003 & RC5_MASK) /*!< Taste 3 */
#define RC5_CODE_4 (0x3004 & RC5_MASK) /*!< Taste 4 */
#define RC5_CODE_5 (0x3005 & RC5_MASK) /*!< Taste 5 */
#define RC5_CODE_6 (0x3006 & RC5_MASK) /*!< Taste 6 */
#define RC5_CODE_7 (0x3007 & RC5_MASK) /*!< Taste 7 */
#define RC5_CODE_8 (0x3008 & RC5_MASK) /*!< Taste 8 */
#define RC5_CODE_9 (0x3009 & RC5_MASK) /*!< Taste 9 */
#define RC5_CODE_UP (0x2010 & RC5_MASK) /*!< Taste Hoch */
#define RC5_CODE_DOWN (0x2011 & RC5_MASK) /*!< Taste Runter */
#define RC5_CODE_LEFT (0x2015 & RC5_MASK) /*!< Taste Links */
#define RC5_CODE_RIGHT (0x2016 & RC5_MASK) /*!< Taste Rechts */
#define RC5_CODE_ENTER (0x2017 & RC5_MASK) /*!< Enter-Taste*/
#define RC5_CODE_PWR (0x100C & RC5_MASK) /*!< Enter Taste als Ersatz fuer Taste An/Aus */
#define RC5_CODE_RED (0x202B & RC5_MASK) /*!< Rote Taste */
#define RC5_CODE_GREEN (0x202C & RC5_MASK) /*!< Gruene Taste */
#define RC5_CODE_YELLOW (0x202D & RC5_MASK) /*!< Gelbe Taste */
#define RC5_CODE_BLUE (0x202E & RC5_MASK) /*!< Blaue Taste */
#define RC5_CODE_VIEW (0x2012 & RC5_MASK) /*!< Instant View Taste */
#define RC5_CODE_SELECT (0x300D & RC5_MASK) /*!< Select Taste */
#define RC5_CODE_BWD (0x3011 & RC5_MASK) /*!< Backward Taste */
#define RC5_CODE_FWD (0x3010 & RC5_MASK) /*!< Forward Taste */
#define RC5_CH_PLUS (0x1020 & RC5_MASK) /*!< Ch + Taste */
#define RC5_CH_MINUS (0x1021 & RC5_MASK) /*!< Ch - Taste */
#define RC5_CODE_I_II RC5_CODE_SELECT
#define RC5_CODE_TV_VCR RC5_CODE_VIEW
#endif
/*!
* Fernbedienung VIVANCO UR89, vor Verwendung auf VCR druecken
* @author Andreas Staudenmayer
*/
#ifdef RC_HAVE_VIVANCO_UR89
#define RC_HAVE_CODES /*!< Definiert Codes */
#undef JOG_DIAL /*!< Hat keinen Jog Dial */
#define RC5_CODE_0 (0x1140 & RC5_MASK) /*!< Taste 0 */
#define RC5_CODE_1 (0x1141 & RC5_MASK) /*!< Taste 1 */
#define RC5_CODE_2 (0x1142 & RC5_MASK) /*!< Taste 2 */
#define RC5_CODE_3 (0x1143 & RC5_MASK) /*!< Taste 3 */
#define RC5_CODE_4 (0x1144 & RC5_MASK) /*!< Taste 4 */
#define RC5_CODE_5 (0x1145 & RC5_MASK) /*!< Taste 5 */
#define RC5_CODE_6 (0x1146 & RC5_MASK) /*!< Taste 6 */
#define RC5_CODE_7 (0x1147 & RC5_MASK) /*!< Taste 7 */
#define RC5_CODE_8 (0x1148 & RC5_MASK) /*!< Taste 8 */
#define RC5_CODE_9 (0x1149 & RC5_MASK) /*!< Taste 9 */
#define RC5_CODE_PWR (0x114C & RC5_MASK) /*!< Taste An, Aus */
#define RC5_CODE_VIEW RC5_NOT_AVAIL /*!< Taste nicht vorhanden */
#define RC5_CODE_SELECT RC5_NOT_AVAIL /*!< Taste nicht vorhanden */
#define RC5_CODE_UP (0x1160 & RC5_MASK) /*!< Taste Hoch */
#define RC5_CODE_DOWN (0x1161 & RC5_MASK) /*!< Taste Runter */
#define RC5_CODE_LEFT (0x0171 & RC5_MASK) /*!< Taste Links */
#define RC5_CODE_RIGHT (0x0170 & RC5_MASK) /*!< Taste Rechts */
#define RC5_CODE_FWD RC5_NOT_AVAIL /*!< Taste nicht vorhanden */
#define RC5_CODE_BWD RC5_NOT_AVAIL /*!< Taste nicht vorhanden */
#define RC5_CODE_RED (0x1172 & RC5_MASK) /*!< rote Taste */
#define RC5_CODE_GREEN (0x1176 & RC5_MASK) /*!< gruene Taste */
#define RC5_CODE_YELLOW (0x1175 & RC5_MASK) /*!< gelbe Taste */
#define RC5_CODE_BLUE (0x1174 & RC5_MASK) /*!< blaue Taste */
#define RC5_CODE_I_II RC5_CODE_SELECT
#define RC5_CODE_TV_VCR RC5_CODE_VIEW
#endif /* RC_HAVE_VIVANCO_UR89 */
/*!
* Fernbedienung VIVANCO UR89, TV Modus (Alle Tasten funktionieren)
* vor Verwendung fuer TV den Code 089 auf der Fernbedienung programmieren
* @author Ulrich Scheffler
*/
#ifdef RC_HAVE_VIVANCO_UR89_TV_CODE_089
#define RC_HAVE_CODES /*!< Definiert Codes */
#undef JOG_DIAL /*!< Hat keinen Jog Dial */
#define RC5_NOT_AVAIL (0xFFFF) /*!< Code fuer Taste nicht vorhanden */
/* Jede Taste bekommt erstmal die Bezeichnung, die aufgedruckt ist */
#define RC5_CODE_PWR (0x100C & RC5_MASK) /*!< Taste An/Aus-Symbol (rot)*/
#define RC5_CODE_MUTE (0x100D & RC5_MASK) /*!< Taste Mute-Symbol (gruen) */
#define RC5_CODE_CH_PLUS (0x1020 & RC5_MASK) /*!< Taste CH + (blau) */
#define RC5_CODE_CH_MINUS (0x1021 & RC5_MASK) /*!< Taste CH - (blau) */
#define RC5_CODE_VOL_MINUS (0x1011 & RC5_MASK) /*!< Taste VOL - (blau) */
#define RC5_CODE_VOL_PLUS (0x1010 & RC5_MASK) /*!< Taste VOL + (blau) */
#define RC5_CODE_BOX_WITH_DOT (0x0017 & RC5_MASK) /*!< Taste Quadrat mit Punkt */
#define RC5_CODE_TV_VCR (0x1038 & RC5_MASK) /*!< Taste TV/VCR (gleicher Code wie Taste A.B) */
#define RC5_CODE_0 (0x1000 & RC5_MASK) /*!< Taste 0 */
#define RC5_CODE_1 (0x1001 & RC5_MASK) /*!< Taste 1 */
#define RC5_CODE_2 (0x1002 & RC5_MASK) /*!< Taste 2 */
#define RC5_CODE_3 (0x1003 & RC5_MASK) /*!< Taste 3 */
#define RC5_CODE_4 (0x1004 & RC5_MASK) /*!< Taste 4 */
#define RC5_CODE_5 (0x1005 & RC5_MASK) /*!< Taste 5 */
#define RC5_CODE_6 (0x1006 & RC5_MASK) /*!< Taste 6 */
#define RC5_CODE_7 (0x1007 & RC5_MASK) /*!< Taste 7 */
#define RC5_CODE_8 (0x1008 & RC5_MASK) /*!< Taste 8 */
#define RC5_CODE_9 (0x1009 & RC5_MASK) /*!< Taste 9 */
#define RC5_CODE_RETURN (0x1022 & RC5_MASK) /*!< Taste Return-Symbol (gleicher Code wie Taste EXIT) */
#define RC5_CODE_A_DOT_B (0x1038 & RC5_MASK) /*!< Taste A.B (gleicher Code wie Taste TV/VCR) */
#define RC5_CODE_WAIT (0x002F & RC5_MASK) /*!< Taste Pause-Symbol */
#define RC5_CODE_GREEN (0x002C & RC5_MASK) /*!< Taste Gruen & Stop-Symbol */
#define RC5_CODE_RECORD (0x102E & RC5_MASK) /*!< Taste Aufnahme-Symbol */
#define RC5_CODE_BOX (0x103F & RC5_MASK) /*!< Taste Quadrat */
#define RC5_CODE_RED (0x002B & RC5_MASK) /*!< Taste Rot & << */
#define RC5_CODE_YELLOW (0x002D & RC5_MASK) /*!< Taste Gelb & > */
#define RC5_CODE_BLUE (0x002E & RC5_MASK) /*!< Taste Blau & >> */
#define RC5_CODE_BOX_WITH_3_EQUAL_LINES (0x103C & RC5_MASK) /*!< Taste Quadrat mit 3 gleichlangen Linien */
#define RC5_CODE_GREEN_UP (0x0010 & RC5_MASK) /*!< Taste hoch (gruen) */
#define RC5_CODE_GREEN_LEFT (0x0015 & RC5_MASK) /*!< Taste links (gruen) */
#define RC5_CODE_GREEN_RIGHT (0x0016 & RC5_MASK) /*!< Taste rechts (gruen) */
#define RC5_CODE_GREEN_DOWN (0x0011 & RC5_MASK) /*!< Taste runter (gruen) */
#define RC5_CODE_BOX_WITH_BOX (0x1029 & RC5_MASK) /*!< Taste Quadrat mit innerem Rechteck und Pfeilen */
#define RC5_CODE_BOX_WITH_3_UNEQUAL_LINES (0x102E & RC5_MASK) /*!< Taste Quadrat mit 3 ungleichlangen Linien */
#define RC5_CODE_OK (0x1023 & RC5_MASK) /*!< Taste OK (gruen) */
#define RC5_CODE_MENU (0x0012 & RC5_MASK) /*!< Taste MENU */
#define RC5_CODE_EXIT (0x1022 & RC5_MASK) /*!< Taste EXIT (gleicher Code wie Taste Return) */
/* Vorhandene Tasten werden hier mit der Wunsch-Funktion belegt (Umwidmung)*/
#define RC5_CODE_UP RC5_CODE_CH_PLUS /*!< Taste CH + wird genutzt fuer UP-Funktion */
#define RC5_CODE_DOWN RC5_CODE_CH_MINUS /*!< Taste CH - wird genutzt fuer DOWN-Funktion */
#define RC5_CODE_LEFT RC5_CODE_VOL_MINUS /*!< Taste VOL - wird genutzt fuer LEFT-Funktion */
#define RC5_CODE_RIGHT RC5_CODE_VOL_PLUS /*!< Taste VOL + wird genutzt fuer RIGHT-Funktion */
#define RC5_CODE_VIEW RC5_CODE_TV_VCR /*!< Taste TV/VCR & A.B werden genutzt fuer VIEW-Funktion*/
#define RC5_CODE_SELECT RC5_CODE_RETURN /*!< Taste Return & Exit werden genutzt fuer SELECT-Funktion */
#define RC5_CODE_BWD RC5_CODE_GREEN_LEFT /*!< Taste links (gruen) wird genutzt fuer BWD-Funktion (backward)*/
#define RC5_CODE_FWD RC5_CODE_GREEN_RIGHT /*!< Taste rechts (gruen) wird genutzt fuer FWD-Funktion (forward)*/
#define RC5_CODE_I_II RC5_CODE_SELECT
#define RC5_CODE_TV_VCR RC5_CODE_VIEW
#endif /* RC_HAVE_VIVANCO_UR89_TV_CODE_089 */
/*!
* Fernbedienung Technisat_TTS35AI (Receiver Digit CIP)
* @author Joerg Bullmann
*/
#ifdef RC_HAVE_Technisat_TTS35AI
#define RC_HAVE_CODES /*!< Definiert Codes */
#undef JOG_DIAL /*!< Hat keinen Jog Dial */
#define RC5_NOT_AVAIL (0xFFFF) /*!< Code fuer Taste nicht vorhanden */
#define RC5_CODE_0 (0x1289 & RC5_MASK) /*!< Taste 0 */
#define RC5_CODE_1 (0x1281 & RC5_MASK) /*!< Taste 1 */
#define RC5_CODE_2 (0x1282 & RC5_MASK) /*!< Taste 2 */
#define RC5_CODE_3 (0x1283 & RC5_MASK) /*!< Taste 3 */
#define RC5_CODE_4 (0x1284 & RC5_MASK) /*!< Taste 4 */
#define RC5_CODE_5 (0x1285 & RC5_MASK) /*!< Taste 5 */
#define RC5_CODE_6 (0x1286 & RC5_MASK) /*!< Taste 6 */
#define RC5_CODE_7 (0x1287 & RC5_MASK) /*!< Taste 7 */
#define RC5_CODE_8 (0x1288 & RC5_MASK) /*!< Taste 8 */
#define RC5_CODE_9 (0x1289 & RC5_MASK) /*!< Taste 9 */
#define RC5_CODE_PWR (0x128C & RC5_MASK) /*!< Taste An, Aus */
#define RC5_CODE_INFO (0x028F & RC5_MASK) /*!< Taste i */
#define RC5_CODE_OK (0x0297 & RC5_MASK) /*!< Taste ok */
#define RC5_CODE_UP (0x12A0 & RC5_MASK) /*!< Taste Hoch */
#define RC5_CODE_DOWN (0x12A1 & RC5_MASK) /*!< Taste Runter */
#define RC5_CODE_LEFT (0x1291 & RC5_MASK) /*!< Taste Links */
#define RC5_CODE_RIGHT (0x1290 & RC5_MASK) /*!< Taste Rechts */
#define RC5_CODE_TV (0x0293 & RC5_MASK) /*!< Taste TV */
#define RC5_CODE_MENU (0x0292 & RC5_MASK) /*!< Taste Menu */
#define RC5_CODE_RED (0x02AB & RC5_MASK) /*!< rote Taste */
#define RC5_CODE_GREEN (0x02AC & RC5_MASK) /*!< gruene Taste */
#define RC5_CODE_YELLOW (0x02AD & RC5_MASK) /*!< gelbe Taste */
#define RC5_CODE_BLUE (0x02AE & RC5_MASK) /*!< blaue Taste */
#define RC5_CODE_FWD RC5_CODE_TV /*!< Taste TV - umgewidmet als FWD-Taste */
#define RC5_CODE_BWD RC5_CODE_MENU /*!< Taste Menu - umgewidmet als BWD-Taste */
#define RC5_CODE_TV_VCR RC5_CODE_INFO /*!< Taste INFO - umgewidmet als View-Taste */
#define RC5_CODE_I_II RC5_CODE_OK /*!< Taste OK - umgewidmet als Select-Taste */
#endif /* RC_HAVE_Technisat_TTS35AI */
/*!
* Fernbedienung Lifetec LT3607 (aeltere, lernfaehige Medion-Fernbedienung)
*/
#ifdef RC_HAVE_LIFETEC_LT3607
#define RC_HAVE_CODES /*!< Definiert Codes */
#undef JOG_DIAL /*!< Hat keinen Jog Dial */
#define RC5_MASK (RC5_COMMAND)
#define RC5_NOT_AVAIL (0xFFFF) /*!< Code fuer Taste nicht vorhanden */
#define RC5_CODE_0 (0x3000 & RC5_MASK) /*!< Taste 0 */
#define RC5_CODE_1 (0x3001 & RC5_MASK) /*!< Taste 1 */
#define RC5_CODE_2 (0x3002 & RC5_MASK) /*!< Taste 2 */
#define RC5_CODE_3 (0x3003 & RC5_MASK) /*!< Taste 3 */
#define RC5_CODE_4 (0x3004 & RC5_MASK) /*!< Taste 4 */
#define RC5_CODE_5 (0x3005 & RC5_MASK) /*!< Taste 5 */
#define RC5_CODE_6 (0x3006 & RC5_MASK) /*!< Taste 6 */
#define RC5_CODE_7 (0x3007 & RC5_MASK) /*!< Taste 7 */
#define RC5_CODE_8 (0x3008 & RC5_MASK) /*!< Taste 8 */
#define RC5_CODE_9 (0x3009 & RC5_MASK) /*!< Taste 9 */
#define RC5_CODE_PWR (0x300C & RC5_MASK) /*!< Taste Power */
#define RC5_CODE_VIEW (0x303F & RC5_MASK) /*!< Taste OSD */
#define RC5_CODE_SELECT (0x303C & RC5_MASK) /*!< Taste Videotext */
#define RC5_CH_PLUS (0x3020 & RC5_MASK) /*!< Ch + Taste */
#define RC5_CH_MINUS (0x3021 & RC5_MASK) /*!< Ch - Taste */
#define RC5_CODE_UP (0x3020 & RC5_MASK) /*!< Taste CH + */
#define RC5_CODE_DOWN (0x3021 & RC5_MASK) /*!< Taste CH - */
#define RC5_CODE_LEFT (0x3011 & RC5_MASK) /*!< Taste VOL- */
#define RC5_CODE_RIGHT (0x3010 & RC5_MASK) /*!< Taste VOL+ */
#define RC5_CODE_I_II (0x3038 & RC5_MASK) /*!< A/B-Taste */
#define RC5_CODE_FWD (0x302B & RC5_MASK) /*!< Taste Mischbild */
#define RC5_CODE_BWD (0x302E & RC5_MASK) /*!< Taste Ueberblenden */
#define RC5_CODE_RED (0x3037 & RC5_MASK) /*!< Taste FRWD / Rot */
#define RC5_CODE_GREEN (0x3036 & RC5_MASK) /*!< Taste STOP / Gruen */
#define RC5_CODE_YELLOW (0x3032 & RC5_MASK) /*!< Taste PLAY / Gelb */
#define RC5_CODE_BLUE (0x3034 & RC5_MASK) /*!< Taste FFWD / Blau */
#define RC5_CODE_TV_VCR RC5_NOT_AVAIL
#endif /* RC_HAVE_LIFETEC_LT3607 */
/*!
* Default-Philips-Fernbedienung mit Jog-Dial-Rad
*/
#ifdef RC_HAVE_DEFAULT /*!< Default RC5-Codes falls keine FB definiert wurde */
#undef JOG_DIAL
#define RC5_CODE_0 (0x3940 & RC5_MASK) /*!< Taste 0 */
#define RC5_CODE_1 (0x3941 & RC5_MASK) /*!< Taste 1 */
#define RC5_CODE_2 (0x3942 & RC5_MASK) /*!< Taste 2 */
#define RC5_CODE_3 (0x3943 & RC5_MASK) /*!< Taste 3 */
#define RC5_CODE_4 (0x3944 & RC5_MASK) /*!< Taste 4 */
#define RC5_CODE_5 (0x3945 & RC5_MASK) /*!< Taste 5 */
#define RC5_CODE_6 (0x3946 & RC5_MASK) /*!< Taste 6 */
#define RC5_CODE_7 (0x3947 & RC5_MASK) /*!< Taste 7 */
#define RC5_CODE_8 (0x3948 & RC5_MASK) /*!< Taste 8 */
#define RC5_CODE_9 (0x3949 & RC5_MASK) /*!< Taste 9 */
#define RC5_CODE_UP (0x2950 & RC5_MASK) /*!< Taste Hoch */
#define RC5_CODE_DOWN (0x2951 & RC5_MASK) /*!< Taste Runter */
#define RC5_CODE_LEFT (0x2955 & RC5_MASK) /*!< Taste Links */
#define RC5_CODE_RIGHT (0x2956 & RC5_MASK) /*!< Taste Rechts */
#define RC5_CODE_PWR (0x394C & RC5_MASK) /*!< Taste An/Aus */
#define RC5_CODE_RED (0x100B & RC5_MASK) /*!< Rote Taste */
#define RC5_CODE_GREEN (0x102E & RC5_MASK) /*!< Gruene Taste */
#define RC5_CODE_YELLOW (0x1038 & RC5_MASK) /*!< Gelbe Taste */
#define RC5_CODE_BLUE (0x1029 & RC5_MASK) /*!< Blaue Taste */
#define RC5_CODE_VIEW (0x000F & RC5_MASK) /*!< Instant View Taste */
#define RC5_CODE_SELECT (0x100B & RC5_MASK) /*!< Select Taste */
#define RC5_CODE_BWD (0x1025 & RC5_MASK) /*!< Backward Taste */
#define RC5_CODE_FWD (0x1026 & RC5_MASK) /*!< Forward Taste */
#define RC5_CODE_I_II RC5_CODE_SELECT
#define RC5_CODE_TV_VCR RC5_CODE_VIEW
#define RC5_CH_PLUS RC5_NOT_AVAIL /*!< Ch + Taste */
#define RC5_CH_MINUS RC5_NOT_AVAIL /*!< Ch - Taste */
#ifdef JOG_DIAL
/* Jogdial geht nur inkl. Adresscode */
#undef RC5_MASK
#define RC5_MASK (RC5_COMMAND | RC5_ADDRESS)
#define RC5_CODE_JOG_MID (0x3969 & RC5_MASK) /*!< Taste Jog-Dial Mitte */
#define RC5_CODE_JOG_L1 (0x3962 & RC5_MASK) /*!< Taste Jog-Dial Links 1 */
#define RC5_CODE_JOG_L2 (0x396F & RC5_MASK) /*!< Taste Jog-Dial Links 2 */
#define RC5_CODE_JOG_L3 (0x395F & RC5_MASK) /*!< Taste Jog-Dial Links 3 */
#define RC5_CODE_JOG_L4 (0x3A6C & RC5_MASK) /*!< Taste Jog-Dial Links 4 */
#define RC5_CODE_JOG_L5 (0x3A6B & RC5_MASK) /*!< Taste Jog-Dial Links 5 */
#define RC5_CODE_JOG_L6 (0x396C & RC5_MASK) /*!< Taste Jog-Dial Links 6 */
#define RC5_CODE_JOG_L7 (0x3A6A & RC5_MASK) /*!< Taste Jog-Dial Links 7 */
#define RC5_CODE_JOG_R1 (0x3968 & RC5_MASK) /*!< Taste Jog-Dial Rechts 1 */
#define RC5_CODE_JOG_R2 (0x3975 & RC5_MASK) /*!< Taste Jog-Dial Rechts 2 */
#define RC5_CODE_JOG_R3 (0x396A & RC5_MASK) /*!< Taste Jog-Dial Rechts 3 */
#define RC5_CODE_JOG_R4 (0x3A6D & RC5_MASK) /*!< Taste Jog-Dial Rechts 4 */
#define RC5_CODE_JOG_R5 (0x3A6E & RC5_MASK) /*!< Taste Jog-Dial Rechts 5 */
#define RC5_CODE_JOG_R6 (0x396E & RC5_MASK) /*!< Taste Jog-Dial Rechts 6 */
#define RC5_CODE_JOG_R7 (0x3A6F & RC5_MASK) /*!< Taste Jog-Dial Rechts 7 */
#endif /* JOG_DIAL */
#endif /* !RC_HAVE_CODES */
#endif /* RC5CODE_H_ */

View file

@ -0,0 +1,33 @@
/*
* 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 rc5.h
* @brief RC5-Fernbedienung
* @author Benjamin Benz (bbe@heise.de)
* @date 26.12.05
*/
#ifndef rc5_H_
#define rc5_H_
/*!
* Liest ein RC5-Codeword und wertet es aus
*/
void rc5_control(void);
#endif

View file

@ -0,0 +1,44 @@
/*
* 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 sensor-low.h
* @brief Low-Level Routinen fuer die Sensor-Steuerung des c't-Bots
* @author Benjamin Benz (bbe@heise.de)
* @date 01.12.05
*/
#ifndef sens_low_H_
#define sens_low_H_
/*!
* Initialisiere alle Sensoren
*/
extern void bot_sens_init(void);
/*!
* Alle Sensoren aktualisieren
*/
extern void bot_sens_isr(void);
/*!
* Kuemmert sich um die Radencoder
* Das muss schneller gehen als die anderen Sensoren,
* daher Update per ISR
*/
extern void bot_encoder_isr(void);
#endif

View file

@ -0,0 +1,111 @@
/*
* 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 sensor.h
* @brief Architekturunabhaengiger Teil der Sensorsteuerung
* @author Benjamin Benz (bbe@heise.de)
* @date 15.01.05
*/
#ifndef SENSOR_H_
#define SENSOR_H_
#include "global.h"
#include "ct-Bot.h"
/* Analoge Sensoren: Der Wertebereich aller analogen Sensoren umfasst 10 Bit. Also 0 bis 1023 */
extern int16 sensDistL; /*!< Distanz linker IR-Sensor [mm] ca. 100 bis 800 */
extern int16 sensDistR; /*!< Distanz rechter IR-Sensor [mm] ca. 100 bis 800 */
extern int16 sensLDRL; /*!< Lichtsensor links [0-1023]; 1023 = dunkel*/
extern int16 sensLDRR; /*!< Lichtsensor rechts [0-1023]; 1023 = dunkel*/
extern int16 sensBorderL; /*!< Abgrundsensor links [0-1023]; 1023 = dunkel*/
extern int16 sensBorderR; /*!< Abgrundsensor rechts [0-1023]; 1023 = dunkel*/
extern int16 sensLineL; /*!< Lininensensor links [0-1023]; 1023 = dunkel*/
extern int16 sensLineR; /*!< Lininensensor rechts [0-1023]; 1023 = dunkel*/
/* digitale Sensoren */
extern volatile int16 sensEncL; /*!< Encoder linker Motor [-32768 bis 32767] */
extern volatile int16 sensEncR; /*!< Encoder rechter Motor [-32768 bis 32767] */
extern uint8 sensTrans; /*!< Sensor Ueberwachung Transportfach [0/1]*/
extern uint8 sensDoor; /*!< Sensor Ueberwachung Klappe [0/1] */
extern uint8 sensError; /*!< Ueberwachung Motor oder Batteriefehler [0/1] 1= alles ok */
extern uint16 RC5_Code; /*!< Letzter empfangener RC5-Code */
#ifdef MAUS_AVAILABLE
extern int8 sensMouseDX; /*!< Maussensor Delta X, positive Werte zeigen querab der Fahrtrichtung nach rechts */
extern int8 sensMouseDY; /*!< Maussensor Delta Y, positive Werte zeigen in Fahrtrichtung */
extern int16 sensMouseX; /*!< Mausposition X, positive Werte zeigen querab der Fahrtrichtung nach rechts */
extern int16 sensMouseY; /*!< Mausposition Y, positive Werte zeigen in Fahrtrichtung */
#endif
extern float heading_enc; /*!< Blickrichtung aus Encodern */
extern float x_enc; /*!< X-Koordinate aus Encodern [mm] */
extern float y_enc; /*!< Y-Koordinate aus Encodern [mm] */
extern float v_enc_left; /*!< Abrollgeschwindigkeit des linken Rades in [mm/s] [-128 bis 127] relaisitisch [-50 bis 50] */
extern float v_enc_right; /*!< Abrollgeschwindigkeit des linken Rades in [mm/s] [-128 bis 127] relaisitisch [-50 bis 50] */
extern float v_enc_center; /*!< Schnittgeschwindigkeit ueber beide Raeder */
#ifdef PC
extern uint16 simultime; /*! Simulierte Zeit */
#endif
#ifdef MEASURE_MOUSE_AVAILABLE
extern float heading_mou; /*!< Aktuelle Blickrichtung relativ zur Startposition aus Mausmessungen */
extern float x_mou; /*!< Aktuelle X-Koordinate in mm relativ zur Startposition aus Mausmessungen */
extern float y_mou; /*!< Aktuelle Y-Koordinate in mm relativ zur Startposition aus Mausmessungen */
extern float v_mou_center; /*!< Geschwindigkeit in mm/s ausschliesslich aus den Maussensorwerten berechnet */
extern float v_mou_left; /*!< ...aufgeteilt auf linkes Rad */
extern float v_mou_right; /*!< ...aufgeteilt auf rechtes Rad */
#endif
extern float heading; /*!< Aktuelle Blickrichtung aus Encoder-, Maus- oder gekoppelten Werten */
extern float x_pos; /*!< Aktuelle X-Position aus Encoder-, Maus- oder gekoppelten Werten */
extern float y_pos; /*!< Aktuelle Y-Position aus Encoder-, Maus- oder gekoppelten Werten */
extern float v_left; /*!< Geschwindigkeit linkes Rad aus Encoder-, Maus- oder gekoppelten Werten */
extern float v_right; /*!< Geschwindigkeit rechtes Rad aus Encoder-, Maus- oder gekoppelten Werten */
extern float v_center; /*!< Geschwindigkeit im Zentrum des Bots aus Encoder-, Maus- oder gekoppelten Werten */
extern int8 sensors_initialized; /*!< Wird 1 sobald die Sensorwerte zur Verfügung stehen */
#ifdef SRF10_AVAILABLE
extern uint16 sensSRF10; /*!< Messergebniss Ultraschallsensor */
#endif
/*! Sensor_update
* Kümmert sich um die Weiterverarbeitung der rohen Sensordaten
*/
void sensor_update(void);
/*! Linearisiert die Sensorwerte
* @param left Linker Rohwert [0-1023]
* @param right Rechter Rohwert [0-1023]
*/
void sensor_abstand(uint16 left, uint16 right);
#endif /*SENSOR_H_*/

View file

@ -0,0 +1,39 @@
/*
* 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 sensor_correction.h
* @brief Konstanten, um die Sensoren zu linearisieren
* @author Benjamin Benz (bbe@heise.de)
* @date 17.02.06
*/
#ifndef SENSOR_CORRECTION_H_
#define SENSOR_CORRECTION_H_
#define SENSDISTSLOPELEFT 47478 /*!< Stuetzwert a fuer Linearisierung des linken Distanzsensors */
#define SENSDISTOFFSETLEFT 50 /*!< Stuetzwert b fuer Linearisierung des linken Distanzsensors */
#define SENSDISTSLOPERIGHT 54333 /*!< Stuetzwert a fuer Linearisierung des rechten Distanzsensors */
#define SENSDISTOFFSETRIGHT 9 /*!< Stuetzwert b fuer Linearisierung des rechten Distanzsensors */
/* Parameter fuer die IR-Sensoren*/
#define SENS_IR_MAX_DIST 750 /*!< Obergrenze des Erfassungsbereichs */
#define SENS_IR_INFINITE 999 /*!< Kennzeichnung fuer "kein Objekt im Erfassungsbereich" */
#endif /*SENSOR_CORRECTION_H_*/

View file

@ -0,0 +1,63 @@
/*
* 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 shift.h
* @brief Routinen zur Ansteuerung der Shift-Register
* @author Benjamin Benz (bbe@heise.de)
* @date 20.12.05
*/
#ifndef SHIFT_H_
#define SHIFT_H_
#define SHIFT_LATCH (1<<1) /*!< Clock to store Data into shiftregister */
#define SHIFT_REGISTER_DISPLAY 0x04 /*!< Port-Pin for shiftregister latch (display) */
#define SHIFT_REGISTER_LED 0x10 /*!< Port-Pin for shiftregister latch (leds) */
#define SHIFT_REGISTER_ENA 0x08 /*!< Port-Pin for shiftregister latch (enable) */
/*!
* Initialisert die Shift-Register
*/
void shift_init(void);
/*!
* Schiebt Daten durch eines der drei 74HC595-Schieberegister
* Achtung: den Port sollte man danach noch per shift_clear() zuruecksetzen!
* @param data Das Datenbyte
* @param latch_data der Pin, an dem der Daten-latch-Pin des Registers (PIN 11) haengt
* @param latch_store der Pin, an dem der latch-Pin zum Transfer des Registers (PIN 12) haengt
*/
void shift_data_out(uint8 data, uint8 latch_data, uint8 latch_store);
/*!
* Schiebt Daten durch eines der drei 74HC595-Schieberegister,
* vereinfachte Version, braucht kein shift_clear().
* Funktioniert NICHT fuer das Shift-Register, an dem das Display haengt!!!
* @param data Das Datenbyte
* @param latch_data der Pin, an dem der Daten-latch-Pin des Registers (PIN 11) haengt
*/
void shift_data(uint8 data, uint8 latch_data);
/*!
* Setzt die Shift-Register wieder zurueck
*/
void shift_clear(void);
#endif

View file

@ -0,0 +1,105 @@
/*
* 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 srf10.h
* @brief Ansteuerung des Ultraschall Entfernungssensors SRF10
* @author Chris efstathiou (hendrix@otenet.gr) & Carsten Giesen (info@cnau.de)
* @date 08.04.06
*/
#include "global.h"
#ifndef srf10_H
#define srf10_H 1
/*!
* Es sind alle moeglichen Adressen eingetragen. In de Regel reicht aber die erste
* Der Code geht nur von SRF10_UNIT_0 aus, daher sind die anderen auskommentiert
*/
#define SRF10_UNIT_0 0xE0 /* the SRF10 MODULE I2C address */
//#define SRF10_UNIT_1 0xE2 /* the SRF10 MODULE I2C address */
//#define SRF10_UNIT_2 0xE4 /* the SRF10 MODULE I2C address */
//#define SRF10_UNIT_3 0xE6 /* the SRF10 MODULE I2C address */
//#define SRF10_UNIT_4 0xE8 /* the SRF10 MODULE I2C address */
//#define SRF10_UNIT_5 0xEA /* the SRF10 MODULE I2C address */
//#define SRF10_UNIT_6 0xEC /* the SRF10 MODULE I2C address */
//#define SRF10_UNIT_7 0xEE /* the SRF10 MODULE I2C address */
//#define SRF10_UNIT_8 0xF0 /* the SRF10 MODULE I2C address */
//#define SRF10_UNIT_9 0xF2 /* the SRF10 MODULE I2C address */
//#define SRF10_UNIT_10 0xF4 /* the SRF10 MODULE I2C address */
//#define SRF10_UNIT_11 0xF6 /* the SRF10 MODULE I2C address */
//#define SRF10_UNIT_12 0xF8 /* the SRF10 MODULE I2C address */
//#define SRF10_UNIT_13 0xFA /* the SRF10 MODULE I2C address */
//#define SRF10_UNIT_14 0xFC /* the SRF10 MODULE I2C address */
//#define SRF10_UNIT_15 0xFE /* the SRF10 MODULE I2C address */
#define SRF10_MIN_GAIN 0 /*!< setze Verstaerung auf 40 */
#define SRF10_MAX_GAIN 16 /*!< setze Verstaerung auf 700 */
#define SRF10_MIN_RANGE 0 /*!< Minimale Reichweite 43mm */
#define SRF10_MAX_RANGE 5977 /*!< Maximale Reichweite 5977mm */
#define SRF10_INCHES 0X50 /*!< Messung in INCHES */
#define SRF10_CENTIMETERS 0X51 /*!< Messung in CM */
#define SRF10_MICROSECONDS 0X52 /*!< Messung in Millisekunden */
#define SRF10_COMMAND 0 /*!< W=Befehls-Register R=Firmware*/
#define SRF10_LIGHT 1 /*!< W=Verstaerkungsfaktor R=Nicht benutzt */
#define SRF10_HIB 2 /*!< W=Reichweite R=Messung High-Byte */
#define SRF10_LOB 3 /*!< W=Nicht benutzt R=Messung Low-Byte */
/*!
* SRF10 initialsieren
*/
extern void srf10_init(void);
/*!
* Verstaerkungsfaktor setzen
* @param gain Verstaerkungsfaktor
*/
extern void srf10_set_gain(uint8 gain);
/*!
* Reichweite setzen, hat auch Einfluss auf die Messdauer
* @param millimeters Reichweite in mm
*/
extern void srf10_set_range(uint16 millimeters);
/*!
* Messung ausloesen
* @param metric_unit 0x50 in Zoll, 0x51 in cm, 0x52 ms
* @return Resultat der Aktion
*/
extern uint8 srf10_ping(uint8 metric_unit);
/*!
* Register auslesen
* @param srf10_register welches Register soll ausgelsen werden
* @return Inhalt des Registers
*/
extern uint8 srf10_read_register(uint8 SRF10_register);
/*!
* Messung starten Ergebniss aufbereiten und zurueckgeben
* @return Messergebniss
*/
extern uint16 srf10_get_measure(void);
#endif /* #ifndef SRF10_H */

View file

@ -0,0 +1,49 @@
/*
* 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 tcp-server.h
* @brief Demo-TCP-Server
* @author Benjamin Benz (bbe@heise.de)
* @date 26.12.05
*/
#ifndef TCP_SERVER_H_
#define TCP_SERVER_H_
/*!
* Init TCP-Server
*/
void tcp_server_init(void);
/*!
* Hauptschleife des TCP-Servers
*/
int tcp_server_run (int runs);
/*!
* Init TCP-test-Client
*/
void tcp_test_client_init(void);
/*!
* Hauptschleife des TCP-Test-Clienzs
*/
int tcp_test_client_run (int runs);
#endif

View file

@ -0,0 +1,92 @@
/*
* 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 tcp.h
* @brief TCP/IP-Kommunikation
* @author Benjamin Benz (bbe@heise.de)
* @date 26.12.05
*/
#ifndef TCP_H_
#define TCP_H_
#if defined WIN32
#define LITTLE_ENDIAN 1234
#define BIG_ENDIAN 4321
#define BYTE_ORDER LITTLE_ENDIAN
#elif defined __linux__
#include <endian.h>
#else
#include <machine/endian.h>
#endif
#include "bot-2-sim.h"
#include "command.h"
#define IP "localhost" /*!< IP, mit der verbunden werden soll (normalerweise localhost) */
//#define IP "10.10.22.242"
#define PORT 10001 /*!< Port, mit dem verbunden werden soll */
extern int tcp_sock; /*!< Unser TCP-Socket */
extern char *tcp_hostname; /*!< Hostname, auf dem ct-Sim laeuft */
/*!
* Sende Kommando per TCP/IP im Little Endian
* @param cmd Zeiger auf das Kommando
* @return Anzahl der gesendete Bytes
*/
int tcp_send_cmd(command_t *cmd);
/*!
* Uebertrage Daten per TCP/IP
* @param data Zeiger auf die Daten
* @param length Anzahl der Bytes
* @return Anzahl der uebertragenen Bytes
*/
int tcp_write(void* data, int length);
/*!
* Lese Daten von TCP/IP-Verbindung.
* Achtung: blockierend!
* @param data Zeiger auf die Daten
* @param length Anzahl der gewuenschten Bytes
* @return Anzahl der uebertragenen Bytes
*/
int tcp_read(void* data, int length);
/*!
* Oeffnet eine TCP-Verbindung zum Server
* @param hostname Symbolischer Name des Host, auf dem ct-Sim laeuft
* @return Der Socket
*/
int tcp_openConnection(const char *hostname);
/*!
* Initialisiere TCP/IP Verbindung
*/
void tcp_init(void);
/*!
* Schreibt den Sendepuffer auf einen Schlag raus
* @return -1 bei Fehlern, sonst zahl der uebertragenen Bytes
*/
int flushSendBuffer(void);
#endif

View file

@ -0,0 +1,102 @@
/*
* 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 timer.h
* @brief Timer und Zaehler
* @author Benjamin Benz (bbe@heise.de)
* @date 26.12.05
*/
#ifndef TIMER_H_
#define TIMER_H_
#include "ct-Bot.h"
/*!
* Makros zur Umrechnung von Ticks in ms und zurueck
* (ms / ticks evtl. nach uint32 casten, fuer grosse Werte)
*/
#define TICKS_TO_MS(ticks) ((ticks)*(TIMER_STEPS/8)/(1000/8))
#define MS_TO_TICKS(ms) ((ms)*(1000/8)/(TIMER_STEPS/8))
#ifdef TIME_AVAILABLE
/*!
* Diese Funktion liefert den Millisekundenanteil der Systemzeit zurueck.
* @return uint16
*/
uint16 timer_get_ms(void);
/*!
* Diese Funktion liefert den Sekundenanteil der Systemzeit zurueck.
* @return uint16
*/
uint16 timer_get_s(void);
/*!
* Liefert die Millisekunden zurueck, die seit old_s, old_ms verstrichen sind
* @param old_s alter Sekundenstand
* @param old_ms alter Millisekundenstand
*/
uint16 timer_get_ms_since(uint16 old_s, uint16 old_ms);
#endif // TIME_AVAILABLE
#ifdef PC
/*!
* Funktion, die die TickCounts um die vergangene Simulzeit erhoeht
*/
void system_time_isr(void);
/*!< liefert Ticks seit Systemstart [176 us] */
inline uint16 timer_get_tickCount16(void);
inline uint32 timer_get_tickCount32(void);
#define TIMER_GET_TICKCOUNT_8 (uint8)timer_get_tickCount16()
#define TIMER_GET_TICKCOUNT_16 timer_get_tickCount16()
#define TIMER_GET_TICKCOUNT_32 timer_get_tickCount32()
#else
typedef union{
uint32 u32;
uint16 u16;
uint8 u8;
} tickCount_t;
extern volatile tickCount_t tickCount;
#define TIMER_GET_TICKCOUNT_8 tickCount.u8
#define TIMER_GET_TICKCOUNT_16 tickCount.u16
#define TIMER_GET_TICKCOUNT_32 tickCount.u32
#endif
// Die Werte fuer TIMER_X_CLOCK sind Angaben in Hz
/*!
* Frequenz von Timer 2 in Hz
*/
#define TIMER_2_CLOCK 5619 // Derzeit genutzt fuer RC5-Dekodierung
/*!
* Mikrosekunden, die zwischen zwei Timer-Aufrufen liegen
*/
// #define TIMER_STEPS (1 000 000/TIMER_2_CLOCK)
#define TIMER_STEPS 176
/*!
* Initialisiert Timer 2 und startet ihn
*/
void timer_2_init(void);
#endif

View file

@ -0,0 +1,75 @@
/*
* 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 uart.h
* @brief Routinen zur seriellen Kommunikation
* @author Benjamin Benz (bbe@heise.de)
* @date 26.12.05
*/
#ifndef UART_H_
#define UART_H_
#include "command.h"
//extern char uart_timeout; /*!< 0, wenn uart_read/uart_send erfolgreich; 1, wenn timeout erreicht */
/*!
* Initialisiere UART
*/
void uart_init(void);
/*!
* Prüft, ob daten verfügbar
* @return Anzahl der verfuegbaren Bytes
*/
uint8 uart_data_available(void);
/*!
* Überträgt ein Zeichen per UART
* Achtung ist noch blockierend!!!!
* TODO: umstellen auf nicht blockierend und mehr als ein Zeichen
* @param data Das Zeichen
*/
void uart_send_byte(uint8 data);
/*!
* Sende Kommando per UART im Little Endian
* @param cmd Zeiger auf das Kommando
* @return Anzahl der gesendete Bytes
*/
//int uart_send_cmd(command_t *cmd);
#define uart_send_cmd(cmd) uart_write((uint8*)cmd,sizeof(command_t));
/*!
* Sende Daten per UART im Little Endian
* @param data Datenpuffer
* @param length Groesse des Datenpuffers in bytes
* @return Anzahl der gesendete Bytes
*/
int uart_write(uint8 * data, int length);
/* Liest Zeichen von der UART
* @param data Der Zeiger an die die gelesenen Zeichen kommen
* @param length Anzahl der zu lesenden Bytes
* @return Anzahl der tatsaechlich gelesenen Zeichen
*/
int uart_read(void* data, int length);
#endif