deprecate 'bug' where you are allowed to not specify the root link if you call it 'world'

This commit is contained in:
wim 2009-11-21 01:18:39 +00:00
parent a0ffa1a8b8
commit ac0782a7fa
2 changed files with 10 additions and 18 deletions

View File

@ -257,23 +257,15 @@ bool Model::initTree(std::map<std::string, std::string> &parent_link_tree)
std::string child_link_name = joint->second->child_link_name; 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()); 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 /// deal with deprecated case
if (parent_link_name == "world") 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());
if (this->getLink(parent_link_name)) boost::shared_ptr<Link> link;
{ link.reset(new Link);
ROS_DEBUG(" parent link '%s' already exists.", parent_link_name.c_str()); link->name = "world";
} this->links_.insert(make_pair(link->name,link));
else ROS_DEBUG(" successfully added new link '%s'", link->name.c_str());
{
ROS_DEBUG(" parent link '%s' is a special case, adding fake link.", parent_link_name.c_str());
boost::shared_ptr<Link> 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()) if (parent_link_name.empty())

View File

@ -91,7 +91,7 @@ int main(int argc, char** argv)
if (!root_link) return -1; if (!root_link) return -1;
if (!root_link->child_links.empty()) 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 // print entire tree