void Robot::setAlpha(float a) { alpha_ = a; M_NameToLink::iterator it = links_.begin(); M_NameToLink::iterator end = links_.end(); for ( ; it != end; ++it ) { RobotLink* link = it->second; link->setRobotAlpha(alpha_); } }
void Robot::load( const urdf::ModelInterface &urdf, bool visual, bool collision ) { link_tree_->hide(); // hide until loaded robot_loaded_ = false; // clear out any data (properties, shapes, etc) from a previously loaded robot. clear(); // the root link is discovered below. Set to NULL until found. root_link_ = NULL; // Create properties for each link. // Properties are not added to display until changedLinkTreeStyle() is called (below). { typedef std::map<std::string, boost::shared_ptr<urdf::Link> > M_NameToUrdfLink; M_NameToUrdfLink::const_iterator link_it = urdf.links_.begin(); M_NameToUrdfLink::const_iterator link_end = urdf.links_.end(); for( ; link_it != link_end; ++link_it ) { const boost::shared_ptr<const urdf::Link>& urdf_link = link_it->second; std::string parent_joint_name; if (urdf_link != urdf.getRoot() && urdf_link->parent_joint) { parent_joint_name = urdf_link->parent_joint->name; } RobotLink* link = link_factory_->createLink( this, urdf_link, parent_joint_name, visual, collision ); if (urdf_link == urdf.getRoot()) { root_link_ = link; } links_[urdf_link->name] = link; link->setRobotAlpha( alpha_ ); } } // Create properties for each joint. // Properties are not added to display until changedLinkTreeStyle() is called (below). { typedef std::map<std::string, boost::shared_ptr<urdf::Joint> > M_NameToUrdfJoint; M_NameToUrdfJoint::const_iterator joint_it = urdf.joints_.begin(); M_NameToUrdfJoint::const_iterator joint_end = urdf.joints_.end(); for( ; joint_it != joint_end; ++joint_it ) { const boost::shared_ptr<const urdf::Joint>& urdf_joint = joint_it->second; RobotJoint* joint = link_factory_->createJoint( this, urdf_joint ); joints_[urdf_joint->name] = joint; joint->setRobotAlpha( alpha_ ); } } // robot is now loaded robot_loaded_ = true; link_tree_->show(); // set the link tree style and add link/joint properties to rviz pane. setLinkTreeStyle(LinkTreeStyle(link_tree_style_->getOptionInt())); changedLinkTreeStyle(); // at startup the link tree is collapsed since it is large and not often needed. link_tree_->collapse(); setVisualVisible( isVisualVisible() ); setCollisionVisible( isCollisionVisible() ); }