RS4Leuze_laser.h
1  /*
2  * Player - One Hell of a Robot Server
3  * Copyright (C) 2000 Brian Gerkey et al.
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  *
19  */
20 
28 #ifndef RS4Leuze_laser_h
29 #define RS4Leuze_laser_h
30 
31 #include <termios.h>
32 #include <sys/types.h>
33 #include <sys/stat.h>
34 #include <fcntl.h>
35 #include <time.h>
36 #include <sys/time.h>
37 #include <stdlib.h>
38 
39 using namespace std;
40 
41 #define MAX_SCAN_POINTS 529
42 
43 
44 typedef struct RS4Leuze_laser_readings {
45  double Reading[MAX_SCAN_POINTS];
47 
48 //classes
52 class Claser
53 {
54  private:
55  char *portName;
56  int serialFD;
57  termios ttyset;
58  fd_set rfds;
60  unsigned char byte;
61  unsigned char checksum;
62  unsigned char option1;
63  long unsigned int scan_number;
64  unsigned int output_start;
65  unsigned int output_stop;
66  unsigned int scanedPoint;
67  unsigned char controlByte;
68  unsigned int points_to_scan;
69  struct timeval tv;
70  timeval timeStamp;
72  public:
73 
74  //Claser(ClogMsg *lgMsg, bool *laser_ON, char dir_name[80]); /**<Opens serial port*/
75  Claser(int scan_points);
76  ~Claser();
77  void closeLaser();
78  unsigned char readByte();
79  void sync();
80  //void readScan(); /**<Sets to scanData array values of last laser scanner*/
81  void writeConfig();
82  int scanRead();
83  void runLaser();
84  void closeSerial();
85  void openSerial(bool *laser_ON,int Baud_rate, const char * Port);
87 
88 };
89 
90 #endif
91 
92 
termios ttyset
termios variable to configure serial port
Definition: RS4Leuze_laser.h:57
static bool MatchMessage(player_msghdr_t *hdr, int type, int subtype, player_devaddr_t addr)
Helper for message processing.
Definition: message.h:159
Definition: roomba_comms.h:89
int selectResult
Laser Message fields.
Definition: RS4Leuze_laser.h:59
~Claser()
Destructor.
Definition: RS4Leuze_laser.cc:46
Claser implements functions to read data from a laser scanner ROTOSCAN RS4-4 (Leuze corp....
Definition: RS4Leuze_laser.h:53
void closeSerial()
Closes serial Port.
Definition: RS4Leuze_laser.cc:54
void openSerial(bool *laser_ON, int Baud_rate, const char *Port)
Opens serial Port and get the default paarameters or those given in the .cfg file.
Definition: RS4Leuze_laser.cc:59
Generic message header.
Definition: player.h:162
virtual int MainSetup(void)
Sets up the resources needed by the driver thread.
Definition: driver.h:658
virtual void MainQuit(void)
Cleanup method for driver thread (called when main exits)
Definition: driver.h:664
void sync()
sync function synchronizes with the start of the laser data
Definition: RS4Leuze_laser.cc:114
const char * ReadString(int section, const char *name, const char *value)
Read a string value.
virtual void Main(void)=0
Main method for driver thread.
char * portName
Serial Port where laser is connected.
Definition: RS4Leuze_laser.h:55
int ReadInt(int section, const char *name, int value)
Read an integer value.
#define PLAYER_MSGTYPE_DATA
A data message.
Definition: player.h:95
#define PLAYER_MSGTYPE_RESP_ACK
A positive response message.
Definition: player.h:112
virtual int ProcessMessage(QueuePointer &resp_queue, player_msghdr *hdr, void *data)
Message handler.
bool ReadBool(int section, const char *name, bool value)
Read a boolean value (one of: yes, no, true, false, 1, 0)
#define PLAYER_MSGTYPE_REQ
A request message.
Definition: player.h:106
timeval timeStamp
Time in microseconds resolution.
Definition: RS4Leuze_laser.h:70
Definition: RS4Leuze_laser.h:44
int serialFD
Serial port file descriptor.
Definition: RS4Leuze_laser.h:56
void closeLaser()
Closes serial Port and data file.
int ReadDeviceAddr(player_devaddr_t *addr, int section, const char *name, int code, int index, const char *key)
Read a device id.
void writeConfig()
Write configuration parameters to laser scanner device.
Class for loading configuration file information.
Definition: configfile.h:197
#define PLAYER_CAPABILITIES_REQ
Capability request message type.
Definition: player.h:397
A device address.
Definition: player.h:146
An autopointer for the message queue.
Definition: message.h:74
A pose in space.
Definition: player.h:229
void runLaser()
Return the scan reading from the laser.
Definition: RS4Leuze_laser.cc:219
#define PLAYER_ERROR(msg)
Definition: error.h:81
Base class for drivers which oeprate with a thread.
Definition: driver.h:553
Claser(int scan_points)
Opens serial port.
Definition: RS4Leuze_laser.cc:37
#define PLAYER_MSGTYPE_CMD
A command message.
Definition: player.h:99
Base class for all drivers.
Definition: driver.h:109
int scanRead()
reads one scan and puts it in scanData array
Definition: RS4Leuze_laser.cc:131
#define PLAYER_MSG2(level, msg, a, b)
Definition: error.h:107
unsigned char readByte()
Reads one byte and updates checksum message.
Definition: RS4Leuze_laser.cc:103
#define PLAYER_MSGQUEUE_DEFAULT_MAXLEN
Default maximum length for a message queue.
Definition: player.h:76
struct timeval tv
termios variable time interval
Definition: RS4Leuze_laser.h:69
T max(T a, T b)
Return the maximum of a, b.
Definition: utility.h:104