sick_lms400.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2009 Radu Bogdan Rusu <rusu -=- cs.tum.edu>
3  * Code based on the LGPL Player SICK LMS400 driver by Nico Blodow and Radu Bogdan Rusu
4  *
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are met:
9  *
10  * * Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
20  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26  * POSSIBILITY OF SUCH DAMAGE.
27  *
28  * $Id$
29  *
30  */
31 
32 #include <ros/ros.h>
33 #include <stdlib.h>
34 #include <netdb.h>
35 #include <sensor_msgs/LaserScan.h>
36 
37 #define BUF_SIZE 1024
38 
40 {
42  typedef struct
43  {
44  unsigned char* string;
45  int length;
47 
49  typedef struct
50  {
51  uint16_t Format;
52  uint16_t DistanceScaling;
53  int32_t StartingAngle;
54  uint16_t AngularStepWidth;
57  uint16_t RemissionScaling;
61 
62 
65  {
66  public:
68  asr_sick_lms_400 (const char* host, int port, int debug_mode);
69 
70  // Creates socket, connects
71  int Connect ();
72  int Disconnect ();
73 
74  // Configuration parameters
75  int SetAngularResolution (const char* password, float ang_res, float angle_start, float angle_range);
76  int SetScanningFrequency (const char* password, float freq, float angle_start, float angle_range);
77  int SetResolutionAndFrequency (float freq, float ang_res, float angle_start, float angle_range);
78 
79  int StartMeasurement (bool intensity = true);
80  sensor_msgs::LaserScan ReadMeasurement ();
81  int StopMeasurement ();
82 
83  int SetUserLevel (int8_t userlevel, const char* password);
84  int GetMACAddress (char** macadress);
85 
86  int SetIP (char* ip);
87  int SetGateway (char* gw);
88  int SetNetmask (char* mask);
89  int SetPort (uint16_t port);
90 
91  int ResetDevice ();
92  int TerminateConfiguration ();
93 
94  int SendCommand (const char* cmd);
95  int ReadResult ();
96  // for "Variables", Commands that only reply with one Answer message
97  int ReadAnswer ();
98  // for "Procedures", Commands that reply with a Confirmation message and an Answer message
99  int ReadConfirmationAndAnswer ();
100 
101  int EnableRIS (int onoff);
102  int SetMeanFilterParameters (int num_scans);
103  int SetRangeFilterParameters (float range_min, float range_max);
104  int EnableFilters (int filter_mask);
105 
106  // turns a string holding an ip address into long
107  unsigned char* ParseIP (char* ip);
108 
109  private:
110  // assembles STX's, length field, message, checksum ready to be sent. Cool.
111  int AssembleCommand (unsigned char* command, int len);
112 
113  const char* hostname_;
114  int sockfd_, portno_, n_;
115  struct sockaddr_in serv_addr_;
116  #if HAVE_GETADDRINFO
117  struct addrinfo *addr_ptr_;
118  #else
119  struct hostent *server_;
120  #endif
121 
122  // Internal Parameters:
123  int verbose_;
129 
130  long int scanning_frequency_, resolution_;
131 
132  // for reading:
133  unsigned char buffer_[4096];
134  unsigned int bufferlength_;
135 
136  // for sending:
137  unsigned char command_[BUF_SIZE];
139  std::vector<MeasurementQueueElement_t>* MeasurementQueue_;
140  };
141 }
ROSLIB_DECL std::string command(const std::string &cmd)
#define BUF_SIZE
Definition: sick_lms400.h:37
std::vector< MeasurementQueueElement_t > * MeasurementQueue_
Definition: sick_lms400.h:139


asr_sick_lms_400
Author(s): Aumann Florian, Krehl Yann, Meißner Pascal
autogenerated on Mon Jun 10 2019 12:41:54