#include#include int main(int argc, char** argv) { ros::init(argc, argv, "getParam_example"); ros::NodeHandle nh; std::string paramValue; if (nh.getParam("param_name", paramValue)) { ROS_INFO("The param value is: %s", paramValue.c_str()); } else { ROS_INFO("The param 'param_name' doesn't exist!"); } return 0; }
#includeThis example retrieves an integer parameter named "param_name" from the parameter server and prints its value to the console. If the parameter doesn't exist, it prints a message indicating that the parameter doesn't exist. Package/library: ROSint main(int argc, char** argv) { ros::init(argc, argv, "getParam_example"); ros::NodeHandle nh; int paramValue; if (nh.getParam("param_name", paramValue)) { ROS_INFO("The param value is: %d", paramValue); } else { ROS_INFO("The param 'param_name' doesn't exist!"); } return 0; }