42 #include <urdf_model/model.h> 
   44 #include <OgreSceneNode.h> 
   45 #include <OgreSceneManager.h> 
   46 #include <OgreEntity.h> 
   47 #include <OgreMaterialManager.h> 
   48 #include <OgreMaterial.h> 
   49 #include <OgreResourceGroupManager.h> 
   58              const std::string& name,
 
   60   : scene_manager_(context->getSceneManager())
 
   62   , visual_visible_(true)
 
   63   , collision_visible_(false)
 
   65   , doing_set_checkbox_(false)
 
   66   , robot_loaded_(false)
 
   67   , inChangedEnableAllLinks(false)
 
   90                        "Expand link details (sub properties) to see all info for all links.", 
link_tree_,
 
   94                        "Expand joint details (sub properties) to see all info for all joints.",
 
  151   M_NameToLink::iterator it = 
links_.begin();
 
  152   M_NameToLink::iterator end = 
links_.end();
 
  153   for (; it != end; ++it)
 
  179   M_NameToLink::iterator it = 
links_.begin();
 
  180   M_NameToLink::iterator end = 
links_.end();
 
  181   for (; it != end; ++it)
 
  196   M_NameToLink::iterator link_it = 
links_.begin();
 
  197   M_NameToLink::iterator link_end = 
links_.end();
 
  198   for (; link_it != link_end; ++link_it)
 
  204   M_NameToJoint::iterator joint_it = 
joints_.begin();
 
  205   M_NameToJoint::iterator joint_end = 
joints_.end();
 
  206   for (; joint_it != joint_end; ++joint_it)
 
  220                                           const urdf::LinkConstSharedPtr& link,
 
  221                                           const std::string& parent_joint_name,
 
  225   return new RobotLink(robot, link, parent_joint_name, visual, collision);
 
  247     typedef std::map<std::string, urdf::LinkSharedPtr> M_NameToUrdfLink;
 
  248     M_NameToUrdfLink::const_iterator link_it = 
urdf.links_.begin();
 
  249     M_NameToUrdfLink::const_iterator link_end = 
urdf.links_.end();
 
  250     for (; link_it != link_end; ++link_it)
 
  252       const urdf::LinkConstSharedPtr& urdf_link = link_it->second;
 
  253       std::string parent_joint_name;
 
  255       if (urdf_link != 
urdf.getRoot() && urdf_link->parent_joint)
 
  257         parent_joint_name = urdf_link->parent_joint->name;
 
  262       if (urdf_link == 
urdf.getRoot())
 
  267       links_[urdf_link->name] = link;
 
  276     typedef std::map<std::string, urdf::JointSharedPtr> M_NameToUrdfJoint;
 
  277     M_NameToUrdfJoint::const_iterator joint_it = 
urdf.joints_.begin();
 
  278     M_NameToUrdfJoint::const_iterator joint_end = 
urdf.joints_.end();
 
  279     for (; joint_it != joint_end; ++joint_it)
 
  281       const urdf::JointConstSharedPtr& urdf_joint = joint_it->second;
 
  284       joints_[urdf_joint->name] = joint;
 
  308   M_NameToLink::iterator link_it = 
links_.begin();
 
  309   M_NameToLink::iterator link_end = 
links_.end();
 
  310   for (; link_it != link_end; ++link_it)
 
  312     link_it->second->setParentProperty(
nullptr);
 
  316   M_NameToJoint::iterator joint_it = 
joints_.begin();
 
  317   M_NameToJoint::iterator joint_end = 
joints_.end();
 
  318   for (; joint_it != joint_end; ++joint_it)
 
  320     joint_it->second->setParentProperty(
nullptr);
 
  327   M_NameToLink::iterator link_it = 
links_.begin();
 
  328   M_NameToLink::iterator link_end = 
links_.end();
 
  329   for (; link_it != link_end; ++link_it)
 
  331     link_it->second->useDetailProperty(use_detail);
 
  335   M_NameToJoint::iterator joint_it = 
joints_.begin();
 
  336   M_NameToJoint::iterator joint_end = 
joints_.end();
 
  337   for (; joint_it != joint_end; ++joint_it)
 
  339     joint_it->second->useDetailProperty(use_detail);
 
  347   M_NameToLink::iterator link_it = 
links_.begin();
 
  348   M_NameToLink::iterator link_end = 
links_.end();
 
  349   for (; link_it != link_end; ++link_it)
 
  352       link_it->second->getLinkProperty()->expand();
 
  354       link_it->second->getLinkProperty()->collapse();
 
  357   M_NameToJoint::iterator joint_it = 
joints_.begin();
 
  358   M_NameToJoint::iterator joint_end = 
joints_.end();
 
  359   for (; joint_it != joint_end; ++joint_it)
 
  362       joint_it->second->getJointProperty()->expand();
 
  364       joint_it->second->getJointProperty()->collapse();
 
  372   M_NameToLink::iterator link_it = 
links_.begin();
 
  373   M_NameToLink::iterator link_end = 
links_.end();
 
  374   for (; link_it != link_end; ++link_it)
 
  376     link_it->second->hideSubProperties(hide);
 
  379   M_NameToJoint::iterator joint_it = 
joints_.begin();
 
  380   M_NameToJoint::iterator joint_end = 
joints_.end();
 
  381   for (; joint_it != joint_end; ++joint_it)
 
  383     joint_it->second->hideSubProperties(hide);
 
  391   M_NameToLink::iterator link_it = 
links_.begin();
 
  392   M_NameToLink::iterator link_end = 
links_.end();
 
  393   for (; link_it != link_end; ++link_it)
 
  395     link_it->second->expandDetails(expand);
 
  403   M_NameToJoint::iterator joint_it = 
joints_.begin();
 
  404   M_NameToJoint::iterator joint_end = 
joints_.end();
 
  405   for (; joint_it != joint_end; ++joint_it)
 
  407     joint_it->second->expandDetails(expand);
 
  420   M_NameToLink::iterator link_it = 
links_.begin();
 
  421   M_NameToLink::iterator link_end = 
links_.end();
 
  422   for (; link_it != link_end; ++link_it)
 
  424     if (link_it->second->hasGeometry())
 
  426       link_it->second->getLinkProperty()->setValue(enable);
 
  430   M_NameToJoint::iterator joint_it = 
joints_.begin();
 
  431   M_NameToJoint::iterator joint_end = 
joints_.end();
 
  432   for (; joint_it != joint_end; ++joint_it)
 
  434     if (joint_it->second->hasDescendentLinksWithGeometry())
 
  436       joint_it->second->getJointProperty()->setValue(enable);
 
  461   std::map<LinkTreeStyle, std::string>::const_iterator style_it = 
style_name_map_.begin();
 
  462   std::map<LinkTreeStyle, std::string>::const_iterator style_end = 
style_name_map_.end();
 
  463   for (; style_it != style_end; ++style_it)
 
  486   std::map<LinkTreeStyle, std::string>::const_iterator style_it = 
style_name_map_.find(style);
 
  519     M_NameToJoint::iterator joint_it = 
joints_.begin();
 
  520     M_NameToJoint::iterator joint_end = 
joints_.end();
 
  521     for (; joint_it != joint_end; ++joint_it)
 
  523       joint_it->second->setParentProperty(
link_tree_);
 
  524       joint_it->second->setJointPropertyDescription();
 
  532     M_NameToLink::iterator link_it = 
links_.begin();
 
  533     M_NameToLink::iterator link_end = 
links_.end();
 
  534     for (; link_it != link_end; ++link_it)
 
  536       link_it->second->setParentProperty(
link_tree_);
 
  546         "A tree of all links in the robot.  Uncheck a link to hide its geometry.");
 
  554         "A tree of all joints and links in the robot.  Uncheck a link to hide its geometry.");
 
  570         "All links in the robot in alphabetic order.  Uncheck a link to hide its geometry.");
 
  593   std::vector<std::string>::const_iterator child_joint_it = link->
getChildJointNames().begin();
 
  594   std::vector<std::string>::const_iterator child_joint_end = link->
getChildJointNames().end();
 
  595   for (; child_joint_it != child_joint_end; ++child_joint_it)
 
  624   M_NameToLink::iterator it = 
links_.find(name);
 
  627     ROS_WARN(
"Link [%s] does not exist", name.c_str());
 
  636   M_NameToJoint::iterator it = 
joints_.find(name);
 
  639     ROS_WARN(
"Joint [%s] does not exist", name.c_str());
 
  651   int links_with_geom_checked = 0;
 
  652   int links_with_geom_unchecked = 0;
 
  666     links_with_geom_checked += checked ? 1 : 0;
 
  667     links_with_geom_unchecked += checked ? 0 : 1;
 
  671   std::vector<std::string>::const_iterator child_joint_it = link->
getChildJointNames().begin();
 
  672   std::vector<std::string>::const_iterator child_joint_end = link->
getChildJointNames().end();
 
  673   for (; child_joint_it != child_joint_end; ++child_joint_it)
 
  678       int child_links_with_geom;
 
  679       int child_links_with_geom_checked;
 
  680       int child_links_with_geom_unchecked;
 
  682           child_links_with_geom, child_links_with_geom_checked, child_links_with_geom_unchecked);
 
  683       links_with_geom_checked += child_links_with_geom_checked;
 
  684       links_with_geom_unchecked += child_links_with_geom_unchecked;
 
  687   int links_with_geom = links_with_geom_checked + links_with_geom_unchecked;
 
  689   if (!links_with_geom)
 
  701   M_NameToLink::iterator link_it = 
links_.begin();
 
  702   M_NameToLink::iterator link_end = 
links_.end();
 
  703   for (; link_it != link_end; ++link_it)
 
  707     Ogre::Vector3 visual_position, collision_position;
 
  708     Ogre::Quaternion visual_orientation, collision_orientation;
 
  710                                   collision_position, collision_orientation))
 
  716       if (visual_orientation.isNaN())
 
  719                            "visual orientation of %s contains NaNs. " 
  720                            "Skipping render as long as the orientation is invalid.",
 
  724       if (visual_position.isNaN())
 
  728             "visual position of %s contains NaNs. Skipping render as long as the position is invalid.",
 
  732       if (collision_orientation.isNaN())
 
  735                            "collision orientation of %s contains NaNs. " 
  736                            "Skipping render as long as the orientation is invalid.",
 
  740       if (collision_position.isNaN())
 
  743                            "collision position of %s contains NaNs. " 
  744                            "Skipping render as long as the position is invalid.",
 
  748       link->
setTransforms(visual_position, visual_orientation, collision_position, collision_orientation);
 
  750       std::vector<std::string>::const_iterator joint_it = link->
getChildJointNames().begin();
 
  751       std::vector<std::string>::const_iterator joint_end = link->
getChildJointNames().end();
 
  752       for (; joint_it != joint_end; ++joint_it)