rec::robotino::api2 C++ interface
LaserRangeFinderReadings.h
1 // Copyright (C) 2004-2013, Robotics Equipment Corporation GmbH
2 
3 //Copyright (c) ...
4 //
5 //REC Robotics Equipment Corporation GmbH, Planegg, Germany. All rights reserved.
6 //Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
7 //1) Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
8 //2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
9 //
10 //THIS SOFTWARE IS PROVIDED BY REC ROBOTICS EQUIPMENT CORPORATION GMBH �AS IS� AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
11 //THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL REC ROBOTICS EQUIPMENT CORPORATION GMBH
12 //BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
13 //GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
14 //LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
15 //
16 //Copyright (c) ...
17 //
18 //REC Robotics Equipment Corporation GmbH, Planegg, Germany. Alle Rechte vorbehalten.
19 //Weiterverbreitung und Verwendung in nichtkompilierter oder kompilierter Form, mit oder ohne Ver�nderung, sind unter den folgenden Bedingungen zul�ssig:
20 //1) Weiterverbreitete nichtkompilierte Exemplare m�ssen das obige Copyright, diese Liste der Bedingungen und den folgenden Haftungsausschluss im Quelltext enthalten.
21 //2) Weiterverbreitete kompilierte Exemplare m�ssen das obige Copyright, diese Liste der Bedingungen und den folgenden Haftungsausschluss in der Dokumentation und/oder anderen Materialien, die mit dem Exemplar verbreitet werden, enthalten.
22 //
23 //DIESE SOFTWARE WIRD VON REC ROBOTICS EQUIPMENT CORPORATION GMBH OHNE JEGLICHE SPEZIELLE ODER IMPLIZIERTE GARANTIEN ZUR VERF�GUNG GESTELLT, DIE UNTER
24 //ANDEREM EINSCHLIESSEN: DIE IMPLIZIERTE GARANTIE DER VERWENDBARKEIT DER SOFTWARE F�R EINEN BESTIMMTEN ZWECK. AUF KEINEN FALL IST REC ROBOTICS EQUIPMENT CORPORATION GMBH
25 //F�R IRGENDWELCHE DIREKTEN, INDIREKTEN, ZUF�LLIGEN, SPEZIELLEN, BEISPIELHAFTEN ODER FOLGESCH�DEN (UNTER ANDEREM VERSCHAFFEN VON ERSATZG�TERN ODER -DIENSTLEISTUNGEN;
26 //EINSCHR�NKUNG DER NUTZUNGSF�HIGKEIT; VERLUST VON NUTZUNGSF�HIGKEIT; DATEN; PROFIT ODER GESCH�FTSUNTERBRECHUNG), WIE AUCH IMMER VERURSACHT UND UNTER WELCHER VERPFLICHTUNG
27 //AUCH IMMER, OB IN VERTRAG, STRIKTER VERPFLICHTUNG ODER UNERLAUBTER HANDLUNG (INKLUSIVE FAHRL�SSIGKEIT) VERANTWORTLICH, AUF WELCHEM WEG SIE AUCH IMMER DURCH DIE BENUTZUNG
28 //DIESER SOFTWARE ENTSTANDEN SIND, SOGAR, WENN SIE AUF DIE M�GLICHKEIT EINES SOLCHEN SCHADENS HINGEWIESEN WORDEN SIND.
29 
30 #ifndef _REC_ROBOTINO_API2_LASERRANGEFINDERREADINGS_H_
31 #define _REC_ROBOTINO_API2_LASERRANGEFINDERREADINGS_H_
32 
33 #include <vector>
34 #include <string.h>
35 
36 namespace rec
37 {
38  namespace robotino
39  {
40  namespace api2
41  {
46  {
47  public:
52  : seq( 0 )
53  , stamp( 0 )
54  , angle_min( 0.0f )
55  , angle_max( 0.0f )
56  , angle_increment( 0.0f )
57  , time_increment( 0.0f )
58  , range_min( 0.0f )
59  , range_max( 0.0f )
60  , _frame_id( NULL )
61  , _ranges( NULL )
62  , _rangesSize( 0 )
63  , _intensities( NULL )
64  , _intensitiesSize( 0 )
65  {
66  _frame_id = new char[1];
67  _frame_id[0] = '\n';
68  }
69 
74  : seq( other.seq )
75  , stamp( other.stamp )
76  , angle_min( other.angle_min )
77  , angle_max( other.angle_max )
80  , range_min( other.range_min )
81  , range_max( other.range_max )
82  , _frame_id( NULL )
83  , _ranges( NULL )
84  , _rangesSize( 0 )
85  , _intensities( NULL )
86  , _intensitiesSize( 0 )
87  {
88  set_frame_id( other._frame_id );
89  setRanges( other._ranges, other._rangesSize );
90  setIntensities( other._intensities, other._intensitiesSize );
91  }
92 
97  {
98  delete [] _frame_id;
99  delete [] _ranges;
100  delete [] _intensities;
101  }
102 
107  {
108  seq = other.seq;
109  stamp = other.stamp ;
110  angle_min = other.angle_min ;
111  angle_max = other.angle_max ;
114  range_min = other.range_min ;
115  range_max = other.range_max ;
116  _frame_id = NULL ;
117  _ranges = NULL ;
118  _rangesSize = 0 ;
119  _intensities = NULL ;
120  _intensitiesSize = 0 ;
121 
122  set_frame_id( other._frame_id );
123  setRanges( other._ranges, other._rangesSize );
124  setIntensities( other._intensities, other._intensitiesSize );
125 
126  return *this;
127  }
128 
132  const char* frame_id() const
133  {
134  return _frame_id;
135  }
136 
141  void set_frame_id( const char* frame_id )
142  {
143  delete [] _frame_id;
144  if ( 0 == frame_id )
145  {
146  _frame_id = new char[1];
147  _frame_id[0] = '\n';
148  return;
149  }
150  size_t len = strlen( frame_id );
151  _frame_id = new char[ len+1 ];
152  strncpy( _frame_id, frame_id, len+1 );
153  }
154 
160  void ranges( const float** readings, unsigned int* rangesSize = NULL ) const
161  {
162  if( NULL != rangesSize )
163  {
164  *rangesSize = _rangesSize;
165  }
166  *readings = _ranges;
167  }
168 
174  void setRanges( const float* ranges, unsigned int rangesSize )
175  {
176  if( rangesSize != _rangesSize )
177  {
178  _rangesSize = rangesSize;
179  delete [] _ranges;
180  _ranges = NULL;
181  if( 0 == _rangesSize )
182  {
183  return;
184  }
185 
186  _ranges = new float[ rangesSize ];
187  }
188 
189  memcpy( _ranges, ranges, _rangesSize * sizeof( float ) );
190  }
191 
195  unsigned int numRanges() const
196  {
197  return _rangesSize;
198  }
199 
201  void clearRanges()
202  {
203  delete [] _ranges;
204  _ranges = NULL;
205  _rangesSize = 0;
206  }
207 
213  void intensities( const float** readings, unsigned int* intensitiesSize = NULL ) const
214  {
215  if( NULL != intensitiesSize )
216  {
217  *intensitiesSize = _intensitiesSize;
218  }
219  *readings = _intensities;
220  }
221 
227  void setIntensities( const float* intensities, unsigned int intensitiesSize )
228  {
229  if( intensitiesSize != _intensitiesSize )
230  {
231  _intensitiesSize = intensitiesSize;
232  delete [] _intensities;
233  _intensities = NULL;
234  if( 0 == _intensitiesSize )
235  {
236  return;
237  }
238 
239  _intensities = new float[ intensitiesSize ];
240  }
241 
242  memcpy( _intensities, intensities, _intensitiesSize * sizeof( float ) );
243  }
244 
248  unsigned int numIntensities() const
249  {
250  return _intensitiesSize;
251  }
252 
255  {
256  delete [] _intensities;
257  _intensities = NULL;
258  _intensitiesSize = 0;
259  }
260 
262  unsigned int seq;
264  unsigned int stamp;
265 
267  float angle_min;
269  float angle_max;
275  float scan_time;
277  float range_min;
279  float range_max;
280 
281  private:
282  char* _frame_id;
283 
284  float* _ranges;
285  unsigned int _rangesSize;
286 
287  float* _intensities;
288  unsigned int _intensitiesSize;
289  };
290  }
291  }
292 }
293 
294 #endif //_REC_ROBOTINO_API2_LASERRANGEFINDERREADINGS_H_
LaserRangeFinderReadings(const LaserRangeFinderReadings &other)
Definition: LaserRangeFinderReadings.h:73
void ranges(const float **readings, unsigned int *rangesSize=NULL) const
Definition: LaserRangeFinderReadings.h:160
float angle_increment
Definition: LaserRangeFinderReadings.h:271
unsigned int numRanges() const
Definition: LaserRangeFinderReadings.h:195
LaserRangeFinderReadings()
Definition: LaserRangeFinderReadings.h:51
float range_min
Definition: LaserRangeFinderReadings.h:277
const char * frame_id() const
Definition: LaserRangeFinderReadings.h:132
Sensor readings of Robotino&#39;s (optional) laser rangefinder.
Definition: LaserRangeFinderReadings.h:45
void set_frame_id(const char *frame_id)
Definition: LaserRangeFinderReadings.h:141
float scan_time
Definition: LaserRangeFinderReadings.h:275
float angle_max
Definition: LaserRangeFinderReadings.h:269
unsigned int seq
Definition: LaserRangeFinderReadings.h:262
void setIntensities(const float *intensities, unsigned int intensitiesSize)
Definition: LaserRangeFinderReadings.h:227
LaserRangeFinderReadings & operator=(const LaserRangeFinderReadings &other)
Definition: LaserRangeFinderReadings.h:106
float range_max
Definition: LaserRangeFinderReadings.h:279
void clearRanges()
Definition: LaserRangeFinderReadings.h:201
float angle_min
Definition: LaserRangeFinderReadings.h:267
Definition: AnalogInput.h:36
unsigned int numIntensities() const
Definition: LaserRangeFinderReadings.h:248
void clearIntensities()
Definition: LaserRangeFinderReadings.h:254
unsigned int stamp
Definition: LaserRangeFinderReadings.h:264
void setRanges(const float *ranges, unsigned int rangesSize)
Definition: LaserRangeFinderReadings.h:174
float time_increment
Definition: LaserRangeFinderReadings.h:273
void intensities(const float **readings, unsigned int *intensitiesSize=NULL) const
Definition: LaserRangeFinderReadings.h:213
~LaserRangeFinderReadings()
Definition: LaserRangeFinderReadings.h:96