double radius2=0.0; bool result=nh.getParam("radius",radius2); if (result) { ROS_INFO("radius is %.2f",radius2); }else{ ROS_INFO("radius not exist"); }
std::vector<std::string> names; nh.getParamNames(names); for (auto &&name : names) { ROS_INFO("paramName is %s",name.c_str()); }
bool flag1=nh.hasParam("radius"); bool flag2=nh.hasParam("radiusxxx"); ROS_INFO("radius is exist? %d",flag1); ROS_INFO("radiusxxx is exist? %d",flag2);
std::string key; nh.searchParam("radius",key); ROS_INFO("result is %s",key.c_str());
if __name__ == "__main__": rospy.init_node("param_get_p") radius=rospy.get_param("radius_p",15) radius1=rospy.get_param("radius_p_",15) rospy.loginfo("radius is %.2f",radius) rospy.loginfo("radius is %.2f",radius1)
names=rospy.get_param_names() for name in names: rospy.loginfo("param name is %s",name)
flag1=rospy.has_param("radius_p") if flag1: rospy.loginfo("radius_p is exist") else: rospy.loginfo("radius_p not exist")
if __name__ == "__main__": rospy.init_node("param_del_p") try: rospy.delete_param("type_p") except Exception as e: rospy.loginfo("deleted param is not exist") pass