How to avoid hard coding the node name prefixes while setting ros parameter ?
I'm working on robot_localization package.
I have requirement now.
I want to set all the parameters as in this node test_ekf_localization_node_bag1_ekf
in my main()
function at the position /* set parameters here */
The main()
is as follows:
int main(int argc, char** argv)
{
ros::init(argc, argv, "ekf_node");
ros::NodeHandle nh;
ros::NodeHandle nh_priv("~");
**/* set parameters here */**
if (!nh.ok()) return 1;
RobotLocalization::RosEkf ekf(nh, nh_priv);
ekf.initialize();
ros::spin();
}
However, If I want to do so, I need to prefix all the parameters with node name, which I don't want to do.
Example:
int main(int argc, char** argv)
{
ros::init(argc, argv, "ekf_node");
ros::NodeHandle nh;
ros::NodeHandle nh_priv("~");
nh.setParam("ekf_node/frequency", 30);
nh.setParam("ekf_node/sensor_timeout", 0.1);
nh.setParam("ekf_node/two_d_mode", false);
RobotLocalization::RosEkf ekf(nh, nh_priv);
ekf.initialize();
ros::spin();
}
Any solution to avoid this prefix and set these parameters in main()
here ?