ersp.h

Go to the documentation of this file.
00001 /*
00002  * ERSP  Player driver 
00003  */
00004 
00005 /*
00006  * This driver is for interacting with the "ERSP" robots, made by Evolution
00007  * Robotics.    
00008  *
00009  * This code is inspired by the player module of ER1 and P2OS; thanks to the
00010  * authors of these modules.
00011  */
00012 
00013 #ifndef ERSP_ERSP_H
00014 #define ERSP_ERSP_H
00015 
00016 #ifdef HAVE_CONFIG_H
00017 #include "config.h"
00018 #endif
00019 
00020 #include <sys/types.h>
00021 #include <stdio.h>
00022 #include <string.h>
00023 #include <unistd.h>
00024 #include <math.h>
00025 #include <stdlib.h>  /* for abs() */
00026 
00027 #include <libplayercore/playercore.h>
00028 
00029 #ifdef HAVE_ERSP
00030 #include <evolution/Resource.hpp>
00031 #endif
00032 
00033 #include <scorpion.h>
00034 
00035 /*
00036  * Relevant types and constants for the "ERSP" robots, made by Evolution
00037  * Robotics.    
00038  */
00039 
00040 #define IR_MAX_RANGE 0.80
00041 
00042 class ERSPDevice
00043 {
00044   private:
00045    player_devaddr_t devaddr;
00046    int subscriptions;
00047    union {
00048       player_position2d_data_t position2d;
00049       player_bumper_data_t bumper;
00050       player_ir_data_t ir;
00051       player_power_data_t power;
00052    } devdata;
00053 
00054    union {
00055 #ifdef HAVE_ERSP
00056       Evolution::IDriveSystem *driver;
00057       Evolution::IAvoidance *avoid;
00058       Evolution::IBattery *battery;
00059       Evolution::IBumpSensor *bumper;
00060       Evolution::IRangeSensor *range;
00061 #endif
00062       void *handle;
00063    } devices[ERSP_DEVICES];
00064 
00065   public:
00066    ERSPDevice(ConfigFile *cf, int section);
00067    ~ERSPDevice(void);
00068 
00069    virtual int Setup();
00070    virtual int Update();
00071    virtual int Shutdown();
00072 
00073    // Message handling
00074    virtual int Subscribe(player_devaddr_t id);
00075    virtual int Unsubscribe(player_devaddr_t id);
00076    virtual int ProcessMessage(MessageQueue *queue,
00077                player_msghdr *msghdr,
00078                void *data);
00079 };
00080 
00081 class ERSP : public Driver 
00082 {
00083   private:
00084 
00086    // Generic driver
00088 
00089    bool running;
00090 
00091    ERSPDevice devices[ERSP_DEVICES];
00092 
00093    // Publish state data.
00094    void PutData(void);
00095 
00097    // Evolution
00099 
00100 #ifdef HAVE_ERSP
00101    Evolution::ResourceManager *manager;
00102    Evolution::IResourceContainer *container;
00103 #endif
00104    const struct ersp_dev *devs;
00105 
00106    int SetupERSP();
00107 
00108   public:
00109    ERSP(ConfigFile *cf, int section);
00110    ~ERSP(void);
00111 
00112    // Thread life-cycle
00113    void Main();
00114    int Setup();
00115    int Shutdown();
00116 
00117    // Message handling
00118    int Subscribe(player_devaddr_t id);
00119    int Unsubscribe(player_devaddr_t id);
00120    int ProcessMessage(MessageQueue *queue,
00121             player_msghdr *msghdr,
00122             void *data);
00123 };
00124 
00125 #endif

Generated on Sat Jan 13 03:11:09 2007 for ERSP Player driver by  doxygen 1.5.1