serialcomm_s300.h
Go to the documentation of this file.
00001 /*
00002  *
00003  * serialcomm_s300.h
00004  *
00005  *
00006  * Copyright (C) 2014
00007  * Software Engineering Group
00008  * RWTH Aachen University
00009  *
00010  *
00011  * Author: Dimitri Bohlender
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  *  Copyright (C) 2010
00031  *     Andreas Hochrath, Torsten Fiolka
00032  *     Autonomous Intelligent Systems Group
00033  *     University of Bonn, Germany
00034  *
00035  *  Player - One Hell of a Robot Server
00036  *  serialstream.cc & sicks3000.cc
00037  *  Copyright (C) 2003
00038  *     Brian Gerkey
00039  *  Copyright (C) 2000
00040  *     Brian Gerkey, Kasper Stoy, Richard Vaughan, & Andrew Howard
00041  *
00042  */
00043 
00044 #ifndef __SERIALCOMMS300_H__
00045 #define __SERIALCOMMS300_H__
00046 
00047 #include <string>
00048 
00049 #define RX_BUFFER_SIZE 4096
00050 #define DEFAULT_SERIAL_PORT "/dev/sick300"
00051 #define DEFAULT_BAUD_RATE 500000
00052 #define PROTOCOL_1_02 0x0102
00053 #define PROTOCOL_1_03 0x0103
00054 
00060 class SerialCommS300
00061 {
00062 public:
00063 
00064   SerialCommS300();
00065   ~SerialCommS300();
00066 
00067   // returns 0 if new laser data has arrived
00068   int readData();
00069 
00070   inline unsigned int getNumRanges()
00071   {
00072     return m_rangesCount;
00073   }
00074   inline float* getRanges()
00075   {
00076     return m_ranges;
00077   }
00078 
00079   int connect(const std::string& deviceName, unsigned int baudRate = DEFAULT_BAUD_RATE);
00080   int disconnect();
00081 
00082 private:
00083 
00084   void setFlags();
00085 
00086   int setBaudRate(int baudRate);
00087   int baudRateToBaudCode(int baudCode);
00088 
00089   unsigned short createCRC(unsigned char* data, ssize_t len);
00090 
00091 protected:
00092 
00093   unsigned char m_rxBuffer[RX_BUFFER_SIZE];
00094 
00095   int m_fd;
00096 
00097   int m_rxCount;
00098 
00099   float* m_ranges;
00100   unsigned int m_rangesCount;
00101 
00102 };
00103 
00104 #endif // __SERIALCOMMS300_H__
00105 


sicks300
Author(s): Dimitri Bohlender
autogenerated on Mon Oct 6 2014 07:37:46