stdr_parser_yaml_file_writer.cpp
Go to the documentation of this file.
1 /******************************************************************************
2  STDR Simulator - Simple Two DImensional Robot Simulator
3  Copyright (C) 2013 STDR Simulator
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 3 of the License, or
7  (at your option) any later version.
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  GNU General Public License for more details.
12  You should have received a copy of the GNU General Public License
13  along with this program; if not, write to the Free Software Foundation,
14  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15 
16  Authors :
17  * Manos Tsardoulias, etsardou@gmail.com
18  * Aris Thallas, aris.thallas@gmail.com
19  * Chris Zalidis, zalidis@gmail.com
20 ******************************************************************************/
21 
23 
24 namespace stdr_parser
25 {
26 
32  {
33 
34  }
35 
38  template void YamlFileWriter::messageToFile
39  (stdr_msgs::Noise msg,std::string file_name);
40 
42  template <>
43  YAML::Emitter& operator << <stdr_msgs::Noise>
44  (YAML::Emitter& out, const stdr_msgs::Noise& msg)
45  {
46  out << YAML::BeginMap;
47  out << YAML::Key << "noise";
48  out << YAML::Value;
49  out << YAML::BeginMap;
50  out << YAML::Key << "noise_specifications";
51  out << YAML::Value;
52  out << YAML::BeginMap;
53  out << YAML::Key << "noise_mean" << YAML::Value << msg.noiseMean;
54  out << YAML::Key << "noise_std" << YAML::Value << msg.noiseStd;
55  out << YAML::EndMap;
56  out << YAML::EndMap;
57  out << YAML::EndMap;
58  return out;
59  }
60 
63  template void YamlFileWriter::messageToFile
64  (stdr_msgs::FootprintMsg msg,std::string file_name);
65 
67  template <>
68  YAML::Emitter& operator << <stdr_msgs::FootprintMsg>
69  (YAML::Emitter& out, const stdr_msgs::FootprintMsg& msg)
70  {
71  out << YAML::BeginMap;
72  out << YAML::Key << "footprint";
73  out << YAML::Value;
74  out << YAML::BeginMap;
75  out << YAML::Key << "footprint_specifications";
76  out << YAML::Value;
77  out << YAML::BeginMap;
78  out << YAML::Key << "radius" << YAML::Value << msg.radius;
79  out << YAML::Key << "points";
80  out << YAML::Value;
81  out << YAML::BeginSeq;
82  for(unsigned int i = 0 ; i < msg.points.size() ; i++)
83  {
84  out << YAML::BeginMap;
85  out << YAML::Key << "point";
86  out << YAML::Value;
87  out << YAML::BeginMap;
88  out << YAML::Key << "x" << YAML::Value << msg.points[i].x;
89  out << YAML::Key << "y" << YAML::Value << msg.points[i].y;
90  out << YAML::EndMap;
91  out << YAML::EndMap;
92  }
93  out << YAML::EndSeq;
94  out << YAML::EndMap;
95  out << YAML::EndMap;
96  out << YAML::EndMap;
97  return out;
98  }
99 
102  template void YamlFileWriter::messageToFile
103  (geometry_msgs::Pose2D msg,std::string file_name);
104 
106  template <>
107  YAML::Emitter& operator << <geometry_msgs::Pose2D>
108  (YAML::Emitter& out, const geometry_msgs::Pose2D& msg)
109  {
110  out << YAML::BeginMap;
111  out << YAML::Key << "pose";
112  out << YAML::Value;
113  out << YAML::BeginMap;
114  out << YAML::Key << "x" << YAML::Value << msg.x;
115  out << YAML::Key << "y" << YAML::Value << msg.y;
116  out << YAML::Key << "theta" << YAML::Value << msg.theta;
117  out << YAML::EndMap;
118  out << YAML::EndMap;
119  return out;
120  }
121 
124  template void YamlFileWriter::messageToFile
125  (stdr_msgs::KinematicMsg msg,std::string file_name);
126 
128  template <>
129  YAML::Emitter& operator << <stdr_msgs::KinematicMsg>
130  (YAML::Emitter& out, const stdr_msgs::KinematicMsg& msg)
131  {
132  out << YAML::BeginMap;
133  out << YAML::Key << "kinematic";
134  out << YAML::Value;
135  out << YAML::BeginMap;
136  out << YAML::Key << "kinematic_specifications";
137  out << YAML::Value;
138  out << YAML::BeginMap;
139  out << YAML::Key << "kinematic_type" << YAML::Value << msg.type;
140  out << YAML::Key << "kinematic_parameters";
141  out << YAML::Value;
142  out << YAML::BeginMap;
143  out << YAML::Key << "a_ux_ux" << YAML::Value << msg.a_ux_ux;
144  out << YAML::Key << "a_ux_uy" << YAML::Value << msg.a_ux_uy;
145  out << YAML::Key << "a_ux_w" << YAML::Value << msg.a_ux_w;
146  out << YAML::Key << "a_uy_ux" << YAML::Value << msg.a_uy_ux;
147  out << YAML::Key << "a_uy_uy" << YAML::Value << msg.a_uy_uy;
148  out << YAML::Key << "a_uy_w" << YAML::Value << msg.a_uy_w;
149  out << YAML::Key << "a_w_ux" << YAML::Value << msg.a_w_ux;
150  out << YAML::Key << "a_w_uy" << YAML::Value << msg.a_w_uy;
151  out << YAML::Key << "a_w_w" << YAML::Value << msg.a_w_w;
152  out << YAML::Key << "a_g_ux" << YAML::Value << msg.a_g_ux;
153  out << YAML::Key << "a_g_uy" << YAML::Value << msg.a_g_uy;
154  out << YAML::Key << "a_g_w" << YAML::Value << msg.a_g_w;
155  out << YAML::EndMap;
156  out << YAML::EndMap;
157  out << YAML::EndMap;
158  out << YAML::EndMap;
159  return out;
160  }
161 
162 
165  template void YamlFileWriter::messageToFile
166  (stdr_msgs::LaserSensorMsg msg,std::string file_name);
167 
169  template <>
170  YAML::Emitter& operator << <stdr_msgs::LaserSensorMsg>
171  (YAML::Emitter& out, const stdr_msgs::LaserSensorMsg& msg)
172  {
173  out << YAML::BeginMap;
174  out << YAML::Key << "laser";
175  out << YAML::Value;
176  out << YAML::BeginMap;
177  out << YAML::Key << "laser_specifications";
178  out << YAML::Value;
179  out << YAML::BeginMap;
180  out << YAML::Key << "max_angle" << YAML::Value << msg.maxAngle;
181  out << YAML::Key << "min_angle" << YAML::Value << msg.minAngle;
182  out << YAML::Key << "max_range" << YAML::Value << msg.maxRange;
183  out << YAML::Key << "min_range" << YAML::Value << msg.minRange;
184  out << YAML::Key << "num_rays" << YAML::Value << msg.numRays;
185  out << YAML::Key << "frequency" << YAML::Value << msg.frequency;
186  out << YAML::Key << "frame_id" << YAML::Value << msg.frame_id;
187  out << YAML::Key << "pose";
188  out << YAML::Value;
189  out << YAML::BeginMap;
190  out << YAML::Key << "x" << YAML::Value << msg.pose.x;
191  out << YAML::Key << "y" << YAML::Value << msg.pose.y;
192  out << YAML::Key << "theta" << YAML::Value << msg.pose.theta;
193  out << YAML::EndMap;
194  out << YAML::Key << "noise";
195  out << YAML::Value;
196  out << YAML::BeginMap;
197  out << YAML::Key << "noise_specifications";
198  out << YAML::Value;
199  out << YAML::BeginMap;
200  out << YAML::Key << "noise_mean";
201  out << YAML::Value << msg.noise.noiseMean;
202  out << YAML::Key << "noise_std";
203  out << YAML::Value << msg.noise.noiseStd;
204  out << YAML::EndMap;
205  out << YAML::EndMap;
206  out << YAML::EndMap;
207  out << YAML::EndMap;
208  out << YAML::EndMap;
209  return out;
210  }
211 
214  template void YamlFileWriter::messageToFile
215  (stdr_msgs::SonarSensorMsg msg,std::string file_name);
216 
218  template <>
219  YAML::Emitter& operator << <stdr_msgs::SonarSensorMsg>
220  (YAML::Emitter& out, const stdr_msgs::SonarSensorMsg& msg)
221  {
222  out << YAML::BeginMap;
223  out << YAML::Key << "sonar";
224  out << YAML::Value;
225  out << YAML::BeginMap;
226  out << YAML::Key << "sonar_specifications";
227  out << YAML::Value;
228  out << YAML::BeginMap;
229  out << YAML::Key << "cone_angle" << YAML::Value << msg.coneAngle;
230  out << YAML::Key << "max_range" << YAML::Value << msg.maxRange;
231  out << YAML::Key << "min_range" << YAML::Value << msg.minRange;
232  out << YAML::Key << "frequency" << YAML::Value << msg.frequency;
233  out << YAML::Key << "frame_id" << YAML::Value << msg.frame_id;
234  out << YAML::Key << "pose";
235  out << YAML::Value;
236  out << YAML::BeginMap;
237  out << YAML::Key << "x" << YAML::Value << msg.pose.x;
238  out << YAML::Key << "y" << YAML::Value << msg.pose.y;
239  out << YAML::Key << "theta" << YAML::Value << msg.pose.theta;
240  out << YAML::EndMap;
241  out << YAML::Key << "noise";
242  out << YAML::Value;
243  out << YAML::BeginMap;
244  out << YAML::Key << "noise_specifications";
245  out << YAML::Value;
246  out << YAML::BeginMap;
247  out << YAML::Key << "noise_mean";
248  out << YAML::Value << msg.noise.noiseMean;
249  out << YAML::Key << "noise_std";
250  out << YAML::Value << msg.noise.noiseStd;
251  out << YAML::EndMap;
252  out << YAML::EndMap;
253  out << YAML::EndMap;
254  out << YAML::EndMap;
255  out << YAML::EndMap;
256  return out;
257  }
260  template void YamlFileWriter::messageToFile
261  (stdr_msgs::RfidSensorMsg msg,std::string file_name);
262 
264  template <>
265  YAML::Emitter& operator << <stdr_msgs::RfidSensorMsg>
266  (YAML::Emitter& out, const stdr_msgs::RfidSensorMsg& msg)
267  {
268  out << YAML::BeginMap;
269  out << YAML::Key << "rfid_reader";
270  out << YAML::Value;
271  out << YAML::BeginMap;
272  out << YAML::Key << "rfid_reader_specifications";
273  out << YAML::Value;
274  out << YAML::BeginMap;
275  out << YAML::Key << "angle_span" << YAML::Value << msg.angleSpan;
276  out << YAML::Key << "max_range" << YAML::Value << msg.maxRange;
277  out << YAML::Key << "signal_cutoff" << YAML::Value << msg.signalCutoff;
278  out << YAML::Key << "frequency" << YAML::Value << msg.frequency;
279  out << YAML::Key << "frame_id" << YAML::Value << msg.frame_id;
280  out << YAML::Key << "pose";
281  out << YAML::Value;
282  out << YAML::BeginMap;
283  out << YAML::Key << "x" << YAML::Value << msg.pose.x;
284  out << YAML::Key << "y" << YAML::Value << msg.pose.y;
285  out << YAML::Key << "theta" << YAML::Value << msg.pose.theta;
286  out << YAML::EndMap;
287  out << YAML::EndMap;
288  out << YAML::EndMap;
289  out << YAML::EndMap;
290  return out;
291  }
294  template void YamlFileWriter::messageToFile
295  (stdr_msgs::CO2SensorMsg msg,std::string file_name);
296 
298  template <>
299  YAML::Emitter& operator << <stdr_msgs::CO2SensorMsg>
300  (YAML::Emitter& out, const stdr_msgs::CO2SensorMsg& msg)
301  {
302  out << YAML::BeginMap;
303  out << YAML::Key << "co2_sensor";
304  out << YAML::Value;
305  out << YAML::BeginMap;
306  out << YAML::Key << "co2_sensor_specifications";
307  out << YAML::Value;
308  out << YAML::BeginMap;
309  //~ out << YAML::Key << "angle_span" << YAML::Value << msg.angleSpan;
310  out << YAML::Key << "max_range" << YAML::Value << msg.maxRange;
311  //~ out << YAML::Key << "signal_cutoff" << YAML::Value << msg.signalCutoff;
312  out << YAML::Key << "frequency" << YAML::Value << msg.frequency;
313  out << YAML::Key << "frame_id" << YAML::Value << msg.frame_id;
314  out << YAML::Key << "pose";
315  out << YAML::Value;
316  out << YAML::BeginMap;
317  out << YAML::Key << "x" << YAML::Value << msg.pose.x;
318  out << YAML::Key << "y" << YAML::Value << msg.pose.y;
319  out << YAML::Key << "theta" << YAML::Value << msg.pose.theta;
320  out << YAML::EndMap;
321  out << YAML::EndMap;
322  out << YAML::EndMap;
323  out << YAML::EndMap;
324  return out;
325  }
328  template void YamlFileWriter::messageToFile
329  (stdr_msgs::ThermalSensorMsg msg,std::string file_name);
330 
332  template <>
333  YAML::Emitter& operator << <stdr_msgs::ThermalSensorMsg>
334  (YAML::Emitter& out, const stdr_msgs::ThermalSensorMsg& msg)
335  {
336  out << YAML::BeginMap;
337  out << YAML::Key << "thermal_sensor";
338  out << YAML::Value;
339  out << YAML::BeginMap;
340  out << YAML::Key << "thermal_sensor_specifications";
341  out << YAML::Value;
342  out << YAML::BeginMap;
343  out << YAML::Key << "angle_span" << YAML::Value << msg.angleSpan;
344  out << YAML::Key << "max_range" << YAML::Value << msg.maxRange;
345  out << YAML::Key << "frequency" << YAML::Value << msg.frequency;
346  out << YAML::Key << "frame_id" << YAML::Value << msg.frame_id;
347  out << YAML::Key << "pose";
348  out << YAML::Value;
349  out << YAML::BeginMap;
350  out << YAML::Key << "x" << YAML::Value << msg.pose.x;
351  out << YAML::Key << "y" << YAML::Value << msg.pose.y;
352  out << YAML::Key << "theta" << YAML::Value << msg.pose.theta;
353  out << YAML::EndMap;
354  out << YAML::EndMap;
355  out << YAML::EndMap;
356  out << YAML::EndMap;
357  return out;
358  }
361  template void YamlFileWriter::messageToFile
362  (stdr_msgs::SoundSensorMsg msg,std::string file_name);
363 
365  template <>
366  YAML::Emitter& operator << <stdr_msgs::SoundSensorMsg>
367  (YAML::Emitter& out, const stdr_msgs::SoundSensorMsg& msg)
368  {
369  out << YAML::BeginMap;
370  out << YAML::Key << "sound_sensor";
371  out << YAML::Value;
372  out << YAML::BeginMap;
373  out << YAML::Key << "sound_sensor_specifications";
374  out << YAML::Value;
375  out << YAML::BeginMap;
376  out << YAML::Key << "angle_span" << YAML::Value << msg.angleSpan;
377  out << YAML::Key << "max_range" << YAML::Value << msg.maxRange;
378  out << YAML::Key << "frequency" << YAML::Value << msg.frequency;
379  out << YAML::Key << "frame_id" << YAML::Value << msg.frame_id;
380  out << YAML::Key << "pose";
381  out << YAML::Value;
382  out << YAML::BeginMap;
383  out << YAML::Key << "x" << YAML::Value << msg.pose.x;
384  out << YAML::Key << "y" << YAML::Value << msg.pose.y;
385  out << YAML::Key << "theta" << YAML::Value << msg.pose.theta;
386  out << YAML::EndMap;
387  out << YAML::EndMap;
388  out << YAML::EndMap;
389  out << YAML::EndMap;
390  return out;
391  }
392 
395  template void YamlFileWriter::messageToFile
396  (stdr_msgs::RobotMsg msg,std::string file_name);
397 
399  template <>
400  YAML::Emitter& operator << <stdr_msgs::RobotMsg>
401  (YAML::Emitter& out, const stdr_msgs::RobotMsg& msg)
402  {
403  out << YAML::BeginMap;
404  out << YAML::Key << "robot";
405  out << YAML::Value;
406  out << YAML::BeginMap;
407  out << YAML::Key << "robot_specifications";
408  out << YAML::Value;
409  out << YAML::BeginSeq;
410  out << msg.footprint;
411  out << YAML::BeginMap;
412  out << YAML::Key << "initial_pose";
413  out << YAML::Value;
414  out << YAML::BeginMap;
415  out << YAML::Key << "x" << YAML::Value << msg.initialPose.x;
416  out << YAML::Key << "y" << YAML::Value << msg.initialPose.y;
417  out << YAML::Key << "theta" << YAML::Value << msg.initialPose.theta;
418  out << YAML::EndMap;
419  out << YAML::EndMap;
420  for(unsigned int i = 0 ; i < msg.laserSensors.size() ; i++)
421  {
422  out << msg.laserSensors[i];
423  }
424  for(unsigned int i = 0 ; i < msg.sonarSensors.size() ; i++)
425  {
426  out << msg.sonarSensors[i];
427  }
428  for(unsigned int i = 0 ; i < msg.rfidSensors.size() ; i++)
429  {
430  out << msg.rfidSensors[i];
431  }
432  for(unsigned int i = 0 ; i < msg.co2Sensors.size() ; i++)
433  {
434  out << msg.co2Sensors[i];
435  }
436  for(unsigned int i = 0 ; i < msg.thermalSensors.size() ; i++)
437  {
438  out << msg.thermalSensors[i];
439  }
440  for(unsigned int i = 0 ; i < msg.soundSensors.size() ; i++)
441  {
442  out << msg.soundSensors[i];
443  }
444 
445  // Kinematic model creation
446  out << msg.kinematicModel;
447 
448  out << YAML::EndSeq;
449  out << YAML::EndMap;
450  out << YAML::EndMap;
451  return out;
452  }
454 
461  template <class T>
462  void YamlFileWriter::messageToFile(T msg,std::string file_name)
463  {
464  YAML::Emitter out;
465  out << msg;
466 
467  std::ofstream sensorYamlFile;
468  sensorYamlFile.open(file_name.c_str());
469  sensorYamlFile << out.c_str();
470  sensorYamlFile.close();
471  }
472 
473 }
474 
static void messageToFile(T msg, std::string file_name)
Creates an yaml file from a message - template member function.
The main namespace for STDR GUI XML parser.
YamlFileWriter(void)
Default constructor.


stdr_parser
Author(s): Manos Tsardoulias, Chris Zalidis, Aris Thallas
autogenerated on Mon Jun 10 2019 15:14:54