serialcomm_s300.h
Go to the documentation of this file.
00001 /*
00002  *
00003  * serialcomm_s300.h
00004  *
00005  *
00006  * Copyright (C) 2010
00007  * Autonomous Intelligent Systems Group
00008  * University of Bonn, Germany
00009  *
00010  *
00011  * Authors: Andreas Hochrath, Torsten Fiolka
00012  *
00013  *
00014  * This program is free software; you can redistribute it and/or modify
00015  * it under the terms of the GNU General Public License as published by
00016  * the Free Software Foundation; either version 3 of the License, or
00017  * (at your option) any later version.
00018  *
00019  * This program is distributed in the hope that it will be useful,
00020  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00021  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00022  * GNU General Public License for more details.
00023  *
00024  * You should have received a copy of the GNU General Public License
00025  * along with this program; if not, write to the Free Software
00026  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
00027  *
00028  *
00029  * Origin:
00030  *  Player - One Hell of a Robot Server
00031  *  serialstream.cc & sicks3000.cc
00032  *  Copyright (C) 2003
00033  *     Brian Gerkey
00034  *  Copyright (C) 2000
00035  *     Brian Gerkey, Kasper Stoy, Richard Vaughan, & Andrew Howard
00036  *
00037  */
00038 
00039 #ifndef __SERIALCOMMS300_H__
00040 #define __SERIALCOMMS300_H__
00041 
00042 #include <string>
00043 
00044 #define RX_BUFFER_SIZE 4096
00045 #define DEFAULT_SERIAL_PORT "/dev/sick300"
00046 #define DEFAULT_BAUD_RATE 500000
00047 
00053 class SerialCommS300
00054 {
00055 public:
00056 
00057   SerialCommS300();
00058   ~SerialCommS300();
00059 
00060   // returns 0 if new laser data has arrived
00061   int readData();
00062 
00063   inline unsigned int getNumRanges()
00064   {
00065     return m_rangesCount;
00066   }
00067   inline float* getRanges()
00068   {
00069     return m_ranges;
00070   }
00071 
00072   int connect(const std::string& deviceName, unsigned int baudRate = DEFAULT_BAUD_RATE);
00073   int disconnect();
00074 
00075 private:
00076 
00077   void setFlags();
00078 
00079   int setBaudRate(int baudRate);
00080   int baudRateToBaudCode(int baudCode);
00081 
00082   unsigned short createCRC(unsigned char* data, ssize_t len);
00083 
00084 protected:
00085 
00086   unsigned char m_rxBuffer[RX_BUFFER_SIZE];
00087 
00088   int m_fd;
00089 
00090   int m_rxCount;
00091 
00092   float* m_ranges;
00093   unsigned int m_rangesCount;
00094 
00095 };
00096 
00097 #endif // __SERIALCOMMS300_H__
00098 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Friends Defines


sicks300
Author(s): Andreas Hochrath, Torsten Fiolka
autogenerated on Thu Apr 25 2013 17:26:53