Main Page | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Namespace Members | Data Fields | Globals

LaserDevice.h

Go to the documentation of this file.
00001 // Copyright (C) 2002 Mathieu Lemay
00002 
00003 
00004 #ifndef LASERDEVICE_H
00005 #define LASERDEVICE_H
00006 
00007 namespace RobotFlow {
00008 
00009 enum eMeasurementMode {
00010    E_MMODE_MM,
00011    E_MMODE_CM,
00012 };
00013 
00014 
00015 class LaserDevice
00016 {
00017    // Friend function
00018    friend  void* receive_threadLaser (void *myLaser);
00019 
00020   public:
00021    // Constructor
00022    LaserDevice(std::string serial_port);
00023 
00024    // Destructor
00025    ~LaserDevice();
00026 
00027    // Establish communication whit LMS
00028    // Search the good serial baudrate
00029    bool  EstablishCommunication();
00030 
00031    // Analyse continious data
00032    // ** datalen needs to be 301  **
00033    bool  ReadLaserData(unsigned short *data, unsigned long datalen);
00034 
00035    // Set the measurement mode of the laser
00036    int  SetLaserMeasurement(eMeasurementMode eMeasureMode, bool bIntensity);
00037 
00038    // Set the resolution of the laser
00039    // ** Must be an angular range of 180 degree **
00040    // ** angular resolution of 0.5 degree       **
00041    bool  SetLaserResolution(int width, int res);
00042 
00043    // Set the baudrate of the laser
00044    bool  SetLaserSpeed(int speed);
00045 
00046    // Start the continious data acquisition
00047    bool  StartDataAcquisition();
00048 
00049    // Stop the continious data acquisition
00050    bool  StopDataAcquisition();
00051 
00052 
00053   private:
00054 
00055    // Change the serial baudrate
00056    int SetSerialBaudrate(int nBaudrate);
00057 
00058    // Create a CRC
00059    unsigned short CreateCRC(unsigned char* data, unsigned long len);
00060 
00061    // Close session of the serial port
00062    void  End_session(int fd);
00063 
00064    // Initialise the serial port
00065    int   Port_initialisation(const char *serial_port);
00066 
00067    // Analyse answer of the laser
00068    int  ReadFromLaser(unsigned char* data, unsigned long maxLen, bool ack, bool timeout);
00069 
00070    // Use by the Receive_thread
00071    // Read data on serial port
00072    void  Receive();
00073 
00074    // Set the laser in Setting Mode to switch the measerement mode
00075    // Call at first in the SetLaserMeasurement function
00076    bool  SetLaserMode();
00077 
00078    // Write data on serial port
00079    int   WriteToLaser(unsigned char* data, unsigned long len);
00080 
00081    /////////////////////////////////////////////////////////////////////////////
00082    // Variables
00083    //
00084    int               m_Laser_fd;
00085    int               m_killed;
00086    unsigned short*   m_pLastDataBuffer;
00087 
00088    pthread_t         m_Receiving_thread;
00089    pthread_mutex_t   m_list_lock;
00090    std::list<std::string>      m_received;
00091 };
00092 
00093 }//namespace RobotFlow
00094 #endif

Generated on Wed Oct 5 14:36:12 2005 for RobotFlow by  doxygen 1.4.4