I was looking for a way to accomplish this without the useful but cumbersome dynamic_reconfigure package as I think we have enough things to deal with, just considering ROS messages/actions/services, launch files (that support YAML syntax in XML...) and catkin specific CMakeLists file without adding another layer of complexity which is often unneeded.
So here is my working but *flawed example (I followed Asormeville's hints):
#include <ros/ros.h>
#include <ros/xmlrpc_manager.h>
#include <std_msgs/String.h>
void callback(XmlRpc::XmlRpcValue& params, XmlRpc::XmlRpcValue& result)
{
ROS_ERROR("Updated parameters!");
}
int main(int argc, char **argv)
{
XmlRpc::XmlRpcValue params, result, payload;
ros::init(argc, argv, "test_node");
ros::NodeHandle nh;
ros::XMLRPCManager::instance()->unbind("paramUpdate");
ros::XMLRPCManager::instance()->bind("paramUpdate", callback);
ros::param::set("~test_param", true);
ROS_INFO("Created new parameter through XmlRpc API call.");
params[0] = ros::this_node::getName();
params[1] = ros::XMLRPCManager::instance()->getServerURI();
params[2] = ros::names::resolve(std::string("~test_param"));
if (ros::master::execute("subscribeParam", params, result, payload, false)) {
ROS_INFO("Subscribed to parameter.");
}
else {
ROS_ERROR("Failed to subscribe to the parameter.");
}
while (ros::ok()) {
ros::spinOnce();
}
return 0;
}
The next steps would be to have a specific callback per parameter.
But I don't know if that would be possible and it would begin to look like Publishers/Subscribers mechanisms.
* The ROS node redefining this callback won't be able to use the ros::param::getCached() function anymore.