From ac0782a7fabdb8d78ccb56c7960d70b696b1bb70 Mon Sep 17 00:00:00 2001 From: wim Date: Sat, 21 Nov 2009 01:18:39 +0000 Subject: [PATCH] deprecate 'bug' where you are allowed to not specify the root link if you call it 'world' --- urdf/src/model.cpp | 26 +++++++++----------------- urdf/src/urdf_check.cpp | 2 +- 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/urdf/src/model.cpp b/urdf/src/model.cpp index 708e074..af4b30e 100644 --- a/urdf/src/model.cpp +++ b/urdf/src/model.cpp @@ -257,23 +257,15 @@ bool Model::initTree(std::map &parent_link_tree) std::string child_link_name = joint->second->child_link_name; ROS_DEBUG("build tree: joint: '%s' has parent link '%s' and child link '%s'", joint->first.c_str(), parent_link_name.c_str(),child_link_name.c_str()); - - /// add an empty "world" link - if (parent_link_name == "world") - { - if (this->getLink(parent_link_name)) - { - ROS_DEBUG(" parent link '%s' already exists.", parent_link_name.c_str()); - } - else - { - ROS_DEBUG(" parent link '%s' is a special case, adding fake link.", parent_link_name.c_str()); - boost::shared_ptr link; - link.reset(new Link); - link->name = "world"; - this->links_.insert(make_pair(link->name,link)); - ROS_DEBUG(" successfully added new link '%s'", link->name.c_str()); - } + + /// deal with deprecated case + if (parent_link_name == "world" && !this->getLink(parent_link_name)){ + ROS_WARN("Joint %s specifies the world link as its parent, but there in no link called world. This used to be allowed, but this behavior has been deprecated. You need to explicitly specify each link in your tree.", joint->first.c_str()); + boost::shared_ptr link; + link.reset(new Link); + link->name = "world"; + this->links_.insert(make_pair(link->name,link)); + ROS_DEBUG(" successfully added new link '%s'", link->name.c_str()); } if (parent_link_name.empty()) diff --git a/urdf/src/urdf_check.cpp b/urdf/src/urdf_check.cpp index 748537e..7712060 100644 --- a/urdf/src/urdf_check.cpp +++ b/urdf/src/urdf_check.cpp @@ -91,7 +91,7 @@ int main(int argc, char** argv) if (!root_link) return -1; if (!root_link->child_links.empty()) - std::cout << "root Link: " << root_link->name << " has " << root_link->child_links.size() << " children" << std::endl; + std::cout << "root Link: " << root_link->name << " has " << root_link->child_links.size() << " child(ren)" << std::endl; // print entire tree