50 MoveItSetupTest::SetUp();
62 initializeWithURDF(getSharePath(
"moveit_resources_fanuc_description") /
"urdf" /
"fanuc.urdf");
67 generateFiles<SRDFConfig>(
"srdf");
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();
97 auto root = srdf_xml_.FirstChildElement(
"robot");
98 EXPECT_EQ(std::string(root->Attribute(
"name")), std::string(
"fanuc"));
99 EXPECT_TRUE(root->NoChildren());
104 initializeWithFanuc();
108 std::string group_name =
"manipulator";
111 std::vector<std::string> joints = {
"joint_1",
"joint_2" };
116 auto root = srdf_xml_.FirstChildElement(
"robot");
117 auto group_el = root->FirstChildElement(
"group");
118 ASSERT_NE(group_el,
nullptr);
119 EXPECT_EQ(std::string(group_el->Attribute(
"name")), group_name);
122 joints.push_back(
"joint_3");
123 joints.push_back(
"joint_4");
128 root = srdf_xml_.FirstChildElement(
"robot");
129 group_el = root->FirstChildElement(
"group");
130 ASSERT_NE(group_el,
nullptr);
136 initializeWithFanuc();
140 std::string group_name =
"manipulator";
143 std::vector<std::string> links = {
"base_link",
"link_1" };
148 auto root = srdf_xml_.FirstChildElement(
"robot");
149 auto group_el = root->FirstChildElement(
"group");
150 ASSERT_NE(group_el,
nullptr);
151 EXPECT_EQ(std::string(group_el->Attribute(
"name")), group_name);
154 links.push_back(
"link_2");
155 links.push_back(
"link_3");
160 root = srdf_xml_.FirstChildElement(
"robot");
161 group_el = root->FirstChildElement(
"group");
162 ASSERT_NE(group_el,
nullptr);
168 initializeWithFanuc();
172 std::string group_name =
"manipulator";
175 std::vector<std::string> joints = {
"joint_1",
"joint_2" };
180 auto root = srdf_xml_.FirstChildElement(
"robot");
181 auto group_el = root->FirstChildElement(
"group");
182 ASSERT_NE(group_el,
nullptr);
183 EXPECT_EQ(std::string(group_el->Attribute(
"name")), group_name);
187 std::vector<std::string> links = {
"base_link",
"link_1" };
192 root = srdf_xml_.FirstChildElement(
"robot");
193 group_el = root->FirstChildElement(
"group");
194 ASSERT_NE(group_el,
nullptr);
195 EXPECT_EQ(std::string(group_el->Attribute(
"name")), group_name);
202 testing::InitGoogleTest(&argc, argv);
203 rclcpp::init(argc, argv);
204 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_
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.
int main(int argc, char **argv)
unsigned int countElements(const tinyxml2::XMLNode &parent, const char *child_name)