sick_generic_radar.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2018, Ing.-Buero Dr. Michael Lehning, Hildesheim
3  * Copyright (C) 2018, SICK AG, Waldkirch
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  * * Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the distribution.
14  * * Neither the name of Osnabrück University nor the names of its
15  * contributors may be used to endorse or promote products derived from
16  * this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
22  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28  * POSSIBILITY OF SUCH DAMAGE.
29  *
30  * Created on: 28th May 2018
31  *
32  * Authors:
33  * Michael Lehning <michael.lehning@lehning.de>
34  *
35  */
36 
37 #ifndef SICK_GENERIC_RADAR_H_
38 #define SICK_GENERIC_RADAR_H_
39 
40 #include <stdio.h>
41 #include <stdlib.h>
42 #include <string>
43 #include <string.h>
44 #include <vector>
45 
46 #include <ros/ros.h>
47 #include <sensor_msgs/LaserScan.h>
48 #include <sensor_msgs/PointCloud.h>
49 #include <sensor_msgs/PointCloud2.h>
50 #include <std_msgs/String.h>
51 
55 #include <sick_scan/RadarScan.h> // generated by msg-generator
56 
57 #ifndef _MSC_VER
58 
59 #include <dynamic_reconfigure/server.h>
60 #include <sick_scan/SickScanConfig.h>
61 
62 #endif
63 
66 
67 namespace sick_scan
68 {
69 
71  {
72  public:
73  float Dist() const
74  { return dist; }
75 
76  void Dist(float val)
77  { dist = val; }
78 
79  float Azimuth() const
80  { return azimuth; }
81 
82  void Azimuth(float val)
83  { azimuth = val; }
84 
85  float Vrad() const
86  { return vrad; }
87 
88  void Vrad(float val)
89  { vrad = val; }
90 
91  float Ampl() const
92  { return ampl; }
93 
94  void Ampl(float val)
95  { ampl = val; }
96 
97  int Mode() const
98  { return mode; }
99 
100  void Mode(int val)
101  { mode = val; }
102 
103  private:
104  float dist;
105  float azimuth;
106  float vrad;
107  float ampl;
108  int mode;
109  };
110 
112  {
113  public:
114  float P3Dx() const
115  { return p3Dx; }
116 
117  void P3Dx(float val)
118  { p3Dx = val; }
119 
120  float P3Dy() const
121  { return p3Dy; }
122 
123  void P3Dy(float val)
124  { p3Dy = val; }
125 
126  float V3Dx() const
127  { return v3Dx; }
128 
129  void V3Dx(float val)
130  { v3Dx = val; }
131 
132  float V3Dy() const
133  { return v3Dy; }
134 
135  void V3Dy(float val)
136  { v3Dy = val; }
137 
138  float ObjLength() const
139  { return objLength; }
140 
141  void ObjLength(float val)
142  { objLength = val; }
143 
144  int ObjId() const
145  { return objId; }
146 
147  void ObjId(int val)
148  { objId = val; }
149 
150  private:
151  float p3Dx;
152  float p3Dy;
153  float v3Dx;
154  float v3Dy;
155  float objLength;
156  int objId;
157  };
158 
159 
161  {
162  private:
163  /* Here will be the instance stored. */
165 
166  /* Private constructor to prevent instancing. */
168 
169  void simulateAsciiDatagramFromFile(unsigned char *receiveBuffer, int *actual_length, std::string filePattern);
170 
171  bool emul = false;
172 
177 
179 
180  public:
181  /* Static access method. */
182  static SickScanRadarSingleton *getInstance();
183 
184  void setEmulation(bool _emul);
185 
186  bool getEmulation(void);
187 
188  int parseDatagram(ros::Time timeStamp, unsigned char *receiveBuffer, int actual_length, bool useBinaryProtocol);
189 
190  int parseAsciiDatagram(char *datagram, size_t datagram_length, sick_scan::RadarScan *msgPtr,
191  std::vector<SickScanRadarObject> &objectList,
192  std::vector<SickScanRadarRawTarget> &rawTargetList); /* , SickScanConfig &config, */ // sensor_msgs::LaserScan &msg, int &numEchos, int &echoMask);
193  void simulateAsciiDatagram(unsigned char *receiveBuffer, int *actual_length);
194  };
195 
196 
197 #if 0
198  class SickScanRadar
199  {
200  public:
201  SickScanRadar(SickScanCommon *commonPtr_)
202  {
203  commonPtr = commonPtr_;
204  }
205  void setEmulation(bool _emul);
206  bool getEmulation(void);
207  int parseDatagram(ros::Time timeStamp, unsigned char *receiveBuffer, int actual_length, bool useBinaryProtocol);
208  int parseAsciiDatagram(char* datagram, size_t datagram_length, sick_scan::RadarScan *msgPtr, std::vector<SickScanRadarObject> &objectList, std::vector<SickScanRadarRawTarget> &rawTargetList); /* , SickScanConfig &config, */ // sensor_msgs::LaserScan &msg, int &numEchos, int &echoMask);
209  void simulateAsciiDatagram(unsigned char * receiveBuffer, int* actual_length);
210  private:
211 // SickScanCommon *commonPtr;
212  void simulateAsciiDatagramFromFile(unsigned char *receiveBuffer, int *actual_length, std::string filePattern);
213  bool emul;
214  };
215 #endif
216 
217 } /* namespace sick_scan */
218 #endif // SICK_GENERIC_RADAR_H_
static SickScanRadarSingleton * instance


sick_scan
Author(s): Michael Lehning , Jochen Sprickerhof , Martin Günther
autogenerated on Wed May 5 2021 03:05:48