51 Node *n,
unsigned int id)
53 geometry_msgs::Pose2D msg;
54 std::vector<int> indexes;
57 if(indexes.size() == 0)
60 msg.x = stdr_parser::MessageCreator::stringToType<float>(
66 msg.x = stdr_parser::MessageCreator::stringToType<float>(
67 n->
elements[indexes[0]]->elements[0]->value.c_str());
71 if(indexes.size() == 0)
73 msg.y = stdr_parser::MessageCreator::stringToType<float>(
78 msg.y = stdr_parser::MessageCreator::stringToType<float>(
79 n->
elements[indexes[0]]->elements[0]->value.c_str());
82 indexes = n->
getTag(
"theta");
83 if(indexes.size() == 0)
85 msg.theta = stdr_parser::MessageCreator::stringToType<float>(
90 msg.theta = stdr_parser::MessageCreator::stringToType<float>(
91 n->
elements[indexes[0]]->elements[0]->value.c_str());
104 geometry_msgs::Point msg;
105 std::vector<int> indexes;
108 if( indexes.size() == 0) {
109 msg.x = stdr_parser::MessageCreator::stringToType<float>(
112 msg.x = stdr_parser::MessageCreator::stringToType<float>(
113 n->
elements[indexes[0]]->elements[0]->value.c_str());
117 if( indexes.size() == 0) {
118 msg.y = stdr_parser::MessageCreator::stringToType<float>(
121 msg.y = stdr_parser::MessageCreator::stringToType<float>(
122 n->
elements[indexes[0]]->elements[0]->value.c_str());
126 if( indexes.size() == 0) {
127 msg.z = stdr_parser::MessageCreator::stringToType<float>(
130 msg.z = stdr_parser::MessageCreator::stringToType<float>(
131 n->
elements[indexes[0]]->elements[0]->value.c_str());
142 Node *n,
unsigned int id)
144 stdr_msgs::Noise msg;
146 if(specs->
tag ==
"noise")
150 std::vector<int> indexes;
152 indexes = specs->
getTag(
"noise_mean");
153 if(indexes.size() == 0)
155 msg.noiseMean = stdr_parser::MessageCreator::stringToType<float>(
160 msg.noiseMean = stdr_parser::MessageCreator::stringToType<float>(
161 specs->
elements[indexes[0]]->elements[0]->value.c_str());
164 indexes = specs->
getTag(
"noise_std");
165 if(indexes.size() == 0)
167 msg.noiseStd = stdr_parser::MessageCreator::stringToType<float>(
172 msg.noiseStd = stdr_parser::MessageCreator::stringToType<float>(
173 specs->
elements[indexes[0]]->elements[0]->value.c_str());
185 Node *n,
unsigned int id)
187 stdr_msgs::FootprintMsg msg;
189 if(specs->
tag ==
"footprint")
193 else if(specs->
tag ==
"footprint_specifications")
198 std::vector<int> indexes;
200 indexes = specs->
getTag(
"radius");
201 if(indexes.size() == 0)
203 msg.radius = stdr_parser::MessageCreator::stringToType<float>(
208 msg.radius = stdr_parser::MessageCreator::stringToType<float>(
209 specs->
elements[indexes[0]]->elements[0]->value);
212 indexes = specs->
getTag(
"points");
213 if( indexes.size() != 0 ) {
214 specs = specs->
elements[indexes[0]];
215 std::vector<int> points = specs->
getTag(
"point");
216 for(
unsigned int i = 0; i < points.size(); i++ ) {
217 msg.points.push_back(createMessage<geometry_msgs::Point>(
231 Node *n,
unsigned int id)
233 stdr_msgs::LaserSensorMsg msg;
235 if(specs->
tag ==
"laser")
239 std::vector<int> indexes;
242 indexes = specs->
getTag(
"max_angle");
243 if(indexes.size() == 0)
245 msg.maxAngle = stdr_parser::MessageCreator::stringToType<float>(
250 msg.maxAngle = stdr_parser::MessageCreator::stringToType<float>(
251 specs->
elements[indexes[0]]->elements[0]->value.c_str());
255 indexes = specs->
getTag(
"min_angle");
256 if(indexes.size() == 0)
258 msg.minAngle = stdr_parser::MessageCreator::stringToType<float>(
263 msg.minAngle = stdr_parser::MessageCreator::stringToType<float>(
264 specs->
elements[indexes[0]]->elements[0]->value.c_str());
268 indexes = specs->
getTag(
"max_range");
269 if(indexes.size() == 0)
271 msg.maxRange = stdr_parser::MessageCreator::stringToType<float>(
276 msg.maxRange = stdr_parser::MessageCreator::stringToType<float>(
277 specs->
elements[indexes[0]]->elements[0]->value.c_str());
281 indexes = specs->
getTag(
"min_range");
282 if(indexes.size() == 0)
284 msg.minRange = stdr_parser::MessageCreator::stringToType<float>(
289 msg.minRange = stdr_parser::MessageCreator::stringToType<float>(
290 specs->
elements[indexes[0]]->elements[0]->value.c_str());
294 indexes = specs->
getTag(
"num_rays");
295 if(indexes.size() == 0)
297 msg.numRays = stdr_parser::MessageCreator::stringToType<int>(
302 msg.numRays = stdr_parser::MessageCreator::stringToType<int>(
303 specs->
elements[indexes[0]]->elements[0]->value.c_str());
307 indexes = specs->
getTag(
"noise");
308 if(indexes.size() != 0)
311 createMessage<stdr_msgs::Noise>(specs->
elements[indexes[0]],0);
315 indexes = specs->
getTag(
"frequency");
316 if(indexes.size() == 0)
318 msg.frequency = stdr_parser::MessageCreator::stringToType<float>(
323 msg.frequency = stdr_parser::MessageCreator::stringToType<float>(
324 specs->
elements[indexes[0]]->elements[0]->value.c_str());
328 indexes = specs->
getTag(
"frame_id");
329 if(indexes.size() == 0)
331 msg.frame_id = std::string(
"laser_") +
SSTR(
id);
335 msg.frame_id = specs->
elements[indexes[0]]->elements[0]->value;
339 indexes = specs->
getTag(
"pose");
340 if(indexes.size() != 0)
343 createMessage<geometry_msgs::Pose2D>(specs->
elements[indexes[0]],0);
347 msg.pose.x = stdr_parser::MessageCreator::stringToType<float>(
349 msg.pose.y = stdr_parser::MessageCreator::stringToType<float>(
351 msg.pose.theta = stdr_parser::MessageCreator::stringToType<float>(
363 Node *n,
unsigned int id)
365 stdr_msgs::SonarSensorMsg msg;
367 if(specs->
tag ==
"sonar")
371 std::vector<int> indexes;
374 indexes = specs->
getTag(
"max_range");
375 if(indexes.size() == 0)
377 msg.maxRange = stdr_parser::MessageCreator::stringToType<float>(
382 msg.maxRange = stdr_parser::MessageCreator::stringToType<float>(
383 specs->
elements[indexes[0]]->elements[0]->value.c_str());
387 indexes = specs->
getTag(
"min_range");
388 if(indexes.size() == 0)
390 msg.minRange = stdr_parser::MessageCreator::stringToType<float>(
395 msg.minRange = stdr_parser::MessageCreator::stringToType<float>(
396 specs->
elements[indexes[0]]->elements[0]->value.c_str());
400 indexes = specs->
getTag(
"cone_angle");
401 if(indexes.size() == 0)
403 msg.coneAngle = stdr_parser::MessageCreator::stringToType<float>(
408 msg.coneAngle = stdr_parser::MessageCreator::stringToType<float>(
409 specs->
elements[indexes[0]]->elements[0]->value.c_str());
413 indexes = specs->
getTag(
"noise");
414 if(indexes.size() != 0)
417 createMessage<stdr_msgs::Noise>(specs->
elements[indexes[0]],0);
421 indexes = specs->
getTag(
"frequency");
422 if(indexes.size() == 0)
424 msg.frequency = stdr_parser::MessageCreator::stringToType<float>(
429 msg.frequency = stdr_parser::MessageCreator::stringToType<float>(
430 specs->
elements[indexes[0]]->elements[0]->value.c_str());
434 indexes = specs->
getTag(
"frame_id");
435 if(indexes.size() == 0)
437 msg.frame_id = std::string(
"sonar_") +
SSTR(
id);
441 msg.frame_id = specs->
elements[indexes[0]]->elements[0]->value;
445 indexes = specs->
getTag(
"pose");
446 if(indexes.size() != 0)
449 createMessage<geometry_msgs::Pose2D>(specs->
elements[indexes[0]],0);
453 msg.pose.x = stdr_parser::MessageCreator::stringToType<float>(
455 msg.pose.y = stdr_parser::MessageCreator::stringToType<float>(
457 msg.pose.theta = stdr_parser::MessageCreator::stringToType<float>(
470 Node *n,
unsigned int id)
472 stdr_msgs::RfidSensorMsg msg;
474 if(specs->
tag ==
"rfid_reader")
478 std::vector<int> indexes;
481 indexes = specs->
getTag(
"angle_span");
482 if(indexes.size() == 0)
484 msg.angleSpan = stdr_parser::MessageCreator::stringToType<float>(
489 msg.angleSpan = stdr_parser::MessageCreator::stringToType<float>(
490 specs->
elements[indexes[0]]->elements[0]->value.c_str());
494 indexes = specs->
getTag(
"max_range");
495 if(indexes.size() == 0)
497 msg.maxRange = stdr_parser::MessageCreator::stringToType<float>(
502 msg.maxRange = stdr_parser::MessageCreator::stringToType<float>(
503 specs->
elements[indexes[0]]->elements[0]->value.c_str());
507 indexes = specs->
getTag(
"signal_cutoff");
508 if(indexes.size() == 0)
510 msg.signalCutoff = stdr_parser::MessageCreator::stringToType<float>(
515 msg.signalCutoff = stdr_parser::MessageCreator::stringToType<float>(
516 specs->
elements[indexes[0]]->elements[0]->value.c_str());
520 indexes = specs->
getTag(
"frequency");
521 if(indexes.size() == 0)
523 msg.frequency = stdr_parser::MessageCreator::stringToType<float>(
528 msg.frequency = stdr_parser::MessageCreator::stringToType<float>(
529 specs->
elements[indexes[0]]->elements[0]->value.c_str());
533 indexes = specs->
getTag(
"frame_id");
534 if(indexes.size() == 0)
536 msg.frame_id = std::string(
"rfid_reader_") +
SSTR(
id);
540 msg.frame_id = specs->
elements[indexes[0]]->elements[0]->value;
544 indexes = specs->
getTag(
"pose");
545 if(indexes.size() != 0)
548 createMessage<geometry_msgs::Pose2D>(specs->
elements[indexes[0]],0);
552 msg.pose.x = stdr_parser::MessageCreator::stringToType<float>(
554 msg.pose.y = stdr_parser::MessageCreator::stringToType<float>(
556 msg.pose.theta = stdr_parser::MessageCreator::stringToType<float>(
569 Node *n,
unsigned int id)
571 stdr_msgs::CO2SensorMsg msg;
573 if(specs->
tag ==
"co2_sensor")
577 std::vector<int> indexes;
580 indexes = specs->
getTag(
"max_range");
581 if(indexes.size() == 0)
583 msg.maxRange = stdr_parser::MessageCreator::stringToType<float>(
588 msg.maxRange = stdr_parser::MessageCreator::stringToType<float>(
589 specs->
elements[indexes[0]]->elements[0]->value.c_str());
593 indexes = specs->
getTag(
"frequency");
594 if(indexes.size() == 0)
596 msg.frequency = stdr_parser::MessageCreator::stringToType<float>(
601 msg.frequency = stdr_parser::MessageCreator::stringToType<float>(
602 specs->
elements[indexes[0]]->elements[0]->value.c_str());
606 indexes = specs->
getTag(
"frame_id");
607 if(indexes.size() == 0)
609 msg.frame_id = std::string(
"co2_sensor_") +
SSTR(
id);
613 msg.frame_id = specs->
elements[indexes[0]]->elements[0]->value;
617 indexes = specs->
getTag(
"pose");
618 if(indexes.size() != 0)
621 createMessage<geometry_msgs::Pose2D>(specs->
elements[indexes[0]],0);
625 msg.pose.x = stdr_parser::MessageCreator::stringToType<float>(
627 msg.pose.y = stdr_parser::MessageCreator::stringToType<float>(
629 msg.pose.theta = stdr_parser::MessageCreator::stringToType<float>(
642 Node *n,
unsigned int id)
644 stdr_msgs::ThermalSensorMsg msg;
646 if(specs->
tag ==
"thermal_sensor")
650 std::vector<int> indexes;
653 indexes = specs->
getTag(
"max_range");
654 if(indexes.size() == 0)
656 msg.maxRange = stdr_parser::MessageCreator::stringToType<float>(
661 msg.maxRange = stdr_parser::MessageCreator::stringToType<float>(
662 specs->
elements[indexes[0]]->elements[0]->value.c_str());
666 indexes = specs->
getTag(
"angle_span");
667 if(indexes.size() == 0)
669 msg.angleSpan = stdr_parser::MessageCreator::stringToType<float>(
674 msg.angleSpan = stdr_parser::MessageCreator::stringToType<float>(
675 specs->
elements[indexes[0]]->elements[0]->value.c_str());
679 indexes = specs->
getTag(
"frequency");
680 if(indexes.size() == 0)
682 msg.frequency = stdr_parser::MessageCreator::stringToType<float>(
687 msg.frequency = stdr_parser::MessageCreator::stringToType<float>(
688 specs->
elements[indexes[0]]->elements[0]->value.c_str());
692 indexes = specs->
getTag(
"frame_id");
693 if(indexes.size() == 0)
695 msg.frame_id = std::string(
"thermal_sensor_") +
SSTR(
id);
699 msg.frame_id = specs->
elements[indexes[0]]->elements[0]->value;
703 indexes = specs->
getTag(
"pose");
704 if(indexes.size() != 0)
707 createMessage<geometry_msgs::Pose2D>(specs->
elements[indexes[0]],0);
711 msg.pose.x = stdr_parser::MessageCreator::stringToType<float>(
713 msg.pose.y = stdr_parser::MessageCreator::stringToType<float>(
715 msg.pose.theta = stdr_parser::MessageCreator::stringToType<float>(
728 Node *n,
unsigned int id)
730 stdr_msgs::SoundSensorMsg msg;
732 if(specs->
tag ==
"sound_sensor")
736 std::vector<int> indexes;
739 indexes = specs->
getTag(
"max_range");
740 if(indexes.size() == 0)
742 msg.maxRange = stdr_parser::MessageCreator::stringToType<float>(
747 msg.maxRange = stdr_parser::MessageCreator::stringToType<float>(
748 specs->
elements[indexes[0]]->elements[0]->value.c_str());
752 indexes = specs->
getTag(
"angle_span");
753 if(indexes.size() == 0)
755 msg.angleSpan = stdr_parser::MessageCreator::stringToType<float>(
760 msg.angleSpan = stdr_parser::MessageCreator::stringToType<float>(
761 specs->
elements[indexes[0]]->elements[0]->value.c_str());
765 indexes = specs->
getTag(
"frequency");
766 if(indexes.size() == 0)
768 msg.frequency = stdr_parser::MessageCreator::stringToType<float>(
773 msg.frequency = stdr_parser::MessageCreator::stringToType<float>(
774 specs->
elements[indexes[0]]->elements[0]->value.c_str());
778 indexes = specs->
getTag(
"frame_id");
779 if(indexes.size() == 0)
781 msg.frame_id = std::string(
"sound_sensor_") +
SSTR(
id);
785 msg.frame_id = specs->
elements[indexes[0]]->elements[0]->value;
789 indexes = specs->
getTag(
"pose");
790 if(indexes.size() != 0)
793 createMessage<geometry_msgs::Pose2D>(specs->
elements[indexes[0]],0);
797 msg.pose.x = stdr_parser::MessageCreator::stringToType<float>(
799 msg.pose.y = stdr_parser::MessageCreator::stringToType<float>(
801 msg.pose.theta = stdr_parser::MessageCreator::stringToType<float>(
815 Node *n,
unsigned int id)
817 stdr_msgs::KinematicMsg msg;
819 if(specs->
tag ==
"kinematic")
823 std::vector<int> indexes;
826 indexes = specs->
getTag(
"kinematic_model");
827 if(indexes.size() == 0)
829 msg.type =
Specs::specs[
"kinematic_model"].default_value.c_str();
833 msg.type = specs->
elements[indexes[0]]->elements[0]->
838 indexes = specs->
getTag(
"kinematic_parameters");
839 if(indexes.size() == 0)
841 msg.a_ux_ux = stdr_parser::MessageCreator::stringToType<float>(
843 msg.a_ux_uy = stdr_parser::MessageCreator::stringToType<float>(
845 msg.a_ux_w = stdr_parser::MessageCreator::stringToType<float>(
848 msg.a_uy_ux = stdr_parser::MessageCreator::stringToType<float>(
850 msg.a_uy_uy = stdr_parser::MessageCreator::stringToType<float>(
852 msg.a_uy_w = stdr_parser::MessageCreator::stringToType<float>(
855 msg.a_w_ux = stdr_parser::MessageCreator::stringToType<float>(
857 msg.a_w_uy = stdr_parser::MessageCreator::stringToType<float>(
859 msg.a_w_w = stdr_parser::MessageCreator::stringToType<float>(
862 msg.a_g_ux = stdr_parser::MessageCreator::stringToType<float>(
864 msg.a_g_uy = stdr_parser::MessageCreator::stringToType<float>(
866 msg.a_g_w = stdr_parser::MessageCreator::stringToType<float>(
871 specs = specs->
elements[indexes[0]];
873 indexes = specs->
getTag(
"a_ux_ux");
874 msg.a_ux_ux = stdr_parser::MessageCreator::stringToType<float>(
875 specs->
elements[indexes[0]]->elements[0]->value.c_str());
876 indexes = specs->
getTag(
"a_ux_uy");
877 msg.a_ux_uy = stdr_parser::MessageCreator::stringToType<float>(
878 specs->
elements[indexes[0]]->elements[0]->value.c_str());
879 indexes = specs->
getTag(
"a_ux_w");
880 msg.a_ux_w = stdr_parser::MessageCreator::stringToType<float>(
881 specs->
elements[indexes[0]]->elements[0]->value.c_str());
883 indexes = specs->
getTag(
"a_uy_ux");
884 msg.a_uy_ux = stdr_parser::MessageCreator::stringToType<float>(
885 specs->
elements[indexes[0]]->elements[0]->value.c_str());
886 indexes = specs->
getTag(
"a_uy_uy");
887 msg.a_uy_uy = stdr_parser::MessageCreator::stringToType<float>(
888 specs->
elements[indexes[0]]->elements[0]->value.c_str());
889 indexes = specs->
getTag(
"a_uy_w");
890 msg.a_uy_w = stdr_parser::MessageCreator::stringToType<float>(
891 specs->
elements[indexes[0]]->elements[0]->value.c_str());
893 indexes = specs->
getTag(
"a_w_ux");
894 msg.a_w_ux = stdr_parser::MessageCreator::stringToType<float>(
895 specs->
elements[indexes[0]]->elements[0]->value.c_str());
896 indexes = specs->
getTag(
"a_w_uy");
897 msg.a_w_uy = stdr_parser::MessageCreator::stringToType<float>(
898 specs->
elements[indexes[0]]->elements[0]->value.c_str());
899 indexes = specs->
getTag(
"a_w_w");
900 msg.a_w_w = stdr_parser::MessageCreator::stringToType<float>(
901 specs->
elements[indexes[0]]->elements[0]->value.c_str());
903 indexes = specs->
getTag(
"a_g_ux");
904 msg.a_g_ux = stdr_parser::MessageCreator::stringToType<float>(
905 specs->
elements[indexes[0]]->elements[0]->value.c_str());
906 indexes = specs->
getTag(
"a_g_uy");
907 msg.a_g_uy = stdr_parser::MessageCreator::stringToType<float>(
908 specs->
elements[indexes[0]]->elements[0]->value.c_str());
909 indexes = specs->
getTag(
"a_g_w");
910 msg.a_g_w = stdr_parser::MessageCreator::stringToType<float>(
911 specs->
elements[indexes[0]]->elements[0]->value.c_str());
925 stdr_msgs::RobotMsg msg;
927 if(specs->
tag ==
"robot")
931 std::vector<int> indexes;
934 indexes = specs->
getTag(
"initial_pose");
935 if(indexes.size() != 0)
938 createMessage<geometry_msgs::Pose2D>(specs->
elements[indexes[0]],0);
942 msg.initialPose.x = stdr_parser::MessageCreator::stringToType<float>(
944 msg.initialPose.y = stdr_parser::MessageCreator::stringToType<float>(
946 msg.initialPose.theta = stdr_parser::MessageCreator::stringToType<float>(
951 indexes = specs->
getTag(
"footprint");
952 if(indexes.size() != 0)
955 createMessage<stdr_msgs::FootprintMsg>(specs->
elements[indexes[0]],0);
959 msg.footprint.radius = stdr_parser::MessageCreator::stringToType<float>(
964 indexes = specs->
getTag(
"laser");
965 if(indexes.size() != 0)
967 for(
unsigned int i = 0 ; i < indexes.size() ; i++)
969 msg.laserSensors.push_back(
970 createMessage<stdr_msgs::LaserSensorMsg>(
976 indexes = specs->
getTag(
"sonar");
977 if(indexes.size() != 0)
979 for(
unsigned int i = 0 ; i < indexes.size() ; i++)
981 msg.sonarSensors.push_back(
982 createMessage<stdr_msgs::SonarSensorMsg>(
988 indexes = specs->
getTag(
"rfid_reader");
989 if(indexes.size() != 0)
991 for(
unsigned int i = 0 ; i < indexes.size() ; i++)
993 msg.rfidSensors.push_back(
994 createMessage<stdr_msgs::RfidSensorMsg>(
1000 indexes = specs->
getTag(
"co2_sensor");
1001 if(indexes.size() != 0)
1003 for(
unsigned int i = 0 ; i < indexes.size() ; i++)
1005 msg.co2Sensors.push_back(
1006 createMessage<stdr_msgs::CO2SensorMsg>(
1012 indexes = specs->
getTag(
"thermal_sensor");
1013 if(indexes.size() != 0)
1015 for(
unsigned int i = 0 ; i < indexes.size() ; i++)
1017 msg.thermalSensors.push_back(
1018 createMessage<stdr_msgs::ThermalSensorMsg>(
1024 indexes = specs->
getTag(
"sound_sensor");
1025 if(indexes.size() != 0)
1027 for(
unsigned int i = 0 ; i < indexes.size() ; i++)
1029 msg.soundSensors.push_back(
1030 createMessage<stdr_msgs::SoundSensorMsg>(
1036 indexes = specs->
getTag(
"kinematic");
1037 if(indexes.size() != 0)
1039 msg.kinematicModel = createMessage<stdr_msgs::KinematicMsg>(
std::string tag
The node value (if it not a tag node)
static T createMessage(Node *n, unsigned int id)
Creates a pose message from a parsed file.
std::vector< int > getTag(std::string tag)
Searches for a tag in the specific node.
The main namespace for STDR GUI XML parser.
static std::map< std::string, ElSpecs > specs
List of non-mergable tags. Read from stdr_multiple_allowed.xml.
MessageCreator(void)
Default constructor.
Implements the main functionalities of the stdr parser tree.
std::vector< Node * > elements
File it was into.