Skip to content

Commit 63204a6

Browse files
authored
[RM] Add error handling for missing plugin tags in URDF parsing (backport #2138) (#2145)
1 parent a978e78 commit 63204a6

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

hardware_interface/src/component_parser.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,10 @@ TransmissionInfo parse_transmission_from_xml(const tinyxml2::XMLElement * transm
411411
// Find name, type and class of a transmission
412412
transmission.name = get_attribute_value(transmission_it, kNameAttribute, transmission_it->Name());
413413
const auto * type_it = transmission_it->FirstChildElement(kClassTypeTag);
414+
if (!type_it)
415+
{
416+
throw std::runtime_error("Missing <plugin> tag of <transmission> element in your URDF.");
417+
}
414418
transmission.type = get_text_for_element(type_it, kClassTypeTag);
415419

416420
// Parse joints
@@ -515,6 +519,10 @@ HardwareInfo parse_resource_from_xml(
515519
if (!std::string(kHardwareTag).compare(ros2_control_child_it->Name()))
516520
{
517521
const auto * type_it = ros2_control_child_it->FirstChildElement(kClassTypeTag);
522+
if (!type_it)
523+
{
524+
throw std::runtime_error("Missing <plugin> tag of <hardware> element in your URDF.");
525+
}
518526
hardware.hardware_class_type =
519527
get_text_for_element(type_it, std::string("hardware ") + kClassTypeTag);
520528
const auto * params_it = ros2_control_child_it->FirstChildElement(kParamTag);

0 commit comments

Comments
 (0)