@@ -72,6 +72,9 @@ bool HardwareInterface::init(ros::NodeHandle& root_nh, ros::NodeHandle& robot_hw
72
72
std::string output_recipe_filename;
73
73
std::string input_recipe_filename;
74
74
75
+ // Load URDF file from parameter server
76
+ loadURDF (robot_hw_nh, " robot_description" );
77
+
75
78
// The robot's IP address.
76
79
if (!robot_hw_nh.getParam (" robot_ip" , robot_ip_))
77
80
{
@@ -956,6 +959,37 @@ bool HardwareInterface::checkControllerClaims(const std::set<std::string>& claim
956
959
}
957
960
return false ;
958
961
}
962
+
963
+ void HardwareInterface::loadURDF (ros::NodeHandle& nh, std::string param_name)
964
+ {
965
+ std::string urdf_string;
966
+ urdf_model_ = new urdf::Model ();
967
+
968
+ // search and wait for robot_description on param server
969
+ while (urdf_string.empty () && ros::ok ())
970
+ {
971
+ std::string search_param_name;
972
+ if (nh.searchParam (param_name, search_param_name))
973
+ {
974
+ ROS_INFO_STREAM (" Waiting for model URDF on the ROS param server at location: " << nh.getNamespace ()
975
+ << search_param_name);
976
+ nh.getParam (search_param_name, urdf_string);
977
+ }
978
+ else
979
+ {
980
+ ROS_INFO_STREAM (" Waiting for model URDF on the ROS param server at location: " << nh.getNamespace ()
981
+ << param_name);
982
+ nh.getParam (param_name, urdf_string);
983
+ }
984
+
985
+ usleep (100000 );
986
+ }
987
+
988
+ if (!urdf_model_->initString (urdf_string))
989
+ ROS_ERROR_STREAM (" Unable to load URDF model" );
990
+ else
991
+ ROS_DEBUG_STREAM (" Received URDF from param server" );
992
+ }
959
993
} // namespace ur_driver
960
994
961
995
PLUGINLIB_EXPORT_CLASS (ur_driver::HardwareInterface, hardware_interface::RobotHW)
0 commit comments