50 MoveItSetupTest::SetUp();
68 std::filesystem::path srdf_path =
output_dir_ /
"config" / (robot_name +
".srdf");
69 ASSERT_TRUE(std::filesystem::is_regular_file(srdf_path));
71 ASSERT_EQ(
srdf_xml_.LoadFile(srdf_path.c_str()), tinyxml2::XML_SUCCESS);
78unsigned int countElements(
const tinyxml2::XMLNode& parent,
const char* child_name)
80 unsigned int count = 0;
81 for (
const tinyxml2::XMLElement* sub_el = parent.FirstChildElement(child_name); sub_el !=
nullptr;
82 sub_el = sub_el->NextSiblingElement(child_name))
91 initializeWithFanuc();
95 ASSERT_NO_FATAL_FAILURE(generateXML());
97 auto root = srdf_xml_.FirstChildElement(
"robot");
98 ASSERT_NE(root,
nullptr) <<
"No <robot> element in generated SRDF";
99 EXPECT_EQ(std::string(root->Attribute(
"name")), std::string(
"fanuc"));
100 EXPECT_TRUE(root->NoChildren());
105 initializeWithFanuc();
109 std::string group_name =
"manipulator";
112 std::vector<std::string> joints = {
"joint_1",
"joint_2" };
115 ASSERT_NO_FATAL_FAILURE(generateXML());
117 auto root = srdf_xml_.FirstChildElement(
"robot");
118 ASSERT_NE(root,
nullptr) <<
"No <robot> element in generated SRDF";
119 auto group_el = root->FirstChildElement(
"group");
120 ASSERT_NE(group_el,
nullptr);
121 EXPECT_EQ(std::string(group_el->Attribute(
"name")), group_name);
124 joints.push_back(
"joint_3");
125 joints.push_back(
"joint_4");
128 ASSERT_NO_FATAL_FAILURE(generateXML());
130 root = srdf_xml_.FirstChildElement(
"robot");
131 group_el = root->FirstChildElement(
"group");
132 ASSERT_NE(group_el,
nullptr);
138 initializeWithFanuc();
142 std::string group_name =
"manipulator";
145 std::vector<std::string> links = {
"base_link",
"link_1" };
148 ASSERT_NO_FATAL_FAILURE(generateXML());
150 auto root = srdf_xml_.FirstChildElement(
"robot");
151 ASSERT_NE(root,
nullptr) <<
"No <robot> element in generated SRDF";
152 auto group_el = root->FirstChildElement(
"group");
153 ASSERT_NE(group_el,
nullptr);
154 EXPECT_EQ(std::string(group_el->Attribute(
"name")), group_name);
157 links.push_back(
"link_2");
158 links.push_back(
"link_3");
161 ASSERT_NO_FATAL_FAILURE(generateXML());
163 root = srdf_xml_.FirstChildElement(
"robot");
164 group_el = root->FirstChildElement(
"group");
165 ASSERT_NE(group_el,
nullptr);
171 initializeWithFanuc();
175 std::string group_name =
"manipulator";
178 std::vector<std::string> joints = {
"joint_1",
"joint_2" };
181 ASSERT_NO_FATAL_FAILURE(generateXML());
183 auto root = srdf_xml_.FirstChildElement(
"robot");
184 ASSERT_NE(root,
nullptr) <<
"No <robot> element in generated SRDF";
185 auto group_el = root->FirstChildElement(
"group");
186 ASSERT_NE(group_el,
nullptr);
187 EXPECT_EQ(std::string(group_el->Attribute(
"name")), group_name);
191 std::vector<std::string> links = {
"base_link",
"link_1" };
194 ASSERT_NO_FATAL_FAILURE(generateXML());
196 root = srdf_xml_.FirstChildElement(
"robot");
197 group_el = root->FirstChildElement(
"group");
198 ASSERT_NE(group_el,
nullptr);
199 EXPECT_EQ(std::string(group_el->Attribute(
"name")), group_name);
206 testing::InitGoogleTest(&argc, argv);
207 rclcpp::init(argc, argv);
208 return RUN_ALL_TESTS();
std::shared_ptr< SRDFConfig > srdf_config_
tinyxml2::XMLDocument srdf_xml_
void initializeWithFanuc()
void generateXML(const std::string &robot_name="fanuc")
void initializeWithURDF(const std::filesystem::path &urdf)
Test environment with DataWarehouse setup and help for generating files in a temp dir.
moveit_setup::DataWarehousePtr config_data_
void generateFiles(const std::string &config_name)
Helper function for generating all the files for a particular config to a temporary directory.
std::filesystem::path output_dir_
void setLinks(const std::string &group_name, const std::vector< std::string > &link_names)
Set the specified group's link names.
void setJoints(const std::string &group_name, const std::vector< std::string > &joint_names)
Set the specified group's joint names.
T * create(const std::string &name)
Create an item with the given name and return the pointer.
std::filesystem::path getSharePath(const std::string &package_name)
Return a path for the given package's share folder.
std::filesystem::path getSharePath(const std::string &package_name)
Return a path for the given package's share folder.
int main(int argc, char **argv)
unsigned int countElements(const tinyxml2::XMLNode &parent, const char *child_name)