Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "stdr_parser/stdr_parser_xml_file_writer.h"
00023
00024 namespace stdr_parser
00025 {
00026
00031 XmlFileWriter::XmlFileWriter(void)
00032 {
00033
00034 }
00035
00038 template void XmlFileWriter::messageToFile
00039 (stdr_msgs::Noise msg,std::string file_name);
00040
00042 template <>
00043 void XmlFileWriter::messageToXmlElement<stdr_msgs::Noise>
00044 (stdr_msgs::Noise msg,TiXmlNode* base)
00045 {
00047 TiXmlElement* noise;
00048 noise = new TiXmlElement("noise");
00049 base->LinkEndChild(noise);
00050
00052 TiXmlElement* noise_specs;
00053 noise_specs = new TiXmlElement("noise_specifications");
00054 noise->LinkEndChild(noise_specs);
00055
00057 TiXmlElement* noise_mean;
00058 noise_mean = new TiXmlElement("noise_mean");
00059 noise_specs->LinkEndChild(noise_mean);
00060
00061 TiXmlText * noise_mean_text = new TiXmlText(SSTR(msg.noiseMean));
00062 noise_mean->LinkEndChild(noise_mean_text);
00063
00065 TiXmlElement* noise_std;
00066 noise_std = new TiXmlElement("noise_std");
00067 noise_specs->LinkEndChild(noise_std);
00068
00069 TiXmlText * noise_std_text = new TiXmlText(SSTR(msg.noiseStd));
00070 noise_std->LinkEndChild(noise_std_text);
00071 }
00072
00075 template void XmlFileWriter::messageToFile
00076 (stdr_msgs::FootprintMsg msg,std::string file_name);
00077
00079 template <>
00080 void XmlFileWriter::messageToXmlElement<stdr_msgs::FootprintMsg>
00081 (stdr_msgs::FootprintMsg msg,TiXmlNode* base){
00083 TiXmlElement* footprint;
00084 footprint = new TiXmlElement("footprint");
00085 base->LinkEndChild(footprint);
00086
00088 TiXmlElement* footprint_specs;
00089 footprint_specs = new TiXmlElement("footprint_specifications");
00090 footprint->LinkEndChild(footprint_specs);
00091
00093 TiXmlElement* radius;
00094 radius = new TiXmlElement("radius");
00095 footprint_specs->LinkEndChild(radius);
00096 TiXmlText * radius_text = new TiXmlText(SSTR(msg.radius));
00097 radius->LinkEndChild(radius_text);
00098
00100 TiXmlElement* points;
00101 points = new TiXmlElement("points");
00102 footprint_specs->LinkEndChild(points);
00103
00104 for(unsigned int i = 0 ; i < msg.points.size() ; i++)
00105 {
00106 TiXmlElement* point;
00107 point = new TiXmlElement("point");
00108 points->LinkEndChild(point);
00109
00110 TiXmlElement* x;
00111 x = new TiXmlElement("x");
00112 point->LinkEndChild(x);
00113 TiXmlText * x_text = new TiXmlText(SSTR(msg.points[i].x));
00114 x->LinkEndChild(x_text);
00115
00116 TiXmlElement* y;
00117 y = new TiXmlElement("y");
00118 point->LinkEndChild(y);
00119 TiXmlText * y_text = new TiXmlText(SSTR(msg.points[i].y));
00120 y->LinkEndChild(y_text);
00121 }
00122 }
00123
00126 template <>
00127 void XmlFileWriter::messageToXmlElement<geometry_msgs::Pose2D>
00128 (geometry_msgs::Pose2D msg,TiXmlNode* base){
00130 TiXmlElement* pose;
00131 pose = new TiXmlElement("pose");
00132 base->LinkEndChild(pose);
00133
00135 TiXmlElement* x;
00136 x = new TiXmlElement("x");
00137 pose->LinkEndChild(x);
00138 TiXmlText * x_text = new TiXmlText(SSTR(msg.x));
00139 x->LinkEndChild(x_text);
00140
00142 TiXmlElement* y;
00143 y = new TiXmlElement("y");
00144 pose->LinkEndChild(y);
00145 TiXmlText * y_text = new TiXmlText(SSTR(msg.y));
00146 y->LinkEndChild(y_text);
00147
00149 TiXmlElement* theta;
00150 theta = new TiXmlElement("theta");
00151 pose->LinkEndChild(theta);
00152 TiXmlText * theta_text = new TiXmlText(SSTR(msg.theta));
00153 theta->LinkEndChild(theta_text);
00154 }
00155
00158 template void XmlFileWriter::messageToFile
00159 (stdr_msgs::LaserSensorMsg msg,std::string file_name);
00160
00162 template <>
00163 void XmlFileWriter::messageToXmlElement<stdr_msgs::LaserSensorMsg>
00164 (stdr_msgs::LaserSensorMsg msg,TiXmlNode* base){
00165
00167 TiXmlElement* laser = new TiXmlElement("laser");
00168 base->LinkEndChild(laser);
00169
00171 TiXmlElement* laser_specifications =
00172 new TiXmlElement("laser_specifications");
00173 laser->LinkEndChild(laser_specifications);
00174
00176 TiXmlElement* max_angle = new TiXmlElement("max_angle");
00177 laser_specifications->LinkEndChild(max_angle);
00178 TiXmlText * max_angle_text = new TiXmlText(SSTR(msg.maxAngle));
00179 max_angle->LinkEndChild(max_angle_text);
00180
00182 TiXmlElement* min_angle = new TiXmlElement("min_angle");
00183 laser_specifications->LinkEndChild(min_angle);
00184 TiXmlText * min_angle_text = new TiXmlText(SSTR(msg.minAngle));
00185 min_angle->LinkEndChild(min_angle_text);
00186
00188 TiXmlElement* max_range = new TiXmlElement("max_range");
00189 laser_specifications->LinkEndChild(max_range);
00190 TiXmlText * max_range_text = new TiXmlText(SSTR(msg.maxRange));
00191 max_range->LinkEndChild(max_range_text);
00192
00194 TiXmlElement* min_range = new TiXmlElement("min_range");
00195 laser_specifications->LinkEndChild(min_range);
00196 TiXmlText * min_range_text = new TiXmlText(SSTR(msg.minRange));
00197 min_range->LinkEndChild(min_range_text);
00198
00200 TiXmlElement* num_rays = new TiXmlElement("num_rays");
00201 laser_specifications->LinkEndChild(num_rays);
00202 TiXmlText * num_rays_text = new TiXmlText(SSTR(msg.numRays));
00203 num_rays->LinkEndChild(num_rays_text);
00204
00206 TiXmlElement* frequency = new TiXmlElement("frequency");
00207 laser_specifications->LinkEndChild(frequency);
00208 TiXmlText * frequency_text = new TiXmlText(SSTR(msg.frequency));
00209 frequency->LinkEndChild(frequency_text);
00210
00212 TiXmlElement* frame_id = new TiXmlElement("frame_id");
00213 laser_specifications->LinkEndChild(frame_id);
00214 TiXmlText * frame_id_text = new TiXmlText(SSTR(msg.frame_id));
00215 frame_id->LinkEndChild(frame_id_text);
00216
00218 messageToXmlElement(msg.pose,laser_specifications);
00219
00221 messageToXmlElement(msg.noise,laser_specifications);
00222 }
00223
00226 template void XmlFileWriter::messageToFile
00227 (stdr_msgs::SonarSensorMsg msg,std::string file_name);
00228
00230 template <>
00231 void XmlFileWriter::messageToXmlElement<stdr_msgs::SonarSensorMsg>
00232 (stdr_msgs::SonarSensorMsg msg,TiXmlNode* base){
00233
00235 TiXmlElement* sonar = new TiXmlElement("sonar");
00236 base->LinkEndChild(sonar);
00237
00239 TiXmlElement* sonar_specifications =
00240 new TiXmlElement("sonar_specifications");
00241 sonar->LinkEndChild(sonar_specifications);
00242
00244 TiXmlElement* cone_angle = new TiXmlElement("cone_angle");
00245 sonar_specifications->LinkEndChild(cone_angle);
00246 TiXmlText * cone_angle_text = new TiXmlText(SSTR(msg.coneAngle));
00247 cone_angle->LinkEndChild(cone_angle_text);
00248
00250 TiXmlElement* max_range = new TiXmlElement("max_range");
00251 sonar_specifications->LinkEndChild(max_range);
00252 TiXmlText * max_range_text = new TiXmlText(SSTR(msg.maxRange));
00253 max_range->LinkEndChild(max_range_text);
00254
00256 TiXmlElement* min_range = new TiXmlElement("min_range");
00257 sonar_specifications->LinkEndChild(min_range);
00258 TiXmlText * min_range_text = new TiXmlText(SSTR(msg.minRange));
00259 min_range->LinkEndChild(min_range_text);
00260
00262 TiXmlElement* frequency = new TiXmlElement("frequency");
00263 sonar_specifications->LinkEndChild(frequency);
00264 TiXmlText * frequency_text = new TiXmlText(SSTR(msg.frequency));
00265 frequency->LinkEndChild(frequency_text);
00266
00268 TiXmlElement* frame_id = new TiXmlElement("frame_id");
00269 sonar_specifications->LinkEndChild(frame_id);
00270 TiXmlText * frame_id_text = new TiXmlText(SSTR(msg.frame_id));
00271 frame_id->LinkEndChild(frame_id_text);
00272
00274 messageToXmlElement(msg.pose,sonar_specifications);
00275
00277 messageToXmlElement(msg.noise,sonar_specifications);
00278 }
00279
00282 template void XmlFileWriter::messageToFile
00283 (stdr_msgs::RfidSensorMsg msg,std::string file_name);
00284
00286 template <>
00287 void XmlFileWriter::messageToXmlElement<stdr_msgs::RfidSensorMsg>
00288 (stdr_msgs::RfidSensorMsg msg,TiXmlNode* base){
00289
00291 TiXmlElement* rfidReader = new TiXmlElement("rfid_reader");
00292 base->LinkEndChild(rfidReader);
00293
00295 TiXmlElement* rfid_reader_specifications =
00296 new TiXmlElement("rfid_reader_specifications");
00297 rfidReader->LinkEndChild(rfid_reader_specifications);
00298
00300 TiXmlElement* maxRange = new TiXmlElement("max_range");
00301 rfid_reader_specifications->LinkEndChild(maxRange);
00302 TiXmlText * maxRange_text = new TiXmlText(SSTR(msg.maxRange));
00303 maxRange->LinkEndChild(maxRange_text);
00304
00306 TiXmlElement* angleSpan = new TiXmlElement("angle_span");
00307 rfid_reader_specifications->LinkEndChild(angleSpan);
00308 TiXmlText * angleSpan_text = new TiXmlText(SSTR(msg.angleSpan));
00309 angleSpan->LinkEndChild(angleSpan_text);
00310
00312 TiXmlElement* signalCutoff = new TiXmlElement("signal_cutoff");
00313 rfid_reader_specifications->LinkEndChild(signalCutoff);
00314 TiXmlText * signalCutoff_text = new TiXmlText(SSTR(msg.signalCutoff));
00315 signalCutoff->LinkEndChild(signalCutoff_text);
00316
00318 TiXmlElement* frequency = new TiXmlElement("frequency");
00319 rfid_reader_specifications->LinkEndChild(frequency);
00320 TiXmlText * frequency_text = new TiXmlText(SSTR(msg.frequency));
00321 frequency->LinkEndChild(frequency_text);
00322
00324 TiXmlElement* frame_id = new TiXmlElement("frame_id");
00325 rfid_reader_specifications->LinkEndChild(frame_id);
00326 TiXmlText * frame_id_text = new TiXmlText(SSTR(msg.frame_id));
00327 frame_id->LinkEndChild(frame_id_text);
00328
00330 messageToXmlElement(msg.pose,rfid_reader_specifications);
00331 }
00334 template void XmlFileWriter::messageToFile
00335 (stdr_msgs::CO2SensorMsg msg,std::string file_name);
00336
00338 template <>
00339 void XmlFileWriter::messageToXmlElement<stdr_msgs::CO2SensorMsg>
00340 (stdr_msgs::CO2SensorMsg msg,TiXmlNode* base){
00341
00343 TiXmlElement* sensor = new TiXmlElement("co2_sensor");
00344 base->LinkEndChild(sensor);
00345
00347 TiXmlElement* sensor_specifications =
00348 new TiXmlElement("co2_sensor_specifications");
00349 sensor->LinkEndChild(sensor_specifications);
00350
00352 TiXmlElement* maxRange = new TiXmlElement("max_range");
00353 sensor_specifications->LinkEndChild(maxRange);
00354 TiXmlText * maxRange_text = new TiXmlText(SSTR(msg.maxRange));
00355 maxRange->LinkEndChild(maxRange_text);
00356
00358
00359
00360
00361
00362
00364
00365
00366
00367
00368
00370 TiXmlElement* frequency = new TiXmlElement("frequency");
00371 sensor_specifications->LinkEndChild(frequency);
00372 TiXmlText * frequency_text = new TiXmlText(SSTR(msg.frequency));
00373 frequency->LinkEndChild(frequency_text);
00374
00376 TiXmlElement* frame_id = new TiXmlElement("frame_id");
00377 sensor_specifications->LinkEndChild(frame_id);
00378 TiXmlText * frame_id_text = new TiXmlText(SSTR(msg.frame_id));
00379 frame_id->LinkEndChild(frame_id_text);
00380
00382 messageToXmlElement(msg.pose,sensor_specifications);
00383 }
00386 template void XmlFileWriter::messageToFile
00387 (stdr_msgs::ThermalSensorMsg msg,std::string file_name);
00388
00390 template <>
00391 void XmlFileWriter::messageToXmlElement<stdr_msgs::ThermalSensorMsg>
00392 (stdr_msgs::ThermalSensorMsg msg,TiXmlNode* base){
00393
00395 TiXmlElement* sensor = new TiXmlElement("thermal_sensor");
00396 base->LinkEndChild(sensor);
00397
00399 TiXmlElement* sensor_specifications =
00400 new TiXmlElement("thermal_sensor_specifications");
00401 sensor->LinkEndChild(sensor_specifications);
00402
00404 TiXmlElement* maxRange = new TiXmlElement("max_range");
00405 sensor_specifications->LinkEndChild(maxRange);
00406 TiXmlText * maxRange_text = new TiXmlText(SSTR(msg.maxRange));
00407 maxRange->LinkEndChild(maxRange_text);
00408
00410 TiXmlElement* angleSpan = new TiXmlElement("angle_span");
00411 sensor_specifications->LinkEndChild(angleSpan);
00412 TiXmlText * angleSpan_text = new TiXmlText(SSTR(msg.angleSpan));
00413 angleSpan->LinkEndChild(angleSpan_text);
00414
00416
00417
00418
00419
00420
00422 TiXmlElement* frequency = new TiXmlElement("frequency");
00423 sensor_specifications->LinkEndChild(frequency);
00424 TiXmlText * frequency_text = new TiXmlText(SSTR(msg.frequency));
00425 frequency->LinkEndChild(frequency_text);
00426
00428 TiXmlElement* frame_id = new TiXmlElement("frame_id");
00429 sensor_specifications->LinkEndChild(frame_id);
00430 TiXmlText * frame_id_text = new TiXmlText(SSTR(msg.frame_id));
00431 frame_id->LinkEndChild(frame_id_text);
00432
00434 messageToXmlElement(msg.pose,sensor_specifications);
00435 }
00438 template void XmlFileWriter::messageToFile
00439 (stdr_msgs::SoundSensorMsg msg,std::string file_name);
00440
00442 template <>
00443 void XmlFileWriter::messageToXmlElement<stdr_msgs::SoundSensorMsg>
00444 (stdr_msgs::SoundSensorMsg msg,TiXmlNode* base){
00445
00447 TiXmlElement* sensor = new TiXmlElement("sound_sensor");
00448 base->LinkEndChild(sensor);
00449
00451 TiXmlElement* sensor_specifications =
00452 new TiXmlElement("sound_sensor_specifications");
00453 sensor->LinkEndChild(sensor_specifications);
00454
00456 TiXmlElement* maxRange = new TiXmlElement("max_range");
00457 sensor_specifications->LinkEndChild(maxRange);
00458 TiXmlText * maxRange_text = new TiXmlText(SSTR(msg.maxRange));
00459 maxRange->LinkEndChild(maxRange_text);
00460
00462 TiXmlElement* angleSpan = new TiXmlElement("angle_span");
00463 sensor_specifications->LinkEndChild(angleSpan);
00464 TiXmlText * angleSpan_text = new TiXmlText(SSTR(msg.angleSpan));
00465 angleSpan->LinkEndChild(angleSpan_text);
00466
00468
00469
00470
00471
00472
00474 TiXmlElement* frequency = new TiXmlElement("frequency");
00475 sensor_specifications->LinkEndChild(frequency);
00476 TiXmlText * frequency_text = new TiXmlText(SSTR(msg.frequency));
00477 frequency->LinkEndChild(frequency_text);
00478
00480 TiXmlElement* frame_id = new TiXmlElement("frame_id");
00481 sensor_specifications->LinkEndChild(frame_id);
00482 TiXmlText * frame_id_text = new TiXmlText(SSTR(msg.frame_id));
00483 frame_id->LinkEndChild(frame_id_text);
00484
00486 messageToXmlElement(msg.pose,sensor_specifications);
00487 }
00488
00491 template void XmlFileWriter::messageToFile
00492 (stdr_msgs::RobotMsg msg,std::string file_name);
00493
00495 template <>
00496 void XmlFileWriter::messageToXmlElement<stdr_msgs::RobotMsg>
00497 (stdr_msgs::RobotMsg msg,TiXmlNode* base){
00498
00500 TiXmlElement* robot = new TiXmlElement("robot");
00501 base->LinkEndChild(robot);
00502
00504 TiXmlElement* robot_specifications =
00505 new TiXmlElement("robot_specifications");
00506 robot->LinkEndChild(robot_specifications);
00507
00509 TiXmlElement* pose;
00510 pose = new TiXmlElement("initial_pose");
00511 robot_specifications->LinkEndChild(pose);
00512
00514 TiXmlElement* x;
00515 x = new TiXmlElement("x");
00516 pose->LinkEndChild(x);
00517 TiXmlText * x_text = new TiXmlText(SSTR(msg.initialPose.x));
00518 x->LinkEndChild(x_text);
00519
00521 TiXmlElement* y;
00522 y = new TiXmlElement("y");
00523 pose->LinkEndChild(y);
00524 TiXmlText * y_text = new TiXmlText(SSTR(msg.initialPose.y));
00525 y->LinkEndChild(y_text);
00526
00528 TiXmlElement* theta;
00529 theta = new TiXmlElement("theta");
00530 pose->LinkEndChild(theta);
00531 TiXmlText * theta_text = new TiXmlText(SSTR(msg.initialPose.theta));
00532 theta->LinkEndChild(theta_text);
00533
00535 messageToXmlElement(msg.footprint,robot_specifications);
00536
00538 for(unsigned int i = 0 ; i < msg.laserSensors.size() ; i++)
00539 {
00540 messageToXmlElement(msg.laserSensors[i],robot_specifications);
00541 }
00542
00544 for(unsigned int i = 0 ; i < msg.sonarSensors.size() ; i++)
00545 {
00546 messageToXmlElement(msg.sonarSensors[i],robot_specifications);
00547 }
00548
00550 for(unsigned int i = 0 ; i < msg.rfidSensors.size() ; i++)
00551 {
00552 messageToXmlElement(msg.rfidSensors[i],robot_specifications);
00553 }
00554
00555 for(unsigned int i = 0 ; i < msg.co2Sensors.size() ; i++)
00556 {
00557 messageToXmlElement(msg.co2Sensors[i],robot_specifications);
00558 }
00559
00560 for(unsigned int i = 0 ; i < msg.thermalSensors.size() ; i++)
00561 {
00562 messageToXmlElement(msg.thermalSensors[i],robot_specifications);
00563 }
00564
00565 for(unsigned int i = 0 ; i < msg.soundSensors.size() ; i++)
00566 {
00567 messageToXmlElement(msg.soundSensors[i],robot_specifications);
00568 }
00569 }
00570
00572
00579 template <class T>
00580 void XmlFileWriter::messageToXmlElement(T msg,TiXmlNode* base)
00581 {
00582 }
00583
00590 template <class T>
00591 void XmlFileWriter::messageToFile(T msg,std::string file_name)
00592 {
00593 TiXmlDocument doc;
00594 messageToXmlElement<T>(msg,&doc);
00595 doc.SaveFile(file_name.c_str());
00596 }
00597 }
00598