11 #define LINEBUFFER_SIZE 10000 30 istringstream lis(buf);
42 if (qualifier==
"FLASER"){
46 if (qualifier==
"RLASER"){
50 if (qualifier==
"ROBOTLASER1"){
51 string laser_type, start_angle, field_of_view, angular_resolution, maximum_range, accuracy, remission_mode;
52 lis >> laser_type>> start_angle>> field_of_view>> angular_resolution>> maximum_range>> accuracy>> remission_mode>> beams;
55 if (qualifier==
"ROBOTLASER2"){
56 string laser_type, start_angle, field_of_view, angular_resolution, maximum_range, accuracy, remission_mode;
57 lis >> laser_type>> start_angle>> field_of_view>> angular_resolution>> maximum_range>> accuracy>> remission_mode>> rbeams;
60 if (qualifier!=
"PARAM")
74 insert(make_pair(name, v));
76 if (laseron || rlaser1){
79 insert(make_pair(
"laser_beams", v));
80 cerr <<
"FRONT LASER BEAMS FROM LOG: " << beams << endl;
83 insert(make_pair(
"robot_use_laser", v));
85 if (rlaseron || rlaser2){
88 insert(make_pair(
"rear_laser_beams", v));
89 cerr <<
"REAR LASER BEAMS FROM LOG: " << beams << endl;
92 insert(make_pair(
"robot_use_rear_laser", v));
105 smap.insert(make_pair(odometry->
getName(), odometry));
106 smap.insert(make_pair(truepos->
getName(), truepos));
108 const_iterator key=find(
"robot_use_sonar");
109 if (key!=end() && key->second.front()==
"on"){
116 key=find(
"robot_max_sonar");
118 maxrange=atof(key->second.front().c_str());
119 cerr <<
"max sonar:" << maxrange << endl;
122 unsigned int sonar_num=0;
123 key=find(
"robot_num_sonars");
125 sonar_num=atoi(key->second.front().c_str());
126 cerr <<
"robot_num_sonars" << sonar_num << endl;
129 key=find(
"robot_sonar_offsets");
131 const vector<string> & soff=key->second;
133 if( (soff.size()/3<sonar_num)){
134 cerr << __func__ <<
": Error " << soff.size()
135 <<
" parameters for defining the sonar offsets" 136 <<
" while the specified number of sonars requires " 137 << sonar_num*3 <<
" parameters at least" << endl;
139 cerr << __func__ <<
": Ok " << soff.size() <<
" parameters for defining the sonar offsets of " << sonar_num <<
" devices" << endl;
145 for (
unsigned int i=0; i<sonar_num*3; i+=3){
146 beam.
span=M_PI/180.*7.5;
147 beam.
pose.
x=atof(soff[i].c_str());
148 beam.
pose.
y=atof(soff[i+1].c_str());
151 sonar->
m_beams.push_back(beam);
152 cerr <<
"beam_x" << beam.
pose.
x;
153 cerr <<
" beam_y" << beam.
pose.
y;
154 cerr <<
" beam_theta" << beam.
pose.
theta << endl;;
158 smap.insert(make_pair(sonar->
getName(), sonar));
162 key=find(
"robot_use_laser");
164 if (key!=end() && key->second.front()==
"on"){
169 key=find(
"robot_frontlaser_offset");
171 laser->
m_pose.
x=atof(key->second.front().c_str());
172 cerr <<
"FRONT OFFSET= " << laser->
m_pose.
x << endl;
180 unsigned int beam_no=180;
182 key=find(
"laser_beams");
184 beam_no=atoi(key->second.front().c_str());
185 cerr <<
"FRONT BEAMS="<< beam_no << endl;
189 double resolution=1.;
192 if (beam_no==180 || beam_no==181)
194 else if (beam_no==360 || beam_no==361)
196 else if (beam_no==540 || beam_no==541)
198 else if (beam_no==769) {
199 resolution =360./1024.;
202 else if (beam_no==682) {
203 resolution =360./1024.;
206 else if (beam_no==683) {
207 resolution =360./1024.;
211 key=find(
"laser_front_laser_resolution");
213 resolution=atof(key->second.front().c_str());
214 cerr <<
"FRONT RES " << resolution << endl;
218 laser->
m_beams.resize(beam_no);
219 double center_beam=(double)beam_no/2.;
220 uint low_index=(uint)floor(center_beam);
221 uint up_index=(uint)ceil(center_beam);
222 double step=resolution*M_PI/180.;
223 double angle=beam_no%2?0:step;
224 unsigned int i=beam_no%2?0:1;
225 for (; i<low_index+1; i++, angle+=step){
233 laser->
m_beams[low_index-i]=beam;
235 laser->
m_beams[up_index+i-1]=beam;
238 smap.insert(make_pair(laser->
getName(), laser));
239 cerr <<
"front beams " << beam_no << endl;
240 cerr <<
"maxrange " << maxrange << endl;
244 key=find(
"robot_use_laser");
245 if (key!=end() && key->second.front()==
"on"){
248 cerr <<
"ROBOTLASER1 inserted" << endl;
251 key=find(
"robot_frontlaser_offset");
253 laser->
m_pose.
x=atof(key->second.front().c_str());
254 cerr <<
"FRONT OFFSET=" << laser->
m_pose.
x << endl;
260 unsigned int beam_no=180;
262 key=find(
"laser_beams");
264 beam_no=atoi(key->second.front().c_str());
265 cerr <<
"FRONT BEAMS="<< beam_no << endl;
269 double resolution=1.;
272 if (beam_no==180 || beam_no==181)
274 else if (beam_no==360 || beam_no==361)
276 else if (beam_no==540 || beam_no==541)
278 else if (beam_no==769)
279 resolution =360./1024.;
280 else if (beam_no==683) {
281 resolution =360./1024.;
285 key=find(
"laser_front_laser_resolution");
287 resolution=atof(key->second.front().c_str());
288 cerr <<
"FRONT RES" << resolution << endl;
292 laser->
m_beams.resize(beam_no);
293 double center_beam=(double)beam_no/2.;
294 uint low_index=(uint)floor(center_beam);
295 uint up_index=(uint)ceil(center_beam);
296 double step=resolution*M_PI/180.;
297 double angle=beam_no%2?0:step;
298 unsigned int i=beam_no%2?0:1;
299 for (; i<low_index+1; i++, angle+=step){
307 laser->
m_beams[low_index-i]=beam;
309 laser->
m_beams[up_index+i-1]=beam;
312 smap.insert(make_pair(laser->
getName(), laser));
313 cerr <<
"front beams" << beam_no << endl;
318 key=find(
"robot_use_rear_laser");
320 if (key!=end() && key->second.front()==
"on"){
326 key=find(
"robot_rearlaser_offset");
328 laser->
m_pose.
x=atof(key->second.front().c_str());
329 cerr <<
"REAR OFFSET = " << laser->
m_pose.
x << endl;
337 unsigned int beam_no=180;
339 key=find(
"rear_laser_beams");
341 beam_no=atoi(key->second.front().c_str());
342 cerr <<
"REAR BEAMS="<< beam_no << endl;
346 double resolution=1.;
349 if (beam_no==180 || beam_no==181)
351 else if (beam_no==360 || beam_no==361)
353 else if (beam_no==540 || beam_no==541)
355 else if (beam_no==769)
356 resolution =360./1024.;
358 key=find(
"laser_rear_laser_resolution");
360 resolution=atof(key->second.front().c_str());
361 cerr <<
"REAR RES" << resolution << endl;
365 laser->
m_beams.resize(beam_no);
366 double center_beam=(double)beam_no/2.;
367 uint low_index=(uint)floor(center_beam);
368 uint up_index=(uint)ceil(center_beam);
369 double step=resolution*M_PI/180.;
370 double angle=beam_no%2?0:step;
371 unsigned int i=beam_no%2?0:1;
372 for (; i<low_index+1; i++, angle+=step){
380 laser->
m_beams[low_index-i]=beam;
382 laser->
m_beams[up_index+i-1]=beam;
385 smap.insert(make_pair(laser->
getName(), laser));
386 cerr<<
"rear beams" << beam_no << endl;
389 key=find(
"robot_use_rear_laser");
390 if (key!=end() && key->second.front()==
"on"){
393 cerr <<
"ROBOTLASER2 inserted" << endl;
397 key=find(
"robot_rearlaser_offset");
400 cerr <<
"REAR OFFSET not used" << laser->
m_pose.
x << endl;
406 unsigned int beam_no=180;
408 key=find(
"rear_laser_beams");
410 beam_no=atoi(key->second.front().c_str());
411 cerr <<
"REAR BEAMS="<< beam_no << endl;
415 double resolution=1.;
418 if (beam_no==180 || beam_no==181)
420 else if (beam_no==360 || beam_no==361)
422 else if (beam_no==540 || beam_no==541)
424 else if (beam_no==769)
425 resolution =360./1024.;
427 key=find(
"laser_rear_laser_resolution");
429 resolution=atof(key->second.front().c_str());
430 cerr <<
"REAR RES" << resolution << endl;
434 laser->
m_beams.resize(beam_no);
435 double center_beam=(double)beam_no/2.;
436 uint low_index=(uint)floor(center_beam);
437 uint up_index=(uint)ceil(center_beam);
438 double step=resolution*M_PI/180.;
439 double angle=beam_no%2?0:step;
440 unsigned int i=beam_no%2?0:1;
441 for (; i<low_index+1; i++, angle+=step){
449 laser->
m_beams[low_index-i]=beam;
451 laser->
m_beams[up_index+i-1]=beam;
454 smap.insert(make_pair(laser->
getName(), laser));
455 cerr <<
"rear beams" << beam_no << endl;
virtual std::istream & load(std::istream &is)
std::vector< Beam > m_beams
std::map< std::string, Sensor * > SensorMap
virtual SensorMap computeSensorMap() const
std::string getName() const